Vote count:
0
I have a program that will count the number of records from a variety of data sources. I have the database names and table names stored in array lists called database_names and table_names respectively. I am unable to get this to run:
for (int i = 0; i < table_names.size(); i++) {
String query = "select count(1) from ?.?";
PreparedStatement stmt = connection.prepareStatement(query);
stmt.setString(1, database_names.get(i));
stmt.setString(2, table_names.get(i));
ResultSet rs = stmt.executeQuery();
}
I get an ORA-00903: invalid table name error. I have set print statements to ensure that my database_names.get(i) and table_names.get(i) were printing out the right values. They were, and if I hardcode the database name and table name into my query string, the program is able to count the records.
asked 26 secs ago
PreparedStatement for select count
Aucun commentaire:
Enregistrer un commentaire