I got a little problem with running my batch process..
First of all, I'm still at learning JDBC etc. so please excuse me, if my mistake is really stupid..
I have to insert some SQL queries into my database. Therefore, I'm building my PreparedStatements like this:
String add = "INSERT INTO company_type VALUES (?,?)";
PreparedStatement company = write.getConnection().prepareStatement(add);
ResultSet com = types.getCompanyType();
while(com.next()) {
System.out.print("1");
company.setInt(1, com.getInt(1));
company.setString(2, com.getString(2));
company.addBatch();
if(i > size) {
company.executeBatch();
i = 0;
}
i++;
}
company.executeBatch();
After going through with the debugger, I know something went wrong with the company.executeBatch();
line.
It just didn't execute and it seems like the program i running into a loop or standing still.
Is there anybody, how can see a mistake?
Thanks
P.s. I did not get any Exception.
public Connection getConnection(){
Connection connection = null;
try{
Class.forName( "oracle.jdbc.driver.OracleDriver" );
} catch(ClassNotFoundException e) {
this.loginmessage.setText("Fehler beim Laden des Oracle JDBC Treibers!");
e.printStackTrace();
return connection;
}
try {
connection = DriverManager.getConnection("j******************);
} catch (SQLException e) {
this.loginmessage.setText("Verbindung fehlgeschlagen!");
e.printStackTrace();
return connection;
}
if (connection != null) {
loginmessage.setText("Verbindung hergestellt!");
return connection;
} else {
loginmessage.setText("Verbindung fehlgeschlagen!");
System.out.print("huaha");
}
return connection;
}