jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes help whit ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "help whit ResultSet" Watch "help whit ResultSet" New topic

help whit ResultSet

Hugo de la Mora

Joined: Jun 29, 2002
Posts: 14
Hi, I need help for the next methods (first(),last(),absolute())because dont work and send me this error in
import java.sql.*;
public class Query {
public static void main(String[] args) {
try {
catch (Exception e) {
System.err.println("Driver Error...");
try {
String cadCon="jdbc:mysql://";
Connection conexion = DriverManager.getConnection(cadCon,"xx ","xx");
Statement sentencia = conexion.createStatement();
String consulta="SELECT * FROM bajas";
ResultSet srs = sentencia.executeQuery(consulta);
srs.absolute(4); //here send me Error
int rowNum = srs.getRow(); // rowNum should be 4
int rowNum2 = srs.getRow(); // rowNum should be 1
int rowNum3 = srs.getRow(); // rowNum should be 3
System.out.println("one "+rowNum+"two"+rowNum2+"three"+rowNum3);
and then i got the error
at Consulta.main(Consulta.java:26)
Exception in thread "main"
the method srs.next() work it, so I dont know what I have to do? thank for your help.
Juanjo Bazan
Ranch Hand

Joined: Feb 04, 2002
Posts: 231
The MySQL's ResultSet class do not has implemented the first(), last() & absolute() methods.
Every database vendor implements its own class from the ResultSet interface, so sometimes you dont have all the methods available.
Take a look at the documentation included with the database you chose.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Check you are using the most recent version of the mm.MySQL drivers. I was pretty sure those methods had been implemented
Hugo de la Mora

Joined: Jun 29, 2002
Posts: 14
Thanks, I downloaded the new driver and then work it, I really apreciate it, thanks.
I agree. Here's the link: http://aspose.com/file-tools
subject: help whit ResultSet
It's not a secret anymore!