出错代码如下:
static String u = "user";
static String p = "psw";
static String url = "jdbc:oracle:thin:@localhost:1521:db_name";
con = DriverManager.getConnection(url, u, p);
statement = con.createStatement();
String query1="select * from dm_mpg_test'";
ResultSet re1=statement.executeQuery(query1);
//get the number of the records
re1.last();
System.out.println("ResultSet size:"+re1.getRow());
报错java.sql.SQLException: 对只转发结果集的无效操作: last
需将statement定义成
statement = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
允许结果集可移动。