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!

No suitable driver found for derbyDB

843859Jun 7 2010 — edited Nov 20 2014
Hi ,

I'm trying to execute some queries on a Derby JDBC, the problem is that I cannot connect to it, here is the exception message:
java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/COREJAVA;create=true
and the connection method code:
public static Connection getConnection() throws SQLException, IOException
   {
      Properties props = new Properties();
      FileInputStream in = new FileInputStream("d:\\database.properties");
      props.load(in);
      in.close();

      String drivers = props.getProperty("jdbc.drivers");
      if (drivers != null) System.setProperty("jdbc.drivers", drivers);
      String url = props.getProperty("jdbc.url");
      String username = props.getProperty("jdbc.username");
      String password = props.getProperty("jdbc.password");

      return DriverManager.getConnection(url, username, password);
   }
now the d:\\database.properties file (how can I use a relative path ?? if I put it in the same folder as the source file it doesn't recognize it) contains:
#jdbc.drivers=org.apache.derby.jdbc.ClientDriver
jdbc.url=jdbc:derby://localhost:1527/COREJAVA;create=true
jdbc.username=dbuser
jdbc.password=secret
and the driver Derby.jar is in D:\Program Files\derbyDB\lib
I'm using NetBeans 6.8 IDE

THNX ALOT
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2010
Added on Jun 7 2010
4 comments
1,170 views