aspose file tools*
The moose likes JDBC and the fly likes Unable to register Derby driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Unable to register Derby driver" Watch "Unable to register Derby driver" New topic
Author

Unable to register Derby driver

pramod talekar
Ranch Hand

Joined: Apr 26, 2010
Posts: 323

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?


Thanks,
Pramod
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

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

Joined: Apr 26, 2010
Posts: 323

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

Joined: Apr 26, 2010
Posts: 323

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

Joined: Apr 26, 2010
Posts: 323

In fact, I wrote



but no use.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

So then that class isn't in your classpath.
pramod talekar
Ranch Hand

Joined: Apr 26, 2010
Posts: 323

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

Joined: Apr 26, 2010
Posts: 323

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
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

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

Joined: Apr 26, 2010
Posts: 323

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
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

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

Joined: Dec 20, 2006
Posts: 2503
    
    8

"org.apache.derby.jdbc.EmbeddedDriver"
Could not register.
Is that the exact error message? Haven't seen that in this form before.

OCUP UML fundamental and ITIL foundation
youtube channel
pramod talekar
Ranch Hand

Joined: Apr 26, 2010
Posts: 323

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

Joined: Apr 26, 2010
Posts: 323

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

Joined: Apr 26, 2010
Posts: 323

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to register Derby driver