Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Java [игнор отключен] [закрыт для гостей] / java.sql.SQLException: Unknown database 'Auth' / 2 сообщений из 2, страница 1 из 1
04.07.2006, 16:38
    #33830756
sahar
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
java.sql.SQLException: Unknown database 'Auth'
При запуске скрипта выдает "java.sql.SQLException: Unknown database 'Auth'
"
База Auth существует. Что не так?
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
 import  java.sql.*;
 public   class  JDBCTest1
{
     public   static   void  main(String[] args)
    {
        String driver = "com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource";
        String url = "jdbc:mysql://127.0.0.1:3306/Auth";
        String fName;
         int  fId;
        Object fSalary;
        Connection con= null ;
        Statement st;
        ResultSet rs;
         try 
        {
             Class .forName(driver);
        }
         catch (ClassNotFoundException cnfe)
        {   
            System.err.println("Can't find JDBC driver");
            cnfe.printStackTrace();
            System.exit( 1 );
        }
         try 
        {
            con=DriverManager.getConnection(url, "user", "");
        }
         catch (SQLException se)
        {
            System.err.println("DB connection error");
            se.printStackTrace();
            System.exit( 1 );
        }
         try 
        {
            st = con.createStatement();
            rs = st.executeQuery("select id, adress, login from worker");
             while  (rs.next())
            {
                fId = rs.getInt("id");
                fName = rs.getString( 2 );
                fSalary = rs.getObject( 3 );
                System.out.println("id=" + fId + ", name=" + fName+",salary="+fSalary.toString());
            }
        }
         catch (SQLException se)
        {
            System.err.println("JDBC execution error");
            se.printStackTrace();
            System.exit( 1 );
        }
         try 
        {
            con.close();
        }
         catch (SQLException se)
        {
            System.err.println("Connection close error");
            se.printStackTrace();
            System.exit( 1 );
        }
    }
}
Драйвер mysql-connector-java-3.1.13-bin.jar

Полный текст ошибки
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
DB connection error
java.sql.SQLException: Unknown database 'Auth'
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java: 2975 )
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java: 798 )
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java: 1256 )
        at com.mysql.jdbc.Connection.createNewIO(Connection.java: 2568 )
        at com.mysql.jdbc.Connection.<init>(Connection.java: 1485 )
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java: 266 )
        at java.sql.DriverManager.getConnection(DriverManager.java: 525 )
        at java.sql.DriverManager.getConnection(DriverManager.java: 171 )
        at JDBCTest1.main(JDBCTest1.java: 26 )
Java Result:  1 
BUILD SUCCESSFUL (total time:  4  seconds)
...
Рейтинг: 0 / 0
04.07.2006, 18:40
    #33831150
Shkel Eugene
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
java.sql.SQLException: Unknown database 'Auth'
а обычный драйвер(без пула) тоже ругается ?
...
Рейтинг: 0 / 0
Форумы / Java [игнор отключен] [закрыт для гостей] / java.sql.SQLException: Unknown database 'Auth' / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]