Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class TBLogs{
- public Connection connection;
- public TBLogs(){
- this.connecton = DBConnection.getConnection();
- }
- public void initTB() {
- try {
- // Remove e cria a tabela a cada execuรงรฃo. Mero exemplo
- Statement stm = this.connection.createStatement();
- stm.executeUpdate("DROP TABLE IF EXISTS logs");
- stm.executeUpdate("CREATE TABLE logs ("
- + "id INTEGER PRIMARY KEY AUTOINCREMENT,"
- + "operation TEXT NOT NULL,"
- + "timestamp BLOB NOT NULL,"
- + "details TEXT);");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public void insert() {
- try {
- Statement stm = this.connection.createStatement();
- String sql = "INSERT INTO logs(operation,timestamp,details) VALUES ('teste', 1,'teste2');";
- stm.executeUpdate(sql);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement