Hello,
I'm having a problem to register my driver for mysql. I'm working in win xp, netbeans 5.0 and mysql 5.0. I've put in my classpath this:
"C:\Archivos de programa\MySQL\mysql-connector-java-5.0.5"
and my code:
import java.sql.*;
public class SerDatos {
Connection conexion;
Statement sentencia;
ResultSet resultado;
public SerDatos() {
}
public void Conectar(){
//Register driver
try {
Class.forName("src.com.mysql.jdbc.Driver");
} catch (Exception e) {
System.out.println(e.getMessage());
}
// load connection mySql
try {
conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/movfinanc","root","u234");
sentencia = conexion.createStatement();
if (sentencia.execute("INSERT INTO area (Id_Area,Name) VALUES (1,'FISICA')")) {
resultado = sentencia.getResultSet();
}
} catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
return;
}
}// fin del metodo conectar
}
when i call this class and method Conectar, i get the message of exception
src.com.mysql.jdbc.Driver
SQLException: No suitable driver found for jdbc:mysql://localhost:3306/movfinanc
SQLState: 08001
VendorError: 0
I think first line is exception about register driver, and how can fix this?
I guess if i fix first, second line will not exist, right?
Thanks for your help!!