Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot connect to Java DB database

843859Aug 22 2007 — edited Nov 20 2014
Hello,
Yep, it's me again.. learning JDBC.... SLOWLY. Anyway, I have read through a number of posts on this, and have not found any threads that answer my question.

I am working through the Sun JDBC tutorial using the COFFEEBREAK database. I have written the following code:
import java.sql.*;

public class FirstJDBC {
   public static void main(String[] args) throws SQLException, ClassNotFoundException {
      System.setProperty("derby.system.home","c:\\program files\\java\\jdk1.6.0\\db\\demo\\databases");
      Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
      Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/COFFEEBREAK;"."username","password");
   }
}
When I step through the code, I get:


Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/COFFEEBREAK;


I do have the EmbeddedDriver class in the appropriate location (%PROJECTHOME%/build/classes/org/apache/derby/jdbc/EmbeddedDriver.class)

I am using Netbeans 5.5

I have read some posts that say that this exception indicates either that:

1) You do not have an appropriate driver loaded for the database you are trying to connect to

2) There is a problem with the URL supplied in the getConnection() method.

I was told that this is the driver I should be using. Is that wrong? If so, can anyone tell me which driver I should be using?

Is the URL I'm using correct?

Please let me know if any more info is needed. Thanks in advance for any help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2007
Added on Aug 22 2007
6 comments
617 views