NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
kaldente
Joined: 13 Nov 2010 Posts: 1
|
Posted: Sat Nov 13, 2010 7:43 pm Post subject: 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! |
|
| Back to top |
|
 |
areeda
Joined: 28 Aug 2008 Posts: 469 Location: Los Angeles
|
Posted: Sun Nov 14, 2010 1:53 am Post subject: |
|
|
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.
|
Posted: Mon Nov 15, 2010 5:03 am Post subject: java.sql.SQLException: No suitable driver |
|
|
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 |
|
 |
|
|
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
|
|