• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to register Derby driver

 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I'm using Derby db in my program.
It seems that the derby driver is not getting registered with the driver manager.



And below is the property file:-


All it prints is

Please advise.

I read that for Derby, user name is app and password is not needed. Is it right?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pramod talekar wrote:I read that for Derby, user name is app and password is not needed. Is it right?


I don't know. But that's irrelevant to this problem; the error message appears because this line of code throws an exception:

In other words, that class can't be loaded.

Now I know you're going to say it's in your classpath and all that, but let me just point out that class names can't include quote characters. In fact you seem to have written your whole properties file as if you thought that properties files were some kind of Java code. They aren't. In particular that line of Java code where you tried to declare the jdbc.url property isn't going to work the way you thought it would.

So check out the API docs for java.util.Properties and look at the examples there.
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Paul,

Yeah, the user and password question is irrelevant here, just wanted to know more.

I'm going through the api.

Thanks for the super fast advice

 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

I changed the properties file as follows:


But I get the same messages again.

I had also removed the quotes from jdbc.drivers and tested but no use.

Please advise.
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact, I wrote



but no use.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So then that class isn't in your classpath.
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Paul,

I just found out that the related jar derby.jar doesn't contain ClientDriver class !!!
It contains EmbeddedDriver among other classes.
I rechecked my classpath, it has %DERBY_HOME%\lib\derby.jar;%DERBY_HOME%\lib; entries among others.
So I replaced ClientDriver with EmbeddedDriver but got the same message.



Isn't it strange to see no ClientDriver class ?
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've run all the classes in that jar which end with Driver i.e. AutoLoadedDriver, InternalDriver etc.
the same error is coming.

I'm downloading the derby setup again
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can't load a class which is in a jar you already have, then downloading another copy of the jar isn't going to fix anything. If you can't load a class which is in a jar you already have, that just means that jar isn't in your classpath. Fix that.
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Paul, I'm saying that the jar file derby.jar is not having the said class ClientDriver which looks strange to me.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd also suggest changing the code in your catch-blocks to

The code you have there now tells you nothing about the exception which was thrown.
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"org.apache.derby.jdbc.EmbeddedDriver"
Could not register.
Is that the exact error message? Haven't seen that in this form before.
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul & Jan,

Below is the stack trace :

for writing

I'm surprised how come the derby.jar file not having this ClientDriver class.

Please advise.
 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry guys.

The class ClientDriver.class is in DerbyClient.jar and not Derby.jar

The program is working fine now. :p

 
pramod talekar
Ranch Hand
Posts: 345
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, there is a small issue though.

How to write this statement :

If I replace jdbc.Database with the actual database name such as :

then it works fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic