tenho que fazer a integraçao do ERP (oracle ) pro novo site (SQLServer) via java.
faço um select no oracle e dentro do laço que crio vou dando insert, soh que a cada insert crio uma
nova conexao e acabo derrubando a porta do servidor SQLserver qndo atinjo um numero x de insert, ja analisei e refiz meu codigo milhoes de vezes, se alguem conseguir ajudar agradeço
vou mandar um resumo do codigo:
[code]
//classe que faz o select e monta o laço
public void selecionaDadosUsu_TproSit() throws SQLException{
this.connectionOracle = conexaoOracle.getConnection();
sql = "SELECT codpro, bla bla ";
PreparedStatement stmOracle = this.connectionOracle.prepareStatement(sql);
try {
ResultSet rs = stmOracle.executeQuery(sql);
while(rs.next()){
String codpro = rs.getString("codpro");
testeInclusaoDao inclusao = new testeInclusaoDao();
tbImportProducts tst = new tbImportProducts();
tst.setIdProduct(codpro);
//chamo a classe que insere no SQLserver
inclusao.adicionaTeste(tst);
}
} catch (Exception e){
System.out.print(e.getMessage());
}
}
/// classe que faz a inserçao
public void adicionaTeste(tbImportProducts incluiProduto) throws SQLException{
//System.out.println(connectionMsSql.isClosed());
this.connectionMsSql = conexao.getConnection();
System.out.println(connectionMsSql);
sqlAux = "insert into bla bla bla ";
PreparedStatement stmMsSql = this.connectionMsSql.prepareStatement(sqlAux);
try {
stmMsSql.setString(1, incluiProduto.getIdProduct());
stmMsSql.execute();
connectionMsSql.isClosed();
fechaConexaoMsSql();
} catch (Exception e) {
System.out.print(e.getMessage());
}
}
//minha conexao
public static Connection getConnection() throws SQLException {
try {
// System.out.println("iniciando conexao ao banco!! ");
Class.forName(“com.microsoft.sqlserver.jdbc.SQLServerDriver”);
// System.out.println("Conectando ao banco Teste_junior ");
return DriverManager.getConnection(
“jdbc:sqlserver://localhost:1433;databaseName=TESTE_SITE;selectMethod=cursor;”,
“livrarias”,
“livrarias”);
} catch (ClassNotFoundException e) {
throw new SQLException(e.getMessage());
}
} [/code]