import java.sql.*;
public class ConnectionMySQL{
public Connection connection;
public ConnectionMySQL(){
try{
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection("jdbc:mysql://localhost/Test", "user", "password");
}
catch(Exception e){System.out.println("connexion refuser"+e);}
}
public Statement createStatement(){
Statement ret=null;
try{
ret = connection.createStatement();
}
catch(SQLException e){System.out.println("error create statement :"+e);}
return ret;
}
public static void main(String arg[]){
ConnectionMySQL essai = new ConnectionMySQL();
}
}
Partager