简体   繁体   中英

ResultSet.next() returns false

In DB2 I execute a select statement and get the ResultSet as below

PreparedStatement ps;
ps = connection.prepareStatement("myQuery");
ps.setString(1, "data");
ps.execute();
ResultSet rs;
rs = ps.getResultSet();

For some reason, I get rs.next() as false sometimes which means it returns 0 rows, whereas if I execute the same query on the database I get 2 rows. I I'd appreciate any help.

try this:

PreparedStatement ps;
ps = connection.prepareStatement("myQuery");
ps.setString(1, "data");
ResultSet rs=ps.executeQuery();
;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM