import java.sql.*; import java.util.ArrayList; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; public class Importacion { private String JDBC_driver = "com.mysql.jdbc.Driver"; private String ODBC_driver = "sun.jdbc.odbc.JdbcOdbcDriver"; private String dsn; private String dbURL; private String Usuario; private String Passwd; /* * CONNECT mysql */ synchronized public Connection ConectaMysql(String User, String Pass, String dsn) throws Exception { this.dsn=dsn; this.dbURL="jdbc:mysql://localhost:3306/"+this.dsn+"?useServerPrepStmts=true"; this.Usuario=User; this.Passwd=Pass; Class.forName(JDBC_driver); Connection con = DriverManager.getConnection(dbURL,Usuario,Passwd); return con; //System.out.println("Conectamos a la base. id="+this.toString()); //System.out.println("con="+con.toString()); //con.setReadOnly(true); } /* * DISCONNECT mysql */ synchronized public void DesconectarMysql(Connection con) { if (con!=null) { try { con.close(); //System.out.println("Desconectamos de la base. id="+this.toString()); //System.out.println("con="+con.toString()); } catch (SQLException e) { // TODO Auto-generated catch block //System.out.println("Error al desconectar id="+this.toString()); //System.out.println("con="+con.toString()); e.printStackTrace(); } } } /* * CONNECT OTHER DATABASE (NO MYSQL) */ synchronized public Connection ConectaEloq(String User, String Pass, String dsn) throws Exception { this.dsn=dsn; this.dbURL="jdbc:odbc:"+this.dsn; this.Usuario=User; this.Passwd=Pass; // Carreguem el driver Class.forName(ODBC_driver); // obtenim la connexio Connection con = DriverManager.getConnection(dbURL,Usuario,Passwd); //System.out.println("Conectamos a la base. id="+this.toString()); //System.out.println("con="+con.toString()); con.setReadOnly(true); return con; } /* * DISCONNECT OTHER DATABASE (NO MYSQL) */ synchronized public void DesconectarEloq(Connection con) { if (con!=null) { try { con.close(); //System.out.println("Desconectamos de la base. id="+this.toString()); //System.out.println("con="+con.toString()); } catch (SQLException e) { // TODO Auto-generated catch block //System.out.println("Error al desconectar id="+this.toString()); //System.out.println("con="+con.toString()); e.printStackTrace(); } } } /* * GET DATA OF OTHER DATABASE (NO MYSQL) */ @SuppressWarnings("unchecked") public ArrayList getListElementos (Connection con, int reg_inicial, int n_limite) throws Exception { ArrayList Listado = new ArrayList(); ******************GET DATA OTHER DATABASE (NO MYSQL) AND IT SAVES TO Listado************** return Listado; } /* * Obitene un arraylist con todos los elementos del eloq */ @SuppressWarnings("unchecked") public ArrayList getListElementos (Connection con) throws Exception { ArrayList Listado = new ArrayList(); ******************GET DATA OTHER DATABASE (NO MYSQL) AND IT SAVES TO Listado************** return Listado; } /* * CHANGE ' by ´ */ @SuppressWarnings("unchecked") public ArrayList pasaFiltro(ArrayList Listado) { ArrayList ListadoRes = new ArrayList(); int tam = Listado.size(); for(int i=0;i=1000){ tam = 1000; }else{ tam = n_reg_totales - n_reg_actualizados; } for( int i=0; i" + n_reg_actualizados); Date fecha_fin = (new GregorianCalendar()).getTime(); System.out.println(fecha_fin.toString()); } pstm.close(); im.DesconectarMysql(con); //Date fecha_fin = (new GregorianCalendar()).getTime(); //System.out.println(fecha_fin.toString()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); Date fecha_fin = (new GregorianCalendar()).getTime(); System.out.println(fecha_fin.toString()); } } }