wood burning stoves*
The moose likes JDBC and the fly likes Couldn't Load Database Driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Couldn Watch "Couldn New topic
Author

Couldn't Load Database Driver

priya sunny
Greenhorn

Joined: May 25, 2011
Posts: 15
Hi
I am trying to connect to Derby Database, the input is given throught the html page , after clicking submit, i get the error message "Couldn't Load Database Driver".
the connection statements i used are here:

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
connection = DriverManager.getConnection("jdbc:derby:C:\\DerbyDatabases\\MyDB;create=true");

Can anyone help me???
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 532

Do you have the required jar file for derby database on your classpath?
priya sunny
Greenhorn

Joined: May 25, 2011
Posts: 15
Hi, i added the jar and it is working fine now. I am trying to create the table using servlet, first time when i run the application it is getting created. But when i run the "script.sql" it says "Table does not exists". What could be the error?? Is the table getting created somewhere else?? If so how will i find that??
Here is my code for your reference:

String sql ="create table APP.emp1 (userid varchar(10),firstname varchar(10),surname varchar(10),address1 varchar(10),address2 varchar(10),town varchar(10),country varchar(10),zipcode int)";
Statement ps = connection.createStatement();
ps.executeUpdate(sql)
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 532

What is there inside your script.sql and are you using the same database where you create this table in script.sql?
priya sunny
Greenhorn

Joined: May 25, 2011
Posts: 15
In script.sql , i just execute "select * from emp1". It says "Table does not exists"
And i have only one Database in my Derby.
priya sunny
Greenhorn

Joined: May 25, 2011
Posts: 15
priya sunny wrote:In script.sql , i just execute "select * from emp1". It says "Table does not exists"
And i have only one Database in my Derby.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 532

one database is fine, before executing select * from emp1, is the database put in use. I don't know the syntax in derby, in mysql we would use "use <dbname>" and then execute our statements..
 
GeeCON Prague 2014
 
subject: Couldn't Load Database Driver