I can't connect to my data base while I run my .jar,but I can do it if I run my project in NetBeans. I'm using the JDBC-ODBC Bridge for the connection. Here's the function I use for the connection.
public Statement connection(Statement st){
try {
// connection avec la base de donnée DataBase.
// On charge le driver ODBC
Properties props = new Properties();
// pour pouvoir afficher les accents et les caractères spéciaux!!
props.put ("charSet", "ISO-8859-15");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cnx = DriverManager.getConnection("jdbc:odbc:DataBase", props);
st=cnx.createStatement();
//JOptionPane.showMessageDialog(null,"connection ouverte avec succès");
}catch(Exception e)
{
System.out.println(e.getLocalizedMessage());
return st;
}
return st;
}
Sample Image: