I have created a Db(student.db3) with sqlite2009pro encrypted(password) protected.how to connect this to JTable.see the following code
import java.sql.*;
import javax.swing.*;
public class javaconnect {
Connection conn=null;
public static Connection connecrDb(){
try{
Class.forName("org.sqlite.JDBC");
Connection conn=DriverManager.getConnection("jdbc:sqlite:C:\\Users\\ME\\Desktop\\MY PROJECTS\\webcam\\sqlite3\\student.db3");
//JOptionPane.showMessageDialog(null,"Connection Established");C:\Users\ME\Desktop\MY PROJECTS\Bunker Calcultaion Tool
return conn;
}catch ( Exception e){
JOptionPane.showMessageDialog(null, e);
return null;
}
}
}
and i am calling this class like,see the bellow code
public void Update_table() {
try{
conn=javaconnect.connecrDb();
String sql="SELECT * FROM grade";
pst=conn.prepareStatement(sql);
rs=pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
}
catch( Exception e){
JOptionPane.showMessageDialog(null, "problem exists");
}
}