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
| public void reconnect() throws SQLException, ClassNotFoundException
{
setConnected(false);
Class.forName(driver);
connexion = DriverManager.getConnection(url, user, passwd);
setConnected(true);
}
SQLAbstractLayer(String confFile)
{
try
{
IniFile IF = new IniFile("conf" + System.getProperty("file.separator") + confFile);
driver = IF.getStrVar("driver");
url = IF.getStrVar("address") + "/" + IF.getStrVar("base");
user = IF.getStrVar("user");
passwd = IF.getStrVar("password");
if(!isConnected())
{
try
{
reconnect();
} catch (Exception e)
{
e.printStackTrace();
}
}
System.out.print("[NOTICE] Connecté à la base de donnée\n");
} catch(IOException e)
{
System.err.print("[WARNING] Le fichier 'conf" + System.getProperty("file.separator") + "db.conf'" +
" ne peu etre lue.\n Assurez-vous qu'il existe et que son format est bon\n");
System.err.print("[ERROR] Erreur: \n");
e.printStackTrace();
}
} |
Partager