Results 1 to 8 of 8
- 09-15-2011, 02:57 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Connection to the datebase can't be established
Connection code:
Error:Java Code:Connection veza = DriverManager.getConnection("jdbc:derby:C://Documents and Settings/$agud/MyDB", "abc", "abc");
I made the database "MyDB" and add derby to the Eclipse.Java Code:java.sql.SQLException: No suitable driver found for jdbc:derby:C://Documents and Settings/$agud/MyDB at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at paketjdbcprimjer1.GlavnaKlasa.main(GlavnaKlasa.java:20)
- 09-15-2011, 03:37 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: Connection to the datebase can't be established
Did you load and register the derby driver with Class.forName( ... )? Also, read the derby documentation, it is very detailed and explains it all.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 09-15-2011, 05:35 PM #3
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Re: Connection to the datebase can't be established
Java Code:private static String dbURL = "jdbc:derby:C://Documents and Settings/$agud/MyDB;create=true;user=abc;password=abc"; public static String driver = "org.apache.derby.jdbc.EmbeddedDriver";
Java Code:Class.forName(driver).newInstance();
Error:Java Code:Connection veza = DriverManager.getConnection(dbURL);
Java Code:java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at paketjdbcprimjer1.GlavnaKlasa.main(GlavnaKlasa.java:22)
- 09-15-2011, 05:42 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: Connection to the datebase can't be established
There's a derby.jar file somewhere on your system (I hope) that contains your driver class; is that jar file on your classpath? The error message indicates it isn't.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 09-15-2011, 06:51 PM #5
Member
- Join Date
- Sep 2011
- Posts
- 3
- Rep Power
- 0
Re: Connection to the datebase can't be established
Thx Jos.
I finally find out what I have missed.
I did copied derby.jar in lib folder in Java project, but I didn't "Add JARs" in Project properties.
- 09-16-2011, 08:11 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: Connection to the datebase can't be established
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 09-16-2011, 09:23 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,475
- Rep Power
- 16
- 09-16-2011, 10:18 AM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Java.net.socket connection :connection closed
By veeru541 in forum Advanced JavaReplies: 2Last Post: 06-27-2010, 02:14 AM -
Exception: An established connection was aborted by the software in your host machine
By vidhya.sk in forum Advanced JavaReplies: 7Last Post: 06-08-2010, 01:36 PM -
FTP connection
By java2010 in forum New To JavaReplies: 3Last Post: 04-19-2010, 09:46 AM -
we implement connection pooling ourselves, but why it always out of connection ?
By zengqingyi12 in forum JDBCReplies: 7Last Post: 10-20-2009, 10:34 AM -
no connection
By even in forum JDBCReplies: 15Last Post: 01-02-2008, 01:50 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks