NetBeans Forums

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

java.sql.SQLException: No suitable driver

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



Joined: 13 Nov 2010
Posts: 1

PostPosted: Sat Nov 13, 2010 7:43 pm    Post subject: java.sql.SQLException: No suitable driver Reply with quote

Hi,

I'm trying a simple java test code to connect mysql server from a Netbean IDE but having "java.sql.SQLException: No suitable driver" issues.

configuration: NetBean IDE 6.9.1, mysql-connector-jave-5.1.13, windows 7 64 bit (this shouldn't be mattered but just in case...)

I added mysql/J to my project library and it shows up on my project property as well but I'm keep getting this error.

Here is the CODE
:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Test {

public static void main(String[] args) {

try {
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/ToDo", "root", "");

} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}

}

and OUTPUT:
run:
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/ToDo
SQLState: 08001
VendorError: 0
BUILD SUCCESSFUL (total time: 0 seconds)

Much appreciated in advance!
Back to top
areeda



Joined: 28 Aug 2008
Posts: 469
Location: Los Angeles

PostPosted: Sun Nov 14, 2010 1:53 am    Post subject: Reply with quote

I'm not 100% sure we're using the same mysql drivers but my code has one more call in it, the Class.forName;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

...

Class.forName("com.mysql.jdbc.Driver");

String connUrl = "jdbc:mysql://localhost/mydb"
conn = DriverManager.getConnection(connUrl, user, pass);
stmt = conn.createStatement();


Joe
Back to top
santosh
Posted via mailing list.





PostPosted: Mon Nov 15, 2010 5:03 am    Post subject: java.sql.SQLException: No suitable driver Reply with quote

Add driver class
Use
Class.forName(String Driverclass);
-----Original Message-----
From: kaldente [mailto:address-removed]
Sent: Sunday, November 14, 2010 1:14 AM
To: address-removed
Subject: [nbusers] java.sql.SQLException: No suitable driver

Hi,

I'm trying a simple java test code to connect mysql server from a Netbean
IDE but having "java.sql.SQLException: No suitable driver" issues.

configuration: NetBean IDE 6.9.1, mysql-connector-jave-5.1.13, windows 7 64
bit (this shouldn't be mattered but just in case...)

I added mysql/J to my project library and it shows up on my project property
as well but I'm keep getting this error.

Here is the CODE
:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Test {

public static void main(String[] args) {

try {
Connection conn =
DriverManager.getConnection("jdbc:mysql://localhost:3306/ToDo", "root", "");

} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}

}

and OUTPUT:
run:
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/ToDo
SQLState: 08001
VendorError: 0
BUILD SUCCESSFUL (total time: 0 seconds)

Much appreciated in advance!











Disclaimer : Information transmitted in this e-mail is proprietary to KARVY Group of companies. It is intended only for the addressee and may contain private, confidential and/or privileged material. Views contained in the email message are those of the sender and may not necessarily reflect those of Karvy. Review, retransmission, dissemination or other use of this information by the person other than the intended recipient is strictly prohibited. If you have received this communication in error, please contact the sender or notify address-removed and delete the material from any stored format/computer.
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