Shouldn't this be a pretty straightforward operation? However, I there is no size() or length() method.
Inside the if(rs.last()) code block, wouldn't the correct method be rs.beforeFirst() instead of rs.first()? This way, you are not skipping the first record in your result set for processing in the while loop.
KG
2009-01-26 17:04:37
KG - Indeed that looks right at a brief look at the code!
JeeBee
2009-01-27 12:36:39
+13
A:
ResultSet.last()
followed by ResultSet.getRow()
will give you the row count, but it may not be a good idea as it can mean reading the entire table over the network and throwing away the data. Do a SELECT COUNT(*) FROM ...
query instead.
finnw
2008-10-10 16:17:36
For brevity's sake I always reference methods in this fashion when writing about them to others, regardless of whether they are static or not. Actually creating an instance of the object and calling the method is implied.
laz
2008-10-10 18:23:58
A:
For a detailed description of how to connect to SQLServer database from Java, Statement, PreparedStatment, CallableStatement, ResultSet objects etc. check this link: HOW TO: SQL in JAVA.
SNK111
2010-06-16 13:25:57