Galera eu tenho uma aplicação de inserção no banco de dados e ela so funciona quando eu estou utilizando o modo de debug, quando mando rodar normal ela roda mas nao inseri no banco … :shock: :shock:
Aqui o codigo[code]import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import br.com.fecomercio.conexao.Conexao_Banco;
import br.com.fecomercio.persistencia.Sindical_Bean;
/*
- Created on May 22, 2006
- TODO To change the template for this generated file go to
- Window - Preferences - Java - Code Style - Code Templates
*/
/**
-
@author felipe
-
TODO To change the template for this generated type comment go to
-
Window - Preferences - Java - Code Style - Code Templates
*/
public class test {public static void validaPagamento(Collection listSindical,Collection listEmpresa) throws SQLException {
PreparedStatement stmt; Conexao_Banco con = new Conexao_Banco(); String sql = ("INSERT INTO cnpj_2 (cnpj) VALUES (?);"); Connection conexaoAcess = con.conectarBancoAcess(); stmt = conexaoAcess.prepareStatement(sql); System.out.println("aki"); //*************************************** Iterator it = listSindical.iterator(); ArrayList array = new ArrayList(); while(it.hasNext()){ String valor = it.next().toString(); if(listEmpresa.contains(valor)){ System.out.println(valor + " existe na lista"); array.add(valor); } } //*************************** System.out.println("de novo"); Iterator it2 = array.iterator(); while (it2.hasNext()) { String ji = (String) it2.next(); stmt.setString(1,ji); stmt.execute();// o debug ta aqui!!!!!!!!!!!!1 } stmt.close(); System.out.println("Fechou conexao");
}
public static void main(String[] args) throws SQLException {
ArrayList sind = new ArrayList(); sind.add("b1"); sind.add("b2"); ArrayList emp = new ArrayList(); emp.add("b1"); emp.add("b2"); emp.add("b3"); emp.add("b4"); validaPagamento(sind, emp);
}
}
[/code]
O banco e sqlserver.
Falow!!!