Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package my.boletas;
- import javax.swing.JOptionPane;
- import java.sql.Statement;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- /**
- *
- * @author skypce
- */
- public class baseDatos {
- public Connection conexion=null;
- public Statement st = null;
- /*public baseDatos(String nombreDB) throws ClassNotFoundException, SQLException{
- Class.forName("org.sqlite.JDBC");
- this.conexion = DriverManager.getConnection("jdbc:sqlite:" + nombreDB);
- this.st = this.conexion.createStatement();
- }*/
- public baseDatos(){
- try {
- Class.forName("org.sqlite.JDBC");
- conexion = DriverManager.getConnection("jdbc:sqlite:negocio.sqlite");
- st = conexion.createStatement();
- }catch(Exception e){
- JOptionPane.showMessageDialog(null, "No se encontro el controlador");
- System.exit(1);
- }
- }
- /*try{
- st=conexion.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
- }catch (Exception e){
- JOptionPane.showMessageDialog(null, "Error al crear objeto sentencia");
- }
- }*/
- public synchronized ResultSet ejecutarSelect (String la_sql){
- ResultSet rs=null;
- try {
- rs=st.executeQuery (la_sql);
- }catch (Exception e){
- System.out.print(e);
- }
- return rs;
- }
- public synchronized int ejecutarSql (String la_sql){
- int num_filas=0;
- try {
- num_filas=st.executeUpdate(la_sql);
- }catch (Exception e){
- System.out.print(e);
- }
- return num_filas;
- }
- public synchronized void closedb (){
- try{
- conexion.close();
- //conexion.close();
- }catch (Exception e){
- System.out.print(e);
- }
- }
- }
Add Comment
Please, Sign In to add comment