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
| public connexion(String classe,String local,String _user,String _password) throws SQLException
{
user = _user.toUpperCase();
pass = _password;
monMetaData = null;
try {
Class.forName(classe);
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
DriverPropertyInfo[] required;
Properties props = new Properties();
Driver driver;
String url = local;
try {
driver =DriverManager.getDriver(url);
} catch (SQLException e) {
e.printStackTrace();
System.err.println("impossible de trouver le pilote");
return;
}
props.put("user",user);
props.put("password",pass );
connect = DriverManager.getConnection(url,props);
monMetaData = connect.getMetaData();
connect.setAutoCommit(false);
st = connect.createStatement();
} |