[RESOLVIDO]Ajuda no insert

4 respostas
snowblacksoul

Pessoal estou com dificuldade em dar um insert no banco Oracle, pegando as informações de um xls.
A estrutura da tabela é a seguinte!


create table rgd.stop_atis_daniel(
cd_cliente number null,
cd_conta number null,
qtde number null,
valor decimal(12,2)
null,
motivo varchar2(50) null,
conta number null,
ciclo number null,
terminal number null)

O código que estou usando para inserir a informação é a seguinte:

public class StopAtis {
    private static int i;
    private static int stringa1 ;
    private static int stringa2 ;
    private static int stringa3 ;
    private static String stringa4 = null;
    private static String stringa5 = null;
    private static int stringa6 ;
    private static int stringa7;
    private static int stringa8;

    /**
     * @param args the command line arguments
     */
	
	public static void main(String []args) throws BiffException, IOException, SQLException{
            
            System.out.println("Conectando ao Banco");
		
		Connection con = new ConnectionFactory().getConnection();
		
                GerarTxt gerarTxt = null;  
                
		Workbook workbook = Workbook.getWorkbook(new File("C:/teste/stop_atisciclo02345.xls"));
		
		Sheet sheet = workbook.getSheet(0);
		
		int linhas = sheet.getRows();
		
		for(i = 1; i < linhas; i++){
			Cell a1 = sheet.getCell(0,i);
			Cell b2 = sheet.getCell(1,i);
			Cell c3 = sheet.getCell(2,i);
			Cell d4 = sheet.getCell(3,i);
			Cell e5 = sheet.getCell(4,i);
			Cell f6 = sheet.getCell(5,i);
			Cell g7 = sheet.getCell(6,i);
			Cell h8 = sheet.getCell(7,i);
                        
				
			stringa1 = Integer.valueOf(a1.getContents());
			stringa2 = Integer.valueOf(b2.getContents());
			stringa3 = Integer.valueOf(c3.getContents());
			stringa4 = d4.getContents();
			stringa5 = e5.getContents();
			stringa6 = Integer.valueOf(f6.getContents());
			stringa7 = Integer.valueOf(g7.getContents());
			stringa8 = Integer.valueOf(h8.getContents());
			
			PreparedStatement st = con.prepareStatement("insert into rgd.stop_atis_daniel(cd_cliente,cd_conta,qtde,valor,motivo,conta,ciclo,terminal)"+"Values('"+stringa1+"','"+stringa2+"','"+stringa3+"','"+stringa4+"','"+stringa5+"','"+stringa6+"','"+stringa7+"','"+stringa8+"')");
                        st.executeUpdate();
                    
		
                        System.out.println("Importando!!!!");
		
		}
               
	}
	
}

e esta dando o seguinte erro!!!

Alguém poderia me ajudar nesse erro!!!
o que posso estar fazendo errado!?

4 Respostas

S

O que tem na linha 70?

snowblacksoul

Bomm pessoal eu ja sei no xls a ultima coluna está em branco, por isso nao consigo importar.
Só consigo fazer a importação colocando “0” zero, agora como fazer isso sem precisar colocar zero!!!?

snowblacksoul

Coseguir importar porém dar um erro enorme, alguem pode me ajudar!!!?

Conectando ao Banco
Exception in thread "main" java.sql.SQLException: ORA-01000: maximum open cursors exceeded

	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
	at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
	at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3657)
	at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)
	at stopatis.StopAtis.main(StopAtis.java:77)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 26 segundos)
snowblacksoul

valeu gente!!! esqueci de fechar o PreparedStatement!!

Criado 11 de novembro de 2011
Ultima resposta 11 de nov. de 2011
Respostas 4
Participantes 2