I have try to connect SQLite database to jtable using java swing.
import java.sql.*;
public class Database {
public static void main(String[] args) throws Exception {
// Get the path to the encrypted database file.
String databaseFile = "DataBase/demo.db?cipher=SQLiteCipher&password=demo&key=demo";
// Create a connection to the encrypted database file.
Connection connection = DriverManager.getConnection("jdbc:sqlite:" + databaseFile);
System.out.println("Connected");
// Create a statement object and use it to execute queries against the database.
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM demo");
// Iterate over the results and print them to the console.
while (resultSet.next()) {
System.out.println(resultSet.getString("ItemName"));
}
// Close all of the open resources.
resultSet.close();
statement.close();
connection.close();
}
}
I want to connect the sqlite3 database to jtable.