Are You sure that at least one row is returned?
Maybe You need to use ' like this:
 
PreparedStatement pstmt = con.prepareStatement("SELECT systemid FROM user_pass WHERE username = '?' AND password = '?' ");
 
Hope it helps.
 
Best wishes,
                    Andras.
 
----- Original Message -----
Sent: Wednesday, September 22, 1999 5:42 PM
Subject: ResultSet not giving up data

Firstly, let me show my code snippet:
--------------------------------------------------------------------------------------------------
try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:msoracle", "vahps", "manager");
    stmt = con.createStatement();
    PreparedStatement pstmt = con.prepareStatement("SELECT systemid FROM user_pass WHERE username = ? AND password = ?");
       
    synchronized (pstmt)
    {
      pstmt.clearParameters();
      pstmt.setString(1, name);
      pstmt.setString(2, passwd);
      rs = pstmt.executeQuery();
      while (rs.next()) {
      testvalue = rs.getString("systemid");
      out.println ("System ID: " + testvalue + "<BR>");
      }
    }
  }
  catch (ClassNotFoundException e) {
      out.println ("Cannot connect to db<BR>");
      out.println (e.getMessage() + "<BR>");
  }
  catch (SQLException e) {
    out.println ("SQLException caught: " + e.getMessage());
  }
--------------------------------------------------------------------------------------------------------------
 
The line in bold should display the variable 'testvalue', even if it's just one row of data returned. And, as you may have guessed it's not working........ Can anyone tell me what I can do to fix this. I am connecting to an Oracle DB using the jdbc-odbc driver from Microsuck. Which I think is the culprit....... What do you think?
 
Antonio

Reply via email to