You are on page 1of 2

package pkgModelo;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
*
* @author amartinez
*/
public final class clsConnection implements intConnection{

Connection conn = null;


Statement stmt = null;
ResultSet rs = null;

public clsConnection() {
this.LoadDriver();
}

@Override
public void LoadDriver() {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (Exception e) {
System.out.println("Err Driver: "+e.toString());
}
try {
conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/misiontic?
user=usu&password=admin");
} catch (Exception e) {
System.out.println("Err Connection: "+e.toString());
}

@Override
public ResultSet processSQL(String SQL) {
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(SQL);

if (stmt.execute(SQL)){
rs = stmt.getResultSet();
}

return rs;
} catch (Exception e) {
System.out.println("Err Process SQL: "+e.toString());
}
return rs;
}

@Override
public int processIUDSQL(String SQL){
try {
stmt = conn.createStatement();
return stmt.executeUpdate(SQL);
} catch (Exception e) {
System.out.println("Error processIUDSQL "+e.toString());
}
return 0;
}

@Override
public Connection getConnection() {
return this.conn;
}

You might also like