• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error connecting to database

 
Shanna Ripley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shanna Ripley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried changing the url...



Now I'm getting the error

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic