Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class Database
- {
- Connection connection = null;
- Statement statement = null;
- public Database(String file)
- {
- try
- {
- Class.forName("org.sqlite.JDBC");
- connection = DriverManager.getConnection("jdbc:sqlite:"+file);
- statement = connection.createStatement();
- }
- catch (ClassNotFoundException | SQLException e)
- {
- e.printStackTrace();
- }
- }
- public ResultSet query(String query)
- {
- ResultSet rs = null;
- try
- {
- rs = statement.executeQuery(query);
- }
- catch (SQLException ex)
- {
- Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
- }
- return rs;
- }
- public void execute(String query)
- {
- try
- {
- statement.executeUpdate(query);
- }
- catch (SQLException ex)
- {
- Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment