1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
/*
* Connexion.java
*
* Created on 18 février 2004, 15:35
*/
/**
*
* @author c-top
*/
import java.sql.*;
public class Connexion {
private Connection con;
private Statement stmt;
/** Creates a new instance of Connexion */
public Connexion() {
String username = "root";
String password = null;
String url = "jdbc:mysql://localhost:3306/biblio";
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try{
con = DriverManager.getConnection(url, username, password);
System.out.println("OK connexion réussie...");
stmt = con.createStatement();
}
catch(SQLException ex){
System.out.println(ex.getMessage());
}
}
public Statement getStmt() {
return stmt;
}
public Connection getCon() {
return con;
}
} |
Partager