我有一个文本文件,我从中读取值
FileInputStream file = new FileInputStream("C:/workspace/table_export.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(file));
String line = null;
while( (line = br.readLine())!= null )
{
String [] tokens = line.split("\\s+");
String var_1 = tokens[0];
System.out.println(var_1);
getstaffinfo(var_1,connection);
}
从文本文件中读取的值被传递给getstaffinfo 方法来查询数据库
public static String getstaffinfo(String var_1, Connection connection) throws SQLException, Exception
// Create a statement
{
StringBuffer query = new StringBuffer();
ResultSet rs = null;
String record = null;
Statement stmt = connection.createStatement();
query.delete(0, query.length());
query.append("select firstname, middlename, lastname from users where employeeid = '"+var_1+"'");
rs = stmt.executeQuery(query.toString());
while(rs.next())
{
record = rs.getString(1) + " " +
rs.getString(2) + " " +
rs.getString(3);
System.out.println(record);
}
return record;
}
我从传递给getstaffinfo方法的文本文件中读取了近14000个值,所有数据库活动都具有加载驱动程序,建立连接都可以正常工作。但是在打印的时候
它抛出错误
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01000: maximum open cursors exceeded
ORA-01000: maximum open cursors exceeded
尽管我知道此错误与数据库配置有关,但是否有一种有效的方法可以进行一次数据库调用并执行从文本文件中读取的多个值的查询。任何输入都会很有用。
提前谢谢了!!