ola amigos estou com uma tabela no excel e preciso jogar esses dados no bando de dados, ja consegui atraves dos topicos do forum ler a tabela e colocar no banco o q acontece é que a tabela tem 16.743 linhas e so estou conseguindo ler a primeira, alguem tem algo pra ajudar?
Segue abaixo o codigo usado
package principal;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
/**
*
-
@author petter
*/
public class teste2 {private static Connection conn;
/** Creates a new instance of Main */
public static void main(String[] args ) throws IOException, BiffException,
ClassNotFoundException, SQLException {/* pega o arquiivo do Excel */ Workbook workbook = Workbook.getWorkbook(new File("C:\\Users\\Gledison\\Downloads\\eleitores.xls")); /* pega a primeira planilha dentro do arquivo XLS */ Sheet sheet = workbook.getSheet(0); /* pega os valores das célular como se numa matriz */ Cell a1 = sheet.getCell(0,0); Cell b2 = sheet.getCell(1,1); Cell c2 = sheet.getCell(2,1); /* pega os conteúdos das células */ String stringa1 = a1.getContents(); String stringb2 = b2.getContents(); String stringc2 = c2.getContents();
/
String sql = “INSERT INTO MinhaTabela(col1,col2,col3) “+
“VALUES(’”+stringa1+”’,’”+stringb2+"’,"+stringc2+"’)";//<em>Executa o insert para inserir os dados no banco de testes MySQL</em>/ Class.forName(“org.postgresql.Driver”); Connection conn = DriverManager.getConnection(“jdbc:postgresql://localhost/sisvota”,“postgres”,“totalbr”);
PreparedStatement ps =
conn.prepareStatement(“INSERT INTO eleitor(codigo,nome,sessao)“+
“VALUES(’”+stringa1+”’,’”+stringb2+"’,’"+stringc2+"’)");ps.executeUpdate();
ps.close();}
}