Results 1 to 8 of 8
Thread: problem with java derby
- 06-26-2010, 07:05 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
problem with java derby
Hi im new to java DB(derby).I installed java db recently.I have set the classpath to derby.jar and derbytools.jar ,which has to be done for driver loading.
here's the sample code i tried with java DB
but i'm getting a error asJava Code:package test; import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author SRIDARSHAN */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { try { // TODO code application logic here Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); } catch (ClassNotFoundException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } try { Connection con = DriverManager.getConnection("jdbc:derby:testDB", "test", "test"); System.out.println("success"); } catch (SQLException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } }
help needed here fellas :(Java Code:Jun 26, 2010 11:12:15 AM test.Main main SEVERE: null java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at test.Main.main(Main.java:22)
- 06-26-2010, 08:57 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
You didn't set your classpath correctly; it should contain the full (or relative) path to derby.jar (including the file name); you don't need that other .jar file. Also, since you don't have your database yet you should append ";create=true" to your URL.
A dirty testing workaround is to put the derby.jar file in your lib/ext directory of your JRE so it will always be found, but don't put your application in production that way.
kind regards,
Jos
- 06-26-2010, 09:14 AM #3
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
First of all i'm using netbeans 6.8,
and i did set the classpath correctly,secondly i have created the database in netbeans,but when i ran the same program in command prompt class.forname() got executed,but there were errors with connection
- 06-26-2010, 09:19 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
Well, if you say your classpath value is correct but the Exception stack trace says it isn't, I don't want to be part of that arguement. Did you append your URL with the command ";create=true" and did you set the property "derby.system.home"? Read the ample documentation that comes with the JavaDB/Derby distribution.
kind regards,
Jos
- 06-26-2010, 09:26 AM #5
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
thanks for reply,
maybe i'm wrong,how do i check i set classpath(just to verify i did i right)?
and it gives that error only in netbeans,but the same program in cmd prompt gave this eror
Java Code:java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/ testDB at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at test.main(test.java:19)
- 06-26-2010, 10:39 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
I don't know NetBeans so I can't help you there, but what is that hostname and port number doing there? I thought you were using the embedded driver? Also, is your database created yet, i.e. did you put ";create=true" at the end of your URL? (it doesn't do anything if your database is already created). And again, did you set the "derby.system.home" property? Otherwise Derby doesn't know where to look for your database files.
kind regards,
Jos
- 06-26-2010, 10:52 AM #7
Member
- Join Date
- Jun 2010
- Posts
- 9
- Rep Power
- 0
how do set system.derby.home?
- 06-26-2010, 12:17 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
derby DB problem
By edi.gotieb in forum Forum LobbyReplies: 8Last Post: 05-17-2010, 12:45 PM -
Problem Connecting JavaDB (Derby) DB in other PC
By Blaine in forum JDBCReplies: 1Last Post: 05-11-2010, 10:31 AM -
need some derby tips:
By kulangotski in forum Advanced JavaReplies: 4Last Post: 03-09-2009, 05:09 PM -
using if in derby
By suhaib1thariq in forum JDBCReplies: 0Last Post: 01-25-2009, 04:46 AM -
Is there a problem with Derby?
By orion_mcl in forum Advanced JavaReplies: 0Last Post: 08-10-2007, 04:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks