My application uses a Mysql connection, which is obtained using this code:
public static void Connect(){
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = "jdbc:mysql://" + host + ":" + port + "/"+ db;
ct = DriverManager.getConnection(url, user, pass);
st = ct.createStatement();
System.out.println("Csatlakozva....n");
}
catch (InstantiationException e)
{
Main.textArea.setText("Error : Instantiation!");
//System.err.println("Error : Instantiation");
e.printStackTrace();
}
catch (IllegalAccessException e)
{
Main.textArea.setText("Error : Illegális Behatolás!");
//System.err.println("Error : Illegális Behatolás!");
e.printStackTrace();
}
catch (ClassNotFoundException e)
{
Main.textArea.setText("Error : Class Nem Található!");
//System.err.println("Error : Class Nem Található!");
e.printStackTrace();
}
catch (SQLException e)
{
Main.textArea.setText("Error : Adatbázis Nem Található!");
//System.err.println("Error : Adatbázis Nem Található!");
e.printStackTrace();
}
}
If the MySQL database server is not running and therefore my app cannot open a connection, how do I make my app wait until a connection can be established?
Aucun commentaire:
Enregistrer un commentaire