import java.sql.*;
public class MysqlConnect{
public static void main(String[] args) {
System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "sint";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "najeer";
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}
hai all J'essaie de le faire alors
c:/>java MysqlConnect.java
C:\>java -cp .;\local\lib\mysql-connector-java-5.1.15-bin.jar MysqlConnect
Exemple de connexion MySQL.
Exception in thread "main" java.lang.NoClassDefFoundError: java/sql/SQLClientInf
oException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.mysql.jdbc.ConnectionImpl.<clinit>(ConnectionImpl.java:270)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:305)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at MysqlConnect.main(MysqlConnect.java:15)
ce type d'erreur se produit merci de m'aider....