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


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error connecting to database" Watch "Error connecting to database" New topic
Author

Error connecting to database

Shanna Ripley
Greenhorn

Joined: Mar 12, 2010
Posts: 18
Hi All

I've just started trying to use JavaDB and have come across a few problems. I have my database set up and now I'm trying to connect to it. I think I set up the classpath for the project successfully but when I run my code I get the error...

java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/AddressBook

This is my code..



After printing the stack trace, the error is at..



I've tried googling this and some posts suggest it's a problem with the url but I've copyed and pasted mine in straight from the database Properties.

I'd appreciate any help or advice on fixing this error.

Thanks in advance
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2510
    
  10

Try to put the Class.forName() piece in the second try block, and remove the first try/catch pair.


Let is now if this fixed your issue.


OCUP UML fundamental and ITIL foundation
youtube channel
Shanna Ripley
Greenhorn

Joined: Mar 12, 2010
Posts: 18
Jan Cumps wrote:Try to put the Class.forName() piece in the second try block, and remove the first try/catch pair.


Let is now if this fixed your issue.


Unfortunately, it didn't work. Still getting the same error. Thanks for the suggestion though
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
No suitable driver found for indicates that either the connection URL is not correct or the driver jar is not in the classpath. You use embedded driver, so the connection URL should be in the format jdbc:derby:databaseName;URLAttributes . Look at http://developers.sun.com/docs/javadb/10.4.2.1/getstart/cgsquck19524.html
Shanna Ripley
Greenhorn

Joined: Mar 12, 2010
Posts: 18
I tried changing the url...



Now I'm getting the error

java.sql.SQLException: Database 'AddressBook' not found.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error connecting to database