I have a class called JavaConnect
and I have two methods: ConnectDB
and DesconnectDb
.
Connection class:
public class JavaConnect {
Connection conn = null;
public static Connection ConnectDb(){
try{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:/home/leo/NetBeansProjects/Controller_workshop/dbControlworkshop.sqlite");
/*JOptionPane.showMessageDialog(null, "Conexao realizada");*/
return conn;
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
return null;
}
}
public static void DesconnectDb(Connection conn){
try{
if(conn != null) {
conn.close();
}
}catch (SQLException e){
}
}
}
So far I understood more or less the features. But I need to start them inside the JFrame.
Code below to help you understand my error:
public void PreencherTabela(String Sql){
ArrayList dados = new ArrayList();
String [] colunas = new String []{"ID","NOME","RG","CPF","RUA","TELEFONE","NUMERO","BAIRRO","CIDADE","ESTADO","CEP"};
JavaConnect.ConnectDb();
JavaConnect.DesconnectDb(conn);
}
When I call the method DesconnectDb
, the "conn" is wrong and displays the error on the side as follows:
can not find symbol
How to solve this?