I need to insert an ArrayList into Oracle XE. Here's what I am sweating on:
ArrayList <Double> array = new ArrayList<Double>();
array.add(10.2);
array.add(11.2);
array.add(12.2);
array.add(1.2);
array.add(10.2);
array.add(10.2);
array.add(10.2);
Connection dbConnection = null;
Statement statement = null;
ResultSet rows = null;
Iterator<Double> it=array.iterator();
String insertTableSQL = "INSERT INTO RVALUES VALUES(";
for(int i=0;i<array.size();){
it.next();
i++;
}
insertTableSQL +=")";
String selectTableSQL = "Select * from RVALUES";
try {
dbConnection = getDBConnection();
statement = dbConnection.createStatement();
System.out.println(insertTableSQL);
rows = statement.executeQuery(selectTableSQL);
while(rows.next()){
System.out.print(rows.getInt(1)+"\t");
System.out.println(rows.getInt(2));
}
statement.executeUpdate(insertTableSQL);
System.out.println("Record is inserted into DBUSER table!");
It says "ORA-00936: missing expression". I am re-doing this so long...that I am lost. Any help on this one will be very appreciated.
Don't do it this way.
Create a PreparedStatement and make a Batch-Update.
This will be faster and more secure.