thank you for any input. I am getting the below error message. I am running JDBC with postgresql and attempting to run 9 queries on my query.txt file that I have. The tables were created and values inserted according to the console message below. However, I am getting exception in the thread main. I am not understanding how to clear this and have my console run successfully and my 1.html file execute my query results. Again thank you all for your help on this. Here is my code for the specific class where I am running my queries.
package dbms.vt;
import java.io.IOException;
import java.sql.*;
import java.util.ArrayList;
public class SQLRunner {
public static boolean execute(Connection connection, String fileURL)
throws SQLException, IOException {
ArrayList<String> tableList = new ArrayList<String>();
Statement stmt = connection.createStatement() ;
try{
tableList = FileIO.readStatementsFromFile(fileURL);
System.out.println(tableList.get(9));
}
catch(IOException ex){
System.out.println("IO Exception from SQLRunner");
}
String testStmt = tableList.get(9);
stmt.executeUpdate(testStmt);
stmt.close();
return true;
}
}
Here is the console results:
SET client_encoding = 'UTF8';
Successfully created all tables.
COMMIT;
Successfully inserted all values.
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 9, Size:
9
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at dbms.vt.SQLRunner.execute(SQLRunner.java:21)
at dbms.vt.MyJDBC.main(MyJDBC.java:27)