/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testeTemplates.conexoes;
import java.sql.*;
import javax.swing.JOptionPane;
/**
*
* @author adm
*/
public class Conexao {
public static String database = "jdbc:postgresql://localhost/testeFramework";
public static String usuario = "postgres";
public static String senha = "masterkey";
public static String driverName="org.postgresql.Driver";
public static Connection conexao;
public static Statement consulta;
public static ResultSet resultado;
public static void criarConexao(){
try{
Class.forName(driverName);
conexao = DriverManager.getConnection(database,usuario,senha);
consulta = conexao.createStatement();
//resultado = consulta.executeQuery("select * from cidades order by estado,cidade");
}catch(Exception e){JOptionPane.showMessageDialog(null, e.getLocalizedMessage());}
}
}
Ouvi falar que a conexão pode ser fechada pelo banco depois de um tempo, então pensei em fazer uma thread separada e nessa Thread a cada 20 minutos eu executaria de novo o metodo criarConexao, essa informação procede? e a minha solução é viavel pra evitar esse problema?