Maybe your first retrieved row is empty, try to access other rows in
your table. Return the whole rowset in a String-Array and look at the
results.
Winfried Klum
"Campbell, Sean" schrieb:
>
> I have a Servlet / JDBC question.
> I have a servlet that needs to retrieve data from an Oracle database using
> Oracle version 8. I have debugged through and confirmed that I'm making the
> connection - my problem is that when I try and retrieve records, I
> consistently get an empty recordset, although I can confirm that the
> recordset structure being returned is the correct structure of the table I'm
> querying. ( i.e. I query a 'Users' table, and when I create a
> ResultSetMetaData object 'rsm' from the ResultSet 'rs' object and use the
> rsm.getColumnName() method, I get the correct column names. I'm just not
> sure why I'm not getting any data back.
> I've inserted my test function below - any help would be greatly
> apprectiated.
>
> Connection con = null;
>
> // this is the constructor of the class my servlet is
> calling
> public Data()
> {
> try{
> DriverManager.registerDriver(new
> oracle.jdbc.driver.OracleDriver() );
> con =
> DriverManager.getConnection("jdbc:oracle:thin:@ccdev:1521:ccct", "ccc",
> "ccc");
> //log.logError("got here", "Constructor", "");
> System.out.println("got here");
>
> System.out.println(testFunc());
> }
> catch(SQLException sqlErr)
> {
> //log.logError("Data Class", "Constructor",
> sqlErr.getMessage());
> System.out.println("error occurred");
> }
>
> // point class Data's ErrorLog object to the passed
> object reference
> //this.log = passedLog;
> }
>
> // the test function to test data retrieval
>
> public String testFunc()
> {
> Statement stmt ;
> ResultSet rs ;
> String returnValue = "no records returned";
>
> try
> {
> stmt = con.createStatement();
> rs = stmt.executeQuery("select * from USERS");
>
> ResultSetMetaData rsm = rs.getMetaData();
> System.out.println(rsm.getColumnName(1) +' ' +
> rsm.getColumnName(2) +' '+ rsm.getColumnName(3));
>
> if (rs.next()) {
> returnValue = rs.getString("password");
> }
>
> stmt.close();
> con.close();
> }
> catch(SQLException sqlErr)
> {
> System.out.println("sql error");
> System.out.println(sqlErr.getMessage());
> //log.logError("Data Class", "validateUser",
> sqlErr.getMessage());
> }
> return returnValue;
> }
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html