Discussion:
No suitable driver found for jdbc:derby
babylonlion
2010-03-31 18:26:11 UTC
Permalink
Hi experts,

I'm using JCreater to run a java program but after the program compiles
successfully, I get this error message:

java.sql.SQLException: No suitable driver found for
jdbc:derby:COREJAVA;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ExecSQL.getConnection(ExecSQL.java:86)
at ExecSQL.main(ExecSQL.java:22)

I'm using an emdedded driver. And I'm creating a database called COREJAVA

My environment variables are as follows:
CLASSPATH: .;C:\Apache\db-derby-10.5.3.0-bin\lib\derby.jar
HOME_DERBY: C:\Apache\db-derby-10.5.3.0-bin
Path: %DERBY_HOME%\bin

I've been working on it since Monday but couldn't get anywhere. Please help
me
--
View this message in context: http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28099914.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
Ronald Rudy
2010-03-31 18:28:35 UTC
Permalink
Try adding this first:

Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();

Adjust the classname for whichever driver you're using.

-Ron
Post by babylonlion
Hi experts,
I'm using JCreater to run a java program but after the program compiles
java.sql.SQLException: No suitable driver found for
jdbc:derby:COREJAVA;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ExecSQL.getConnection(ExecSQL.java:86)
at ExecSQL.main(ExecSQL.java:22)
I'm using an emdedded driver. And I'm creating a database called COREJAVA
CLASSPATH: .;C:\Apache\db-derby-10.5.3.0-bin\lib\derby.jar
HOME_DERBY: C:\Apache\db-derby-10.5.3.0-bin
Path: %DERBY_HOME%\bin
I've been working on it since Monday but couldn't get anywhere. Please help
me
--
View this message in context: http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28099914.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
babylonlion
2010-03-31 18:37:40 UTC
Permalink
I forgot to mension that I have a databse.properties file:

#jdbc.drivers=org.apache.derby.jdbc.EmbeddedDriver
jdbc.url=jdbc:derby:COREJAVA;create=true
jdbc.username=dbuser
jdbc.password=secret
Post by Ronald Rudy
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Adjust the classname for whichever driver you're using.
-Ron
Post by babylonlion
Hi experts,
I'm using JCreater to run a java program but after the program compiles
java.sql.SQLException: No suitable driver found for
jdbc:derby:COREJAVA;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ExecSQL.getConnection(ExecSQL.java:86)
at ExecSQL.main(ExecSQL.java:22)
I'm using an emdedded driver. And I'm creating a database called COREJAVA
CLASSPATH: .;C:\Apache\db-derby-10.5.3.0-bin\lib\derby.jar
HOME_DERBY: C:\Apache\db-derby-10.5.3.0-bin
Path: %DERBY_HOME%\bin
I've been working on it since Monday but couldn't get anywhere. Please help
me
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28099914.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
View this message in context: http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100056.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
babylonlion
2010-03-31 18:43:23 UTC
Permalink
Where do I need to add it?
Post by Ronald Rudy
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Adjust the classname for whichever driver you're using.
-Ron
Post by babylonlion
Hi experts,
I'm using JCreater to run a java program but after the program compiles
java.sql.SQLException: No suitable driver found for
jdbc:derby:COREJAVA;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ExecSQL.getConnection(ExecSQL.java:86)
at ExecSQL.main(ExecSQL.java:22)
I'm using an emdedded driver. And I'm creating a database called COREJAVA
CLASSPATH: .;C:\Apache\db-derby-10.5.3.0-bin\lib\derby.jar
HOME_DERBY: C:\Apache\db-derby-10.5.3.0-bin
Path: %DERBY_HOME%\bin
I've been working on it since Monday but couldn't get anywhere. Please help
me
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28099914.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
View this message in context: http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100127.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
Ronald Rudy
2010-03-31 18:45:20 UTC
Permalink
Before attempting to make the connection in your ExecSQL.getConnection() method by the looks of it.

You can also add it anywhere in that class statically like this:

static {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
}
Post by babylonlion
Where do I need to add it?
Post by Ronald Rudy
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Adjust the classname for whichever driver you're using.
-Ron
Post by babylonlion
Hi experts,
I'm using JCreater to run a java program but after the program compiles
java.sql.SQLException: No suitable driver found for
jdbc:derby:COREJAVA;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ExecSQL.getConnection(ExecSQL.java:86)
at ExecSQL.main(ExecSQL.java:22)
I'm using an emdedded driver. And I'm creating a database called COREJAVA
CLASSPATH: .;C:\Apache\db-derby-10.5.3.0-bin\lib\derby.jar
HOME_DERBY: C:\Apache\db-derby-10.5.3.0-bin
Path: %DERBY_HOME%\bin
I've been working on it since Monday but couldn't get anywhere. Please help
me
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28099914.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
View this message in context: http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100127.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
babylonlion
2010-03-31 18:55:20 UTC
Permalink
I'm sorry but I'm really new to this and I'm not sure how or where to add
this piece of code. And what is "class.forName"?
Post by Ronald Rudy
Before attempting to make the connection in your ExecSQL.getConnection()
method by the looks of it.
static {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
}
Post by babylonlion
Where do I need to add it?
Post by Ronald Rudy
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Adjust the classname for whichever driver you're using.
-Ron
Post by babylonlion
Hi experts,
I'm using JCreater to run a java program but after the program compiles
java.sql.SQLException: No suitable driver found for
jdbc:derby:COREJAVA;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ExecSQL.getConnection(ExecSQL.java:86)
at ExecSQL.main(ExecSQL.java:22)
I'm using an emdedded driver. And I'm creating a database called COREJAVA
CLASSPATH: .;C:\Apache\db-derby-10.5.3.0-bin\lib\derby.jar
HOME_DERBY: C:\Apache\db-derby-10.5.3.0-bin
Path: %DERBY_HOME%\bin
I've been working on it since Monday but couldn't get anywhere. Please help
me
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28099914.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100127.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
View this message in context: http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100309.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
babylonlion
2010-03-31 18:58:12 UTC
Permalink
I'm sorry but I'm really new to this and I'm not sure how or where to add
this piece of code. And what is "class.forName"? By the way, my instructore
has the same exact code and it's working fine. I did everything the way he
has on his computer but no luck. It's weird
Post by Ronald Rudy
Before attempting to make the connection in your ExecSQL.getConnection()
method by the looks of it.
static {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
}
Post by babylonlion
Where do I need to add it?
Post by Ronald Rudy
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Adjust the classname for whichever driver you're using.
-Ron
Post by babylonlion
Hi experts,
I'm using JCreater to run a java program but after the program compiles
java.sql.SQLException: No suitable driver found for
jdbc:derby:COREJAVA;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ExecSQL.getConnection(ExecSQL.java:86)
at ExecSQL.main(ExecSQL.java:22)
I'm using an emdedded driver. And I'm creating a database called COREJAVA
CLASSPATH: .;C:\Apache\db-derby-10.5.3.0-bin\lib\derby.jar
HOME_DERBY: C:\Apache\db-derby-10.5.3.0-bin
Path: %DERBY_HOME%\bin
I've been working on it since Monday but couldn't get anywhere. Please help
me
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28099914.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100127.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
View this message in context: http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100339.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
Ronald Rudy
2010-03-31 19:37:48 UTC
Permalink
It's rather outside of the scope of this particular mailing list, but very basically what that does is load that class, allowing it to be registered with the DriverManager, which is where you grab your connection from with the connection string (jdbc:derby:xxxxx). Class.forName(String) is a method to load the class using the full classname.

See here:
http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html#embedded_driver

And here, general JDBC:
http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html

The second link is probably the best for you to familiarize yourself with.

Note that in the sample I gave, which came from the first link (Derby's own help tutorial), it actually creates an instance of the specified object. I don't believe this is actually necessary, not sure why it's set up that way.

By putting it in the static block in your ExecSQL class it basically ensures that that code is run whenever the ExecSQL class is loaded by the JVM. It is a bit dangerous however, as it will (I think) cause the application to halt if the specified class isn't available.

-Ron
Post by babylonlion
I'm sorry but I'm really new to this and I'm not sure how or where to add
this piece of code. And what is "class.forName"? By the way, my instructore
has the same exact code and it's working fine. I did everything the way he
has on his computer but no luck. It's weird
Post by Ronald Rudy
Before attempting to make the connection in your ExecSQL.getConnection()
method by the looks of it.
static {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
}
Post by babylonlion
Where do I need to add it?
Post by Ronald Rudy
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Adjust the classname for whichever driver you're using.
-Ron
Post by babylonlion
Hi experts,
I'm using JCreater to run a java program but after the program compiles
java.sql.SQLException: No suitable driver found for
jdbc:derby:COREJAVA;create=true
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at ExecSQL.getConnection(ExecSQL.java:86)
at ExecSQL.main(ExecSQL.java:22)
I'm using an emdedded driver. And I'm creating a database called COREJAVA
CLASSPATH: .;C:\Apache\db-derby-10.5.3.0-bin\lib\derby.jar
HOME_DERBY: C:\Apache\db-derby-10.5.3.0-bin
Path: %DERBY_HOME%\bin
I've been working on it since Monday but couldn't get anywhere. Please help
me
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28099914.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100127.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
--
View this message in context: http://old.nabble.com/No-suitable-driver-found-for-jdbc%3Aderby-tp28099914p28100339.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.
Loading...