This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Another "No suitable driver found for ..." error -- yes, it does find the driver" Watch "Another "No suitable driver found for ..." error -- yes, it does find the driver" New topic
Author

Another "No suitable driver found for ..." error -- yes, it does find the driver

Jeff Hasz
Greenhorn

Joined: Jan 09, 2011
Posts: 4
Ok, I've tried all I know at this point and maybe some of you folks might know.

In an effort to learn Hibernate (in preparation for converting an application to use it instead of the home grown DAO), I created a stand alone program that does a couple queries and prints the results to the console. So far all is well. This runs just find and returns the expected results.

The application is a Netbeans platform application - modules, etc... I first attempted to move the code into it's own module/library, but that wasn't working so I figured I'd incorporate it directly ...

Now I am attempting to move this code, verbatim, over to the application (I wrote the original program against the applications DB - which is in derby) and now I get:

"INFO [org.hibernate.connection.DriverManagerConnectionProvider]: using driver: org.apache.derby.jdbc.ClientDriver at URL: jdbc:derby://localhost:1527/kslog
INFO [org.hibernate.connection.DriverManagerConnectionProvider]: connection properties: {user=user, password=****}
WARNING [org.hibernate.cfg.SettingsFactory]: Could not obtain connection metadata
java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/kslog"

I know it's finding the org.apache.derby.jdbc.ClientDriver class because if I tell it to use a different, nonexisting class, it gives a NoClassFound exception.

In all my research so far, the only thing I've found is that this indicates that the connection URL is bad - (the jdbc:derby://localhost:1527/kslog part)... However, this can't be the case, since I can connect to the DB using squirrel using that URL, using the exact same code, but from within a stand alone program, and from the original program using the existing home grown DAO.

Now, the only thing I can think of is that the remaining parts of the application that still use the home grown DAO are interfering with the Hibernate part? or is it something else?

My hibernate.cfg.xml file looks like this:



Any help would be appreciated as I am becoming a bit frustrated with this. It's probably something really simple that I am just not seeing - as these things are wont to be.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Hi Jeff Hasz,

Welcome to Javaranch.
It might sound simple but did you add the derby client jar or whatever jar you added can you go to the jar, explore it and find out if that particular ClientDriver class is present.


If you are not laughing at yourself, then you just didn't get the joke.
Jeff Hasz
Greenhorn

Joined: Jan 09, 2011
Posts: 4
Arun Kumarr wrote:Hi Jeff Hasz,

Welcome to Javaranch.
It might sound simple but did you add the derby client jar or whatever jar you added can you go to the jar, explore it and find out if that particular ClientDriver class is present.


Ok - I'm biting my tongue on this one... Yes, I did add the derbyclient.jar file and yes the ClientDriver.class is in there ... and as stated in the title of the thread the application is finding the driver. And yes, it is the correct driver - Iuse this very same driver in another, stand alone, program.

The program actually loads the driver class ...
I know it's finding the org.apache.derby.jdbc.ClientDriver class because if I tell it to use a different, nonexisting class, it gives a NoClassFound exception.


My apologies if I sound a bit frustrated with your answer, but I was up until the wee small hours futzing with this to no avail.

So, it's something else ... what I'm not sure. I am beginning to think that it is something to do with the mechanism of running from within the platform.

My next step is going to be attempting to use EclipseLink (basically following the tutorial modifying it for my own DB) and if that works, then I guess I'll go with that until Netbeans has a way/tutorial on how to do what I want with Hibernate.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Okay. What I really wanted to check is if you had manually added the jar to your IDE classpath without relying on the system classpath. This is because, if we are dealing with two classpaths, this issue might occur.

In net beans can you try adding your jar in runtime libraries.

If you've added then, I also wanted to check if there are no other version of the jar available in classpath.
I can't think of any other issue. Beats me too.
Jeff Hasz
Greenhorn

Joined: Jan 09, 2011
Posts: 4
Arun Kumarr wrote:Okay. What I really wanted to check is if you had manually added the jar to your IDE classpath without relying on the system classpath. This is because, if we are dealing with two classpaths, this issue might occur.

In net beans can you try adding your jar in runtime libraries.

If you've added then, I also wanted to check if there are no other version of the jar available in classpath.
I can't think of any other issue. Beats me too.


Ok, I'm a bit befuddled - all these late nights are beginning to make my brain operate really slowly ... Where do I manually set the IDE classpath? I've been using netbeans on and off since the beginning (apparently 2001) and I know there were some classpath issues early on, but I haven't found a place to put an actual classpath in. I've had more of these kind of classpath issues with Eclipse than Netbeans...

I can't imagine that this is the problem considering that with the original, home grown Data Access Layer it works just fine, and when building a standalone test app using hibernate it works just fine ... and when using the Netbeans EclipseLink tutorial, it works just fine (which I don't believe is Hibernate) ...

Tome to go load up the oversized coffee mug again and see if I can't coax a few more thoughts out of these weary brain cells ... currently I have the project set up so that it uses the original data layer. That way I can still make progress on the other areas I need to improve (UI, etc...)... but this is frustrating.

Thanks for the suggestions - really - I do appreciate them, it's just that I can't find anyplace to set the classpath in the IDE!
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Okay. Here goes the list of stupid things i faced when i tried to recreate netbeans with derby. (I actually downloaded both of them to check what could've gone wrong. )

1. It threw error and couldn't identify the classes i created. I had to manually create do a,

to see where it is looking and had to change my path accordingly.

2. Second the mapping tag was placed in the middle and it kept throwing some error and it got solved once i moved it
to the end.


3. Again, all through my "setting up of environment and trying to run the code", I kept getting compilation issues, so I had to clean every often. Though this sounds dumb, sometimes, when i did a clean and ran again the errors just disappeared. May be because it was an xml and was cached.

4. I added the derbyClient.jar in Right Click project -->Properties -->Libraries --> Add Jar/Folder.

5. Finally I right clicked on the project and selected Run -- > Viola it worked.

Hope this helps.
Jeff Hasz
Greenhorn

Joined: Jan 09, 2011
Posts: 4
Arun Kumarr wrote:Okay. Here goes the list of stupid things i faced when i tried to recreate netbeans with derby. (I actually downloaded both of them to check what could've gone wrong. )

1. It threw error and couldn't identify the classes i created. I had to manually create do a,

to see where it is looking and had to change my path accordingly.

2. Second the mapping tag was placed in the middle and it kept throwing some error and it got solved once i moved it
to the end.


3. Again, all through my "setting up of environment and trying to run the code", I kept getting compilation issues, so I had to clean every often. Though this sounds dumb, sometimes, when i did a clean and ran again the errors just disappeared. May be because it was an xml and was cached.

4. I added the derbyClient.jar in Right Click project -->Properties -->Libraries --> Add Jar/Folder.

5. Finally I right clicked on the project and selected Run -- > Viola it worked.

Hope this helps.


Thanks Arun for all the effort trying to help me figure out just what the heck is going on here... but (yeah, there had to be one) ... from reading what you wrote, I have a feeling you're missing one important bit of info.. This is a Netbeans Platform application ... which in Netbeans means Module projects.

The derbyclient.jar file is wrapped in a library wrapper module, and the entity code is wrapped in another one, and the Hibernate persistence stuff in a third ... and the actual application is in an actual Module project, all of which are under a Module Suite project or more preferably a Module Application project.

What's very strange is that I follow the Tutorial, and use EclipseLink and it works with the sample DB as shown in the tutorial, so I tried it with Hibernate - the sample db in the tutorial - and it doesn't work!

So I figure - ok, give up on Hibernate for now and go with EclipseLink ... get to the point of compile and run ... do a clean and build (no errors) and then a run ... and I get a persistence layer error - it can't start find the Persistence class to start the Persistence Unit (ProjectPU)... what a mess.

I'm about ready to go back to my own data access classes.

Again Arun, thanks for the efforts - I do appreciate it (see I am fairly pleasant when I've had enough sleep )
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Forgot to add this.
In my hbm file, I added, my table name as schemaName.tableName.


Jeff Hasz wrote:
I'm about ready to go back to my own data access classes.


Though not now, try it some other time. Don't give up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another "No suitable driver found for ..." error -- yes, it does find the driver
 
Similar Threads
Connecting jsp with derby
Can't connect to MySQL database with Hibernate
Unable to find a suitable driver
ClassNotFoundException
Schema Export Unsuccesful