Currently I have the below code, where I am trying to cast from Object to String and I get an exception error.
What is the best way to convert from this Object array to String array so that it will work in my for loop? Or is there a way to alter my for loop to display the Object array?
<%
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:/Users/rhysparker/Documents/workspace/Resource_Planner/WebContent/db/RESOURCE.SQLITE");
Statement stat = conn.createStatement();
ArrayList<ArrayList<String>> al = new ArrayList<ArrayList<String>>();
ResultSet rs = stat.executeQuery("select project_name from project;");
ResultSetMetaData metaData = rs.getMetaData();
int columns = metaData.getColumnCount();
while (rs.next()) {
ArrayList<String> record = new ArrayList<String>();
for (int i = 1; i <= columns; i++) {
String value = rs.getString(i);
record.add(value);
}
al.add(record);
}
String[] testing = (String[])al.toArray();
for(int i=0;i<testing.length;i++)
{ %>
<option value="<%=testing[i]%>"><%=testing[i]%></option><%
}
rs.close();
conn.close();
%>