File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
I can't connect to DB
Ekrem Altintas
Greenhorn
Joined: Dec 04, 2006
Posts: 5
posted
Mar 17, 2008 04:08:00
0
Hi there,
I,m trying to connecting to sample database of NetBeans 6. But I'm getting an error on this line:
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
It says:
Method "forName" in class "java.lang.Class" threw an exception: instance of
java.lang.ClassNotFoundException
(id=349)
How can I solve this problem?
Thank you
import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; . . . . public class Databasecon { public void baglan() { Connection conn = null; try { String userName = "app"; String password = "app"; String url = "jdbc :mrgreen: erby://localhost:1527/sample"; Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance(); conn = DriverManager.getConnection (url, userName, password); } catch(Exception e) { System.out.println("Error!!!"); } } }
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
I like...
posted
Mar 17, 2008 04:15:00
0
Make sure your driver is in your classpath.
JavaRanch FAQ
HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
jrebel
subject: I can't connect to DB
Similar Threads
Help with Bean problem in JSP
connecting to mysql, with java, on a mac
problem with MySQL driver
Second thread is blocked until the first thread commit the transaction, I can not understand why...
problem with MySQL driver
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter