Result Set returned iteration.Please advise

I am invoking a Stored Function from my Java code that returns back
a result set.
I have put a break point on my code.
The value of the rs = OracleResultSetImpl(id=59)
and when the cursor reaches while(rs.next()),it does not go in this loop
and exits out.
Does this mean that there are no records returned back ?
But then the rs should be null instead of showing :OracleResultSetImpl(id=59)
public synchronized ResultSet getAcctChgData(String OrderNo) throws SQLException {
           CallableStatement loadAcctChgStatement=null;
         ResultSet rs=null;
         try
              loadAcctChgStatement = con.prepareCall("{call ? := SF_ACCOUNTCHG(?)}"); //This is oracle function
              loadAcctChgStatement.registerOutParameter(1,OracleTypes.CURSOR);
              loadAcctChgStatement.setString(2,OrderNo);
              loadAcctChgStatement.execute();
              rs = (ResultSet)loadAcctChgStatement.getObject(1);
              while(rs.next()){
                   String f_OrderID  = rs.getString("FixOrderID");
                   String f_EffTs    = rs.getString("EffTs");
                   String f_ClrAcct  = rs.getString("ClrAcct");     
         }catch (SQLException e){
          logger.error("No record found for Order No " + OrderNo);
         return rs;
     }

Yes, and I'm suprised you don't get a classCastException, actually. I'd've expected you to get a return code through the output parameter.

Similar Messages

  • New iPad 5 pixels getting stuck (Rewind, Play, Fast Forward) when using apple tv. Leave ghost buttons on screen. Do I return? Please advise.

    New iPad 5 pixels getting stuck (Rewind, Play, Fast Forward) when using apple tv. Leave ghost buttons on screen. Do I return? Please advise.

    edit: iPad 4

  • Iphone 5 app store search gives blank result all the time, please advise how to solve?

    iphone 5 search in app store always gives blank result all the time, please advise how to solve? It worked several times when I first used the phone from unboxed, but since then, it never work again. Could you please advise how to fix? Thanks

    Try reseting (not just turning off) your phone: hold down the Home button and the Power button on the top until the Silver Apple appears (ignore the red slider if it appears). See if the reset clears things up!
    Cheers,
    GB

  • Trying to make a payment with paypal and the page opens in German. Can't make a payment if I can't read the language. Browser is set correctly. Please advise

    Trying to make a payment on a website and the whole page is in German. Browser setting is English. Can't imagine why this would happen. Please advise...time sensitive.

    Clear the cache and the cookies from websites that cause problems.
    "Clear the Cache":
    *Firefox > Preferences > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Firefox > Preferences > Privacy > Cookies: "Show Cookies"

  • Character Set issues.  Please advise

    I have a client who use a version 10gR2 DB that stores both English and French data. There are several times where they will send up .dmp file where we load it into ours.
    2 questions.
    What would be the best charater sets to use here in this setup?
    I am assuming we would use
    NLS_CHARACTERSET = WE8ISO9959P1
    NLS_NCHAR_CHARACTERSET = AL16UTF16
    Also if someone can confirm for me.
    NLS_CHARACTERSET = database character set ???
    NLS_NCHAR_CHARACTERSET = national character set???

    So is it better to say that I should use the AL32UTF8
    instead of AL16UTF16 ?It's not an instead of situation. AL32UTF8 is a valid setting for the database character set, which controls CHAR and VARCHAR2 columns. AL16UTF16 is a valid setting for the national character set which controls NCHAR and NVARCHAR2 columns.
    Could you tell me the difference?The difference between the two encodings comes down to how many bytes are required to store a particular code point (character). AL32UTF8 is a variable-length character set, so 1 character will require between 1 and 3 bytes of storage (4 for the supplemental characters but those are rather rare). AL16UTF16 is a fixed-width character set, so 1 character will require 2 bytes of storage (4 for the rare supplemental characters again).
    Also could you tell me the difference between
    WE8ISO8859P15 and WE8ISO8859P1 ? There's a Wikipedia article that discusses the differences and has links to the two different code tables.
    Werner's point is an excellent one as well. I was assuming that we were talking about how to set up both sides of this proposed system. If the source system already exists, there are additional considerations like ensuring that your target system supports a superset of the characters supported by the source system. Regardless, when doing imports & exports, as Werner points out, you need to ensure that NLS_LANG is set appropriately.
    Justin

  • My emails delete randomly unrelated to set up. Please advise

    My emails delete randomly and disappear regardless of the set up which is 50 messages and ask before delete. What is the problem? 

    Add an email account on your iPhone, iPad, or iPod touch - Apple Support

  • Sorting the result set return by EXTRACT for  XMLTYPE

    What is the best way to order the output return by extract?
        My SELECT statement:
         SELECT
                regexp_replace(regexp_replace(extract(xmltype(t.message_xml), '//Event'),'<Event>',''),'</Event>',',')
                FROM SUB_XML T
                Current output: EVT_B3_TRAN,EVT_B3_PROD,EVT_B3_FX,EVT_B3_ACC,EVT_B3_PRICE
                Required output: EVT_B3_ACC,EVT_B3_FX,EVT_B3_PROD,EVT_B3_PRICE, EVT_B3_TRAN

    Please post your example data so that people can help you.
    You would be better to extract the contents of the XML using the XMLTABLE functionality, rather than an extract with regexp_replace string functions.  Treat the XML as XML, not as strings.
    Example:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select xmltype('<XML>
      2    <Event>EVT_B3_TRAN</Event>
      3    <Event>EVT_B3_PROD</Event>
      4    <Event>EVT_B3_FX</Event>
      5    <Event>EVT_B3_ACC</Event>
      6    <Event>EVT_B3_PRICE</Event>
      7  </XML>') as xml from dual)
      8  --
      9  -- end of example XML
    10  --
    11  select listagg(event,',') within group (order by rn) as events
    12  from (
    13        select x.event
    14              ,row_number() over (order by x.event) as rn
    15        from   t
    16              ,xmltable('/XML/Event'
    17                        passing t.xml
    18                        columns event varchar2(20) path '.'
    19                       ) x
    20*      )
    SQL> /
    EVENTS
    EVT_B3_ACC,EVT_B3_FX,EVT_B3_PRICE,EVT_B3_PROD,EVT_B3_TRAN

  • Callable Statatement returning multiple Result Sets

    Hello all,
    I've got a stored procedure that will be returning multiple result sets and i was wondering if someone could show me how to pull the multiple result sets out of the CallableStatement object. Any help would be greatly appreciated.

    Here is a sample that does what you want. You will have to substitute the call to DBConn.getConnection() with your own DB connection. Also remove the import of com.ovotron.util.*.import com.ovotron.util.*;
    import java.sql.*;
    public class MultiSQL {
        private static Connection conn = null;
        public static void main(String[] args) {
            // Just gets a connection to the DB.
            conn = DBConn.getConnection();
            getResults(conn);
        * Cycles through multiple result sets returned from a stored procedure.
        * Only the first column is output.
        * <p>
        private static void getResults(Connection conn) {
            // Not sure which DBMS you are using. This is the syntax for
            // SQLServer V7.0.
            String            sql     = "{call getMultiResults}";
            CallableStatement stmt    = null;
            ResultSet         rs      = null;
            int               setNo   = 0;
            try {
                stmt = conn.prepareCall(sql);
                boolean found = stmt.execute();
                while (found) {
                    setNo++;
                    rs = stmt.getResultSet();
                    while (rs.next()) {
                        System.out.println("Result set " + setNo +
                                           ": value: " + rs.getString(1));
                        System.out.flush();
                    rs.close();
                    found = stmt.getMoreResults();
            catch (SQLException e) {
                e.printStackTrace();
            finally {
                try {
                    if (rs   != null) rs.close();
                    if (stmt != null) stmt.close();
                catch (SQLException e) {
                    // Tried already to clean up.
    }The procedure I used is:CREATE PROCEDURE [getMultiResults] AS
    select  col1 from tab1;
    select col2 from tab1;
    select col3 from tab1;Of course you will need to create and populate tab1.

  • SAP Note: 1127156 Result set is too large

    Hi,
    The note 1127156 explains how to resolve the issue with removing the message "Result Set is too large." I want to check the settings in the template and it gives the following steps but i cannot find the settings on the Analysis web item of the data provider.
    Can someone pls help.
    Query View
    The following steps describe how to change the "safety belt" for Query Views:
    1. Use the context menu Properties / Data Provider in a BEx Web Application to maintain the "safety belt" for a Query View.
    2. Choose the register "Size Restriction for Result Sets".
    3. Choose an entry from the dropdown box to specify the maximum number of cells for the result set.
                   The following values are available:
         Maximum Number
         Default Number
         Custom-Defined Number
                   Behind "Maximum Number" and "Default Number" you can find the current numbers defined in the customizing table RSADMIN (see below).
    4. Save the Query View and use it in another Web Template.
    Many thanks

    Hi,
    I was facing the same issue in BEx analyzer 7.0. The query was working fine in BW 3.5 analyzer but gave error in BEx 7.0.
    When executed in web, it gave error result set is too large.
    The maximum no of cells that can be displayed is 750000.
    Please check the result set returned by the query. Also check note Note 1040454 - Front-end memory requirement of the BEx Analyzer.
    Some enhancement are planned to be delivered in enhancement package 1.
    Regards,
      Niraj

  • Result Set Causing out of memory issue

    Hi,
    I am having trouble to fix the memory issue caused by result set.I am using jdk 1.5 and sql server 2000 as the backend. When I try to execute a statement the result set returns minimum of 400,000 records and I have to go through each and every record one by one and put some business logic and update the rows and after updating around 1000 rows my application is going out of memory. Here is the original code:
    Statement stmt = con.createStatement();
    ResultSet   rs = st.executeQuery("Select * from  database tablename where field= 'done'");
                while(rs!=null && rs.next()){
                System.out.println("doing some logic here");
    rs.close();
    st.close();
    I am planning to fix the code in this way:
    Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
                          ResultSet.CONCUR_UPDATABLE);
    stmt.setFetchSize(50);
    ResultSet   rs = st.executeQuery("Select * from  database tablename where field= 'done'");
                while(rs!=null && rs.next()){
                System.out.println("doing some logic here");
    rs.close();
    st.close();But one of my colleague told me that setFetchSize() method does not work with sql server 2000 driver.
    So Please suggest me how to fix this issue. I am sure there will be a way to do this but I am just not aware of it.
    Thanks for your help in advance.

    Here is the full-fledged code.There is Team Connect and Top Link Api being used. The code is already been developed and its working for 2-3 hours and then it fails.I just have to fix the memory issue. Please suggest me something:
    Statement stmt = con.createStatement();
    ResultSet   rs = st.executeQuery("Select * from  database tablename where field= 'done'");
                while(rs!=null && rs.next()){
                 /where vo is the value object obtained from the rs row by row     
                if (updateInfo(vo, user)){
                               logger.info("updated : "+ rs.getString("number_string"));
                               projCount++;
    rs.close();
    st.close();
    private boolean updateInfo(CostCenter vo, YNUser tcUser) {
              boolean updated;
              UnitOfWork unitOfWork;
              updated = false;
              unitOfWork = null;
              List projList_m = null;
              try {
                   logger.info("Before vo.getId() HERE i AM" + vo.getId());
                   unitOfWork = FNClientSessionManager.acquireUnitOfWork(tcUser);
                   ExpressionBuilder expressionBuilder = new ExpressionBuilder();
                   Expression ex1 = expressionBuilder.get("application")
                             .get("projObjectDefinition").get("uniqueCode").equal(
                                       "TABLE-NAME");
                   Expression ex2 = expressionBuilder.get("primaryKey")
                             .equal(vo.getPrimaryKey());// primaryKey;
                   Expression finalExpression = ex1.and(ex2);
                   ReadAllQuery projectQuery = new ReadAllQuery(FQUtility
                             .classForEntityName("EntryTable"), finalExpression);
                   List projList = (List) unitOfWork.executeQuery(projectQuery);
                   logger.info("list value1" + projList.size());
                   TNProject project_hist = (TNProject) projList.get(0); // primary key
                   // value
                   logger.info("vo.getId1()" + vo.getId());
                   BNDetail detail = project_hist.getDetailForKey("TABLE-NAME");
                   project_hist.setNumberString(project_hist.getNumberString());
                   project_hist.setName(project_hist.getName());
                   String strNumberString = project_hist.getNumberString();
                   TNHistory history = FNHistFactory.createHistory(project_hist,
                             "Proj Update");
                   history.addDetail("HIST_TABLE-NAME");
                   history.setDefaultCategory("HIST_TABLE-NAME");
                   BNDetail histDetail = history.getDetailForKey("HIST_TABLE-NAME");
                   String strName = project_hist.getName();
                   unitOfWork.registerNewObject(histDetail);
                   setDetailCCGSHistFields(strNumberString, strName, detail,
                             histDetail);
                   logger.info("No Issue");
                   TNProject project = (TNProject) projList.get(0);
                   project.setName(vo.getName());
                   logger.info("vo.getName()" + vo.getName());
                   project.setNumberString(vo.getId());
                   BNDetail detailObj = project.getDetailForKey("TABLE-NAME"); // required
                   setDetailFields(vo, detailObj);//this method gets the value from vo and sets in the detail_up object
                   FNClientSessionManager.commit(unitOfWork);
                   updated = true;
                   unitOfWork.release();
              } catch (Exception e) {
                   logger.warn("update: caused exception, "
                             + e.getMessage());
                   unitOfWork.release();
              return updated;
         }Now I have tried to change little bit in the code. And I added the following lines:
                        updated = true;
                     FNClientSessionManager.release(unitOfWork);
                     project_hist=null;
                     detail=null;
                     history=null;
                     project=null;
                     detailObj=null;
                        unitOfWork.release();
                        unitOfWork=null;
                     expressionBuilder=null;
                     ex1=null;
                     ex2=null;
                     finalExpression=null;
    and also I added the code to request the Garbage collector after every 5th update:
    if (updateInfo(vo, user)){
                               logger.info("project update : "+ rs.getString("number_string"));
                               projCount++;
                               //call garbage collector every 5th record update
                               if(projCount%5==0){
                                    System.gc();
                                    logger.debug("Called Garbage Collectory on "+projCount+"th update");
                          }But now the code wont even update the single record. So please look into the code and suggest me something so that I can stop banging my head against the wall.

  • Random result set from cursor

    Hello all,
    I have a cursor defined that simply performs a SELECT. I would like to be able to dynamically state whether I'd like the entire result set returned or a random selection.
    The issue I'm having is that because the cursor is already defined I am trying to build this functionality into the LOOP. I am able to return random sets by using DBMS_RANDOM but I've only been able to do this when modifying the SELECT statement. I have considered an ORDER BY in the cursor and then simply EXIT'ing when the ROWNUM meets a certain number of returned results. This would, at least, provide the ability to return a user specified number of random records. Perhaps the ORDER BY could be modified by a cursor parameter?
    I'm hoping there's an elegant solution that I'm missing.
    Thanks for any help!
    Mark

    user10368702 wrote:
    Thanks for pointing out this feature to me. The problem is that my cursors are currently doing multi-table joins and the SAMPLE clause will not work with them. To clarify, I would like to programatically decide whether I'd like to return all the rows from the cursor, or just a sampling. The current method being used it to generate a random number and loop through the entire cursor until that rownum is found. I dislike the table walk, but am unable to come up with a way to return a specific sample size or record num. Ideally I'd like to be able to perform the equivalent of ROWNUM = X with the results from the cursor.
    Thanks for any help!Probably you can't use dynamic SQL (using OPEN or EXECUTE IMMEDIATE) for a particular reason? Because in that case you could just use your query as an inline view like that:
    SELECT * FROM (
    <YOUR_QUERY_INCLUDING DBMS_RANDOM_VALUE>
    WHERE <RANDOM_VALUE> <= <YOUR_LIMIT>and construct your query dynamically.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/
    Edited by: Randolf Geist on Sep 29, 2008 11:21 PM
    Removed unnecessary ORDER BY

  • Why to need close the result set and statement

    why to need close the result set and statement

    It's best to explicitly close every ResultSet, Statement, and Connection in the narrowest scope possible.
    These should be closed in a finally block.
    Since each close() method throws SQLException, each one should be in an individual try/catch block to ensure that a failure to close one won't ruin the chances for all the others.
    You can capture this in one nice utility class, like this:
    package db;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.Map;
    import java.util.LinkedHashMap;
    import java.util.List;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    * Created by IntelliJ IDEA.
    * User: MD87020
    * Date: Feb 16, 2005
    * Time: 8:42:19 PM
    * To change this template use File | Settings | File Templates.
    public class DatabaseUtils
         * Logger for DatabaseUtils
        private static final Log logger = LogFactory.getLog(DatabaseUtils.class);
        /** Private default ctor to prevent subclassing and instantiation */
        private DatabaseUtils() {}
         * Close a connection
         * @param connection to close
        public static void close(Connection connection)
            try
                if ((connection != null) && !connection.isClosed())
                    connection.close();
            catch (SQLException e)
                logger.error("Could not close connection", e);
         * Close a statement
         * @param statement to close
        public static void close(Statement statement)
            try
                if (statement != null)
                    statement.close();
            catch (SQLException e)
                logger.error("Could not close statement", e);
         * Close a result set
         * @param rs to close
        public static void close(ResultSet rs)
            try
                if (rs != null)
                    rs.close();
            catch (SQLException e)
                logger.error("Could not close result set", e);
         * Close both a connection and statement
         * @param connection to close
         * @param statement to close
        public static void close(Connection connection, Statement statement)
            close(statement);
            close(connection);
         * Close a connection, statement, and result set
         * @param connection to close
         * @param statement to close
         * @param rs to close
        public static void close(Connection connection,
                                 Statement statement,
                                 ResultSet rs)
            close(rs);
            close(statement);
            close(connection);
         * Helper method that maps a ResultSet into a map of columns
         * @param rs ResultSet
         * @return map of lists, one per column, with column name as the key
         * @throws SQLException if the connection fails
        public static final Map toMap(ResultSet rs) throws SQLException
            List wantedColumnNames = getColumnNames(rs);
            return toMap(rs, wantedColumnNames);
         * Helper method that maps a ResultSet into a map of column lists
         * @param rs ResultSet
         * @param wantedColumnNames of columns names to include in the result map
         * @return map of lists, one per column, with column name as the key
         * @throws SQLException if the connection fails
        public static final Map toMap(ResultSet rs, List wantedColumnNames)
            throws SQLException
            // Set up the map of columns
            int numWantedColumns    = wantedColumnNames.size();
            Map columns             = new LinkedHashMap(numWantedColumns);
            for (int i = 0; i < numWantedColumns; ++i)
                List columnValues   = new ArrayList();
                columns.put(wantedColumnNames.get(i), columnValues);
            while (rs.next())
                for (int i = 0; i < numWantedColumns; ++i)
                    String columnName   = (String)wantedColumnNames.get(i);
                    Object value        = rs.getObject(columnName);
                    List columnValues   = (List)columns.get(columnName);
                    columnValues.add(value);
                    columns.put(columnName, columnValues);
            return columns;
         * Helper method that converts a ResultSet into a list of maps, one per row
         * @param rs ResultSet
         * @return list of maps, one per row, with column name as the key
         * @throws SQLException if the connection fails
        public static final List toList(ResultSet rs) throws SQLException
            List wantedColumnNames  = getColumnNames(rs);
            return toList(rs, wantedColumnNames);
         * Helper method that maps a ResultSet into a list of maps, one per row
         * @param rs ResultSet
         * @param wantedColumnNames of columns names to include in the result map
         * @return list of maps, one per column row, with column names as keys
         * @throws SQLException if the connection fails
        public static final List toList(ResultSet rs, List wantedColumnNames)
            throws SQLException
            List rows = new ArrayList();
            int numWantedColumns = wantedColumnNames.size();
            while (rs.next())
                Map row = new LinkedHashMap();
                for (int i = 0; i < numWantedColumns; ++i)
                    String columnName   = (String)wantedColumnNames.get(i);
                    Object value = rs.getObject(columnName);
                    row.put(columnName, value);
                rows.add(row);
            return rows;
          * Return all column names as a list of strings
          * @param rs query result set
          * @return list of column name strings
          * @throws SQLException if the query fails
        public static final List getColumnNames(ResultSet rs) throws SQLException
            ResultSetMetaData meta  = rs.getMetaData();
            int numColumns = meta.getColumnCount();
            List columnNames = new ArrayList(numColumns);
            for (int i = 1; i <= numColumns; ++i)
                columnNames.add(meta.getColumnName(i));
            return columnNames;
    }Anybody who lets the GC or timeouts or sheer luck handle their resource recovery for them is a hack and gets what they deserve.
    Do a search on problems with Oracle cursors being exhausted and learn what the root cause is. That should convince you.
    scsi-boy is 100% correct.
    %

  • Sending an Event to Result Set iView

    Hi,
    in the standard MDM Result Set iView, there is a provision to generate an EPCF/URL Event. But is there a way to send an event into this standard result set iView?
    I want to create a custom filter in web dynpro and filter the Result Set iView.
    Please let me know if you know of a provision to do this.
    Regards,
    Nitin

    Thanks, issue was solved.
    Ivan,
    I am using the following code:
    For Item Details
                    WDPortalEventing.fire(
         "urn:com.sap.pct.mdm.appl.masteriviews",
         "selectRecord",
         "MDMSystemAlias=SAP_MDM_Repository_Customers&MDMTableName=CUSTOMERS&mdmId="
         + rec.getId() //RecordId.
         + "&RefreshSearch=true");
    For resultset
                   WDPortalEventing.fire(
         "urn:com.sap.pct.mdm.appl.masteriviews",
         "getRecordByIds",
         "MDMSystemAlias=SAP_MDM_Repository_Customers&MDMTableName=CUSTOMERS"
         + "&id="
         + rec.getId()) ; //recordId

  • SQL Exception: Result Set Closed. Help Needed Pls...

    Hi
    I am trying to insert the name field into �TestNoName� table which is randomly retrieved from �UniqueName� table. I am getting SQL exception: result set closed. Please look at the given code and let me know what�s wrong with my code:
    Also please guide me about entering unique (serial numbers) dynamically into
    database using Java. I have to enter customer details into database at some time and some customers details after some time but the customers should be given serial numbers.
    Thank you in advance!
    Ravi
    Here is the Code:
    String query1 = "Select Name from Unique_Names";
    String query2 = "SELECT Number, Name FROM TestNoName";
    Statement stmt;
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url,"","");
    System.out.println("Successfully Connected to Database");
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery(query1);
    ResultSet rs2 = stmt.executeQuery(query2);
    int count=0;
    while (rs.next()) {
    count++;
    rs.beforeFirst();
    for(int i = 0; i < 10; i++) {
    int randomrow = random.nextInt(count)+ 1;
    System.out.println(randomrow);
    String Name2 = rs.getString("Name");
    rs2.moveToInsertRow();
    rs2.updateInt("Number",i);
    rs2.updateString("Name",Name2);
    rs2.insertRow();
    System.out.println("Exececuted SQL Statement- Inserted One Record");
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    }

    I am trying to insert the name field into
    �TestNoName� table which is randomly retrieved from
    �UniqueName� table. I am getting SQL exception:
    result set closed. Please look at the given code and
    let me know what�s wrong with my code: Post the actual exception, not some paraphrase of it. Oh, and let us know which line it actually refers to in the code.

  • Test for null result set

    I am trying to do a test for a null result set. Basically if the result set returns a value I want to display a table, otherwise I want to display an error message. The following code does not produce the error message. Either the test for null is incorrect, or for some reason I am not getting a null result set even when I don't enter any text into the following text boxes (this is for a login screen, these text boxes come a login screen):
    <input type="text" name="username">
    <input type="text" name="password">
    This is the code for the action page:
    <HTML>
    <%@page import="java.sql.*"%>
    <%
    //define connection
    Connection con = null;
    String user1 = request.getParameter("username");
    String pass1 = request.getParameter("password");
    String test = "good";
    try{
    //get the class
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //get the connection
    con = DriverManager.getConnection("jdbc:odbc:errorlog", "admin", "");
    //catch your exceptions!
    catch(Exception e){
         out.println(e.getMessage());
    %>
    <title>Error Application - Logged Errors</title>
    <link href="style/errorstyle.css" rel="stylesheet" type="text/css">
    <BODY>
    <%
    //define resultset and statement
    ResultSet rs=null;
    Statement stmt=null;
    try {
    //Using the current database connection create a statement
    stmt=con.createStatement();
    %>
    <%
    String sql="SELECT* FROM tblUsers" + " WHERE Username = '"+user1+"' AND Password ='"+pass1+"'";
    rs = stmt.executeQuery(sql);
    %>
    <% //Fetch all the records and print in table
    while(rs.next()){
    String user2 = rs.getString("FirstName");
    String pass2 = rs.getString("LastName");
    %>
    <table width="100%" border="0" cellspacing="1" cellpadding="6">
    <tr >
    <td width="67" height="27" bgcolor="#999999"><strong><font size="- 1">First Name</font></strong>
    </td>
    <td width="89" bgcolor="#999999"><strong><font size="-1">Last
    Name</font></strong>
    </td>
    </tr>
    <tr>
    <td>
    <%out.println(user2);%>
    </td>
    <td><%out.println(pass2);%></td>
    </table>
    <%}
    if (rs == null)
    out.println("Incorrect Username or Password");
    //close all your open resultsets, statements, and connection when you are done with them!
    rs.close();
    stmt.close();
    con.close();
    //catch all your exceptions
    catch (SQLException e) {
         out.println(e.getMessage());
    %>

    You simply test the rs.next().
    if ( rs.next() )
    //spit out the rs row and
    //continue processing the resultset 'til empty
    else
    msg = "invalid username or password
    }

Maybe you are looking for