|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
werid problem, please help, thanks very much!!!I am getting a error when I try to get a connection, the werid thing is I can called the getConnection method with no problem from some project but got below erros in other projects:
java.lang.NoSuchMethodError: org.apache.derby.jdbc.InternalDriver.embeddedDriverAcceptsURL(Ljava/lang/String;)Z at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) my code is: private static final String driver = "com.mysql.jdbc.Driver"; private static final String dbName="Umbrella"; private static final String connectionURL = "jdbc:mysql://localhost:3306/" + dbName; Connection conn = null; conn = DriverManager.getConnection(connectionURL, "root", "password"); I don't know why there is anything to do with derby! i am using mysql(I was using derby before but I changed it) and from the connection string there is no way the code is calling derby and the code in fact was fine with some project (I am using eclipse) I think the code is correct but do I need to check any configuration settings? |
|
|
Re: werid problem, please help, thanks very much!!!my whole method is :
private static final String driver = "com.mysql.jdbc.Driver"; private static final String dbName="Umbrella"; private static final String connectionURL = "jdbc:mysql://localhost:3306/" + dbName; Connection conn = null; public Connection getConnection() { // Beginning of JDBC code sections // ## LOAD DRIVER SECTION ## try { Class.forName(driver); System.out.println(driver + " loaded. "); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); System.out.println("\n >>> Please check your CLASSPATH variable <<<\n"); } // Beginning of Primary DB access section // ## BOOT DATABASE SECTION ## try { conn = DriverManager.getConnection(connectionURL, "root", "raymoney"); System.out.println("URL: " + connectionURL); System.out.println("Connection: " + conn); // Beginning of the primary catch block: uses errorPrint method } catch (Throwable e) { /* Catch all exceptions and pass them to ** the exception reporting method */ System.out.println(" . . . . . .exception thrown:"); errorPrint(e); } System.out.println("Getting Started With MySql JDBC program ending."); return conn; } |
|
|
Re: werid problem, please help, thanks very much!!!Are you sure that the driver is the one that is effectively loaded? And that
there's not a registration of the derby driver for such url (should not happen)? Maybe eclipse is running another compiled version of the code, what about a clean+make of the project? Luca -- MySQL Java Mailing List For list archives: http://lists.mysql.com/java To unsubscribe: http://lists.mysql.com/java?unsub=lists@... |
| Free embeddable forum powered by Nabble | Forum Help |