Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem registering driver jdbc - mysql

843859May 17 2007 — edited May 24 2007
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!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 21 2007
Added on May 17 2007
19 comments
275 views