NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Fail to establish the MySQL JDBC driver

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Zelig



Joined: 04 Apr 2009
Posts: 64
Location: FRANCE

PostPosted: Wed May 12, 2010 1:33 pm    Post subject: Fail to establish the MySQL JDBC driver Reply with quote

Hello everybody,

My problem is related to the use of the Connector JDBC for My SQL. In Netbeans, the driver appears and I can connect to my databases.

When I try to connect from a Java application, the command "Class.forName("com.mysql.jdbc.Driver")" triggers, at runtime, the following error message :
"java.lang.ClassNotFoundException : com.mysql.jdbc.Driver". Crying or Very sad

Can someone please help me?
Back to top
Peter Pis
Posted via mailing list.





PostPosted: Wed May 12, 2010 2:15 pm    Post subject: Fail to establish the MySQL JDBC driver Reply with quote

Hi,

have you added "MySQL JDBC Driver" library to the project? (Select the
project from "Projects" view and invoke "Properties" popup menu action,
switch to "Libraries" category -> "Compile" tab. By pushing "Add
Library" you can add that lib)

HTH,
-Peter

Zelig wrote:
Quote:
Hello everybody,

My problem is related to the use of the Connector JDBC for My SQL. In Netbeans, the driver appears and I can connect to my databases.

When I try to connect from a Java application, the command "Class.forName("com.mysql.jdbc.Driver")" triggers, at runtime, the following error message :
"java.lang.ClassNotFoundException : com.mysql.jdbc.Driver". [Crying or Very sad]

Can someone please help me?




Back to top
Filos



Joined: 14 Dec 2009
Posts: 3

PostPosted: Wed May 12, 2010 3:08 pm    Post subject: Re: Fail to establish the MySQL JDBC driver Reply with quote

Hello

I had the same problem and it was resolved by deleting the row:
Class.forName( JDBC_DRIVER ). There is no need to load the jdbc driver for latest version of jdbc driver . It's enough to establish the connection to database and then create a statement.

I hope it was helpful!!
Back to top
Zelig



Joined: 04 Apr 2009
Posts: 64
Location: FRANCE

PostPosted: Wed May 12, 2010 9:19 pm    Post subject: Re: Fail to establish the MySQL JDBC driver Reply with quote

Peter Pis wrote:
Hi,

have you added "MySQL JDBC Driver" library to the project? (Select the
project from "Projects" view and invoke "Properties" popup menu action,
switch to "Libraries" category -> "Compile" tab. By pushing "Add
Library" you can add that lib)

HTH,
-Peter

Zelig wrote:
Quote:
Hello everybody,

My problem is related to the use of the Connector JDBC for My SQL. In Netbeans, the driver appears and I can connect to my databases.

When I try to connect from a Java application, the command "Class.forName("com.mysql.jdbc.Driver")" triggers, at runtime, the following error message :
"java.lang.ClassNotFoundException : com.mysql.jdbc.Driver". [Crying or Very sad]

Can someone please help me?




Thanks Peter, your solution is efficient.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo