Bug in ResultSet.TYPE_SCROLL_SENSITIVE

Hello OTN,
I am able to found a bug in JDBC driver-8.1.7
It is:
When I tried to create a resultset of type: ResultSet.TYPE_SCROLL_SENSITIVE(1005) from prepared statement, I am getting resultset of type: ResultSet.TYPE_SCROLL_INSENSITIVE(1004).
I used this driver with :Oracle-Oracle8i Enterprise Edition Release 8.1.6.1.0.
Please see the code snippet below:
PreparedStatement pst = conn.prepareStatement("select * from empdest",
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE); //READ_ONLY);
System.out.println("set type: "+ResultSet.TYPE_SCROLL_SENSITIVE); //printing 1005 here.
ResultSet rs = pst.executeQuery();
System.out.println("got type: "+rs.getType()); //printing 1004 here
Is it really a bug or have any alternative!
Please respond to this ASAP.
Regards,
SreenU.

this is a "feature"... :)
don't do "select *"... you must name the columns in the select statement or the driver will change the type to read only...
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Sreenu B ([email protected]):
Hello OTN,
I am able to found a bug in JDBC driver-8.1.7
It is:
When I tried to create a resultset of type: ResultSet.TYPE_SCROLL_SENSITIVE(1005) from prepared statement, I am getting resultset of type: ResultSet.TYPE_SCROLL_INSENSITIVE(1004).
I used this driver with :Oracle-Oracle8i Enterprise Edition Release 8.1.6.1.0.
Please see the code snippet below:<HR></BLOCKQUOTE>
null

Similar Messages

  • Error while defining :- createStatement(ResultSet.TYPE_SCROLL_SENSITIVE)

    What I am trying to do is, get the current row and compare with the previous from the resultset.
    To achieve it I am using the previous(), absolute() and next() methods from ResultSet. Now to be able to use these methods I believe I need to define connx as:
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con1 = DriverManager.getConnection("jdbc:oracle:thin:@uaix02....","....","....");
    stmt1 = con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE);
    By doing so when I compile from JDeveloper, I am getting the following error:
    C:\Program Files\Oracle\JDeveloper 3.2\myhtml\test548_html\untitled10.jsp
    Warning: (0) ISO-8859-1 character set may not match project compiler setting.
    Error: (82) method createStatement(int) not found in interface java.sql.Connection.
    I am importing java.sql and oracle.jdbc libraries.
    Any pointers to it would be greatly appreciated.
    Thanks in Advance
    Ajith
    null

    Fixed...
    Actually createStatement() takes zero or no arguments....
    kash! the error messages had been more developer friendly....
    Ajith

  • Bug in ResultSet#getDate() with ojdbc7-12.1.0.1

    As "documented" here java - ResultSet#getDate() semantics - Stack Overflow there seems to be a bug in ResultSet#getDate() with ojdbc7-12.1.0.1.
    The java.sql.Date condition
    To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero
    is violated.
    How can we report that to Oracle?

    Hello Hwang
    1/ I don't know for your first question. Have you checked all the RUEI rpm prerequisites? One should be missing probably.
    2/ One solutions consists of installing and configuring Squid proxy on the RUEI server. Then you can use your own browser with ruei server as a proxy and surf. You also need to tweak RUEI to collect traffic within the right network card.
    as $RUEI_USER :
    execsql config_set_profile_value wg profile_wg_localhost_1 config ForceInterface add eth0
    replace wg by the name of your profle (probably wg anyay) and eth0 by the proper network card (also eth0 probably).
    GL & HF
    JB

  • Bug Report: ResultSet.isLast() returns false when queries return zero rows

    When calling the method isLast() on a resultset that contains zero (0) rows, false is returned. If a resultset contains no rows, isLast() should return true because returning false would indicate that there are more rows to be retrieved.
    Try the following Java source:
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import oracle.jdbc.driver.*;
    public class Test2 {
    public static void main (String [] args) throws Exception {
    Connection conn = null;
    String jdbcURL = "jdbc:oracle:thin:@" +
    "(DESCRIPTION=(ADDRESS=(HOST=<host computer>)"+
    "(PROTOCOL=tcp)(PORT=<DB port number>))"+
    "(CONNECT_DATA=(SID=<Oracle DB instance>)))";
    String userId = "userid";
    String password = "password";
    try{
    // Load the Oracle JDBC Driver and register it.
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    // *** The following statement creates a database connection object
    // using the DriverManager.getConnection method. The first parameter is
    // the database URL which is constructed based on the connection parameters
    // specified in ConnectionParams.java.
    // The URL syntax is as follows:
    // "jdbc:oracle:<driver>:@<db connection string>"
    // <driver>, can be 'thin' or 'oci8'
    // <db connect string>, is a Net8 name-value, denoting the TNSNAMES entry
    conn = DriverManager.getConnection(jdbcURL, userId, password);
    } catch(SQLException ex){ //Trap SQL errors
    // catch error
    //conn = new OracleDriver().defaultConnection(); // Connect to Oracle 8i (8.1.7), use Oracle thin client.
    PreparedStatement ps = conn.prepareStatement("select 'a' from dual where ? = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); // Use any query that will return zero rows.
    ps.setInt(1, 1); // Set the params so that the query returns 0 rows.
    ps.setInt(2, 2);
    ResultSet rs = ps.executeQuery();
    System.out.println("1. Last here? " + rs.isLast());
    while (rs.next()) {
    // do whatever
    System.out.println("2. Last here? " + rs.isLast());
    ps.close();
    rs.close();
    EXPECTED RESULT -
    1. Last here? true
    2. Last here? true
    ACTUAL RESULT -
    1. Last here? false
    2. Last here? false
    This happens to me on Oracle 9.2.0.1.0.

    387561,
    For your information, I discovered this problem from
    running a query that did access an actual DB table.
    Try it and let me know.I did say I was only guessing, and yes, I did try it (after I posted my reply, and before I read yours). And I did check the query plan for the queries I tried -- to verify that they were actually doing some database "gets".
    In any case, the usual way that I determine whether a "ResultSet" is empty is when the very first invocation of method "next()" returns 'false'. Is that not sufficient for you?
    Good Luck,
    Avi.

  • Bug with ResultSet.wasNull() function

    The wasNull() function is incorrectly reporting false when null values are read for doubles. This is in conjunction with the Oracle 10gr2 classes12.jar driver.
    The case where I am seeing this is for a left outer join SQL statement. Double columns on the right side of the join are reporting false with wasNull when they are in fact null. I haven't tested other conditions yet.
    Is this a documented bug?
    Also, I apologize if there is a more appropriate forum for this question. If so, just let me know and I'll post there.

    Hi ,
    There is a bug mentioned on http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4424215.
    You can go through this for the fix release.
    -Priyanka

  • Bug in Oracle UpdatableResultSet? (insert, updateString requires non-empty ResultSet?

    As far as I can determine from the documentation and posts in other newsgroups
    the following example should work to produce an updatable but "empty" ResultSet which can be used to insert rows.
    But it doesn't work in a JDK 1.2.2 and JDK 1.3.0_01 application using Oracle 8i (8.1.7) thin JDBC
    driver against an Oracle 8.1.5 database I get the following error
    SQLException: java.sql.SQLException: Invalid argument(s) in call: setRowBufferAt
    However, if I change it to so the target (ie insert) ResultSet is initialized to contain one or more
    rows, it works just fine.
    ResultSet rset2 = stmt2.executeQuery ( "select Context.* from Context where ContextCd = '0' " );
    Is this a bug in Oracle's JDBC driver (more specifically, the UpdatableResultSet implimentation)?
    Does an updatabable ResultSet have to return rows to be valid and useable for insert operations?
    If it does, is there another way to create an updatable ResultSet that does not depend upon
    "hard-coding" some known data value into the query?
    try
    // conn is a working, tested connection to an Oracle database via 8.1.7 thin JDBC driver.
    // source statement
    Statement stmt = conn.createStatement (
    ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
    System.out.println("source rset");
    rset = stmt.executeQuery ( "select Context.* from Context" );
    // target Statement
    Statement stmt2 = conn.createStatement (
    ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
    ResultSet rset2 =
    stmt2.executeQuery ( "select Context.* from Context where ContextCd = NULL" );
    System.out.println(
    "see if rset2 looks good even though empty (bcs primarykey = null)");
    ResultSetMetaData rsmd2 = rset2.getMetaData();
    int numColumns = rsmd2.getColumnCount();
    for( int i = 0; i <= numColumns; i++ )
    env.msg.println ( "(" + i + ") " + rsmd2.getColumnLabel(i) );
    // test results showed the correct columns even though no row returned.
    // quess we can use this trick to create an "empty" insert ResultSet.
    System.out.println("interate through rset and insert using rset2");
    if(rset.next())
    System.out.println("move to insert row");
    rset2.moveToInsertRow();
    System.out.println("insert values");
    rset2.updateString( "ContextCd", rset.getString("ContextCd") + "-test" );
    rset2.updateString( "Descrip", "test" );
    rset2.updateString( "Notes", "test" );
    System.out.println("insert row into db (but not committed)");
    rset2.insertRow();
    catch( ... ) ...
    Thanks
    R.Parr
    Temporal Arts

    I have noticed the same problem, actually it doens't matter if there is no data in your resultset. If you have a result with data and suppose you were to analyze the data by moving through all of the rows, the cursor is now after the last row. If you call insertRow, the same exception is thrown. Kinda strange, I didn't get any response as to why this is happening and that was a few weeks ago. I hope someone responds, at this point I am just re-writing some of my code to not use updateable resultsets.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Randall Parr ([email protected]):
    As far as I can determine from the documentation and posts in other newsgroups
    the following example should work to produce an updatable but "empty" ResultSet which can be used to insert rows.
    But it doesn't work in a JDK 1.2.2 and JDK 1.3.0_01 application using Oracle 8i (8.1.7) thin JDBC
    driver against an Oracle 8.1.5 database I get the following error<HR></BLOCKQUOTE>
    null

  • About TYPE_SCROLL_SENSITIVE of ResultSet

    Hi,I used
    Connection.prepareStatement( sql,
    ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_READ_ONLY
    to get my PreparedStatement,and then when I retrieved data from the ResultSet object,I found that the getObject() method always returned null and getString() method returned wrong encoding Strings. But it's OK when I used common PreparedStatement.I don't know what the hell is going on.
    can anybody give me some suggestion? I am working under Oracle 8.1.6 Server & JDBC driver.
    thanks very much.

    this is a "feature"... :)
    don't do "select *"... you must name the columns in the select statement or the driver will change the type to read only...
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Sreenu B ([email protected]):
    Hello OTN,
    I am able to found a bug in JDBC driver-8.1.7
    It is:
    When I tried to create a resultset of type: ResultSet.TYPE_SCROLL_SENSITIVE(1005) from prepared statement, I am getting resultset of type: ResultSet.TYPE_SCROLL_INSENSITIVE(1004).
    I used this driver with :Oracle-Oracle8i Enterprise Edition Release 8.1.6.1.0.
    Please see the code snippet below:<HR></BLOCKQUOTE>
    null

  • Invalid operation for read only resultset:

    Hi.
    I'm developing an app that connects to Oracle, but I ran into the following problem:
    When I create a Statement, I specify
    that I need an Updatable ResultSet with the following code:
    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rset =stmt.executeQuery(somesql);
    When I try to update the ResultSet, I get an SQLException: java.sql.SQLException: Invalid operation for read only resultset: updateString
    Am I
    doing something wrong or is this a bug?
    Any info is greatly appreciated.
    null

    There are limitations on the kinds of queries you can perform. If the query is not suitable for update, it reverts back to readonly automatically. Read the below article about limitations and examples.
    http://technet.oracle.com/doc/oracle8i_816/java.816/a81354/resltse2.htm
    null

  • Two resultset objects

    IS it possible to define two resultset objects with two different queries inside the same DB class?java.sql.SQLException: Invalid state, the ResultSet object is closed.
         at net.sourceforge.jtds.jdbc.JtdsResultSet.checkOpen(JtdsResultSet.java:299)
         at net.sourceforge.jtds.jdbc.MSCursorResultSet.next(MSCursorResultSet.java:1123)
         at DB5.getDetails(Daily_Quote_Response_report.java:238)
         at Daily_Quote_Response_report.main(Daily_Quote_Response_report.java:74)
    java.util.List items = null;
            String query;
            String query2;
            try {
                query =
                       "select * from oqrep_except_resp_summary";
                query2 = "select * from oqrep_except_resp_detail";
                Statement state = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                        ResultSet.CONCUR_READ_ONLY);
                ResultSet rs = state.executeQuery(query);
                ResultSet rs2 = state.executeQuery(query2);
              //cannot create two rs objects // ResultSet rs2 = state.executeQuery(query);
                items = new ArrayList();Edited by: bobz on 03-Dec-2009 11:16
    Edited by: bobz on 03-Dec-2009 11:16

    Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

  • Implicit vs explicit close of resultsets and statements?

    Hi friends.I am a newbie Java Developer..Okay Here goes
    I have just made a LAN based Java application using Swing,JDBC with backend as MS-Access..The backend is on a shared network drive..
    The application is distributed as jar files on the LAN PCs..
    Everywhere I have connected to the database I have just closed the connection explicitly like this
    con.close();
    I do not close the associated resultset and statement explicitly
    The specification says associated statements and resultsets close when you close
    the connection,even if you don't explicitly close them
    Also I am not using connection pool..its simple basic connection using DriverManager
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url = "jdbcdbcSN name";
    String user = "";
    String pw = "";
    con = DriverManager.getConnection(url, user, pw);
    Statement stmt = con.createStatement();
    String select = "" ;
    ResultSet rows = stmt.executeQuery(select);
    On the net everyone says to explicitly close everything..but I did not know that
    earlier..
    If specification says everything closes on
    closing connection why do ppl insist on closing everything explicitly..?
    Or is this driver dependent..don't the drivers go through the specification..
    My driver is the Sun JDBC ODBC bridge.....
    I found this method DriverManager.setLogwriter()
    It prints out a trace of all JDBC operations..
    So I ran a sample program with this method included...
    I redirected output to a log file..
    In that program I just explicitly close the connection without closing the
    statements and resultsets explicitly...
    After running the program and seeing the log I saw that the statements
    and resultsets are closed implicitly If I just close the connection explicitly..
    I am putting the log file and the code..
    Have a look at the end of the log file..
    Code
    import java.sql.;
    import java.io.;
    class gc4test
    public static void main(String args[])
    Connection con = null;
    try
    FileWriter fwTrace = new FileWriter("c:\\log.txt");
    PrintWriter pwTrace= new PrintWriter(fwTrace);
    DriverManager.setLogWriter(pwTrace);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url = "jdbc:odbc:pravahcon";
    String user = "admin";
    String pw = "ash123";
    con = DriverManager.getConnection(url, user, pw);
    Statement stmt = con.createStatement();
    Statement stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    Statement stmt2 = con.createStatement();
    Statement stmt3 = con.createStatement();
    Statement stmt4 = con.createStatement();
    Statement stmt5 = con.createStatement();
    Statement stmt6 = con.createStatement();
    Statement stmt7 = con.createStatement();
    String select = "SELECT * FROM Users" ;
    ResultSet rows = stmt.executeQuery(select);
    ResultSet rows1 = stmt1.executeQuery(select);
    while(rows.next())
    con.close();
    catch (ClassNotFoundException f)
    System.out.println(f.getMessage());
    System.exit(0);
    catch (SQLException g)
    System.out.println(g.getMessage());
    System.exit(0);
    catch (Exception e)
    System.out.println(e.getMessage());
    System.exit(0);
    End of Log File
    Setting statement option (SQLSetStmtAttr), hStmt=50275112, fOption=25
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    Fetching (SQLFetch), hStmt=50274224
    End of result set (SQL_NO_DATA)
    *Connection.close
    8 Statement(s) to close
    *Statement.close
    Free statement (SQLFreeStmt), hStmt=50281544, fOption=1
    deregistering Statement sun.jdbc.odbc.JdbcOdbcStatement@2e7263
    *Statement.close
    Free statement (SQLFreeStmt), hStmt=50277224, fOption=1
    deregistering Statement sun.jdbc.odbc.JdbcOdbcStatement@1bf216a
    *Statement.close
    *ResultSet.close
    *ResultSet has been closed
    Free statement (SQLFreeStmt), hStmt=50274224, fOption=1
    deregistering Statement sun.jdbc.odbc.JdbcOdbcStatement@156ee8e
    *Statement.close
    Free statement (SQLFreeStmt), hStmt=50280464, fOption=1
    deregistering Statement sun.jdbc.odbc.JdbcOdbcStatement@c20e24
    *Statement.close
    Free statement (SQLFreeStmt), hStmt=50278304, fOption=1
    deregistering Statement sun.jdbc.odbc.JdbcOdbcStatement@12ac982
    *Statement.close
    *ResultSet.close
    *ResultSet has been closed
    Free statement (SQLFreeStmt), hStmt=50275112, fOption=1
    deregistering Statement sun.jdbc.odbc.JdbcOdbcStatement@e0e1c6
    *Statement.close
    Free statement (SQLFreeStmt), hStmt=50276144, fOption=1
    deregistering Statement sun.jdbc.odbc.JdbcOdbcStatement@6ca1c
    *Statement.close
    Free statement (SQLFreeStmt), hStmt=50279384, fOption=1
    deregistering Statement sun.jdbc.odbc.JdbcOdbcStatement@1389e4
    Disconnecting (SQLDisconnect), hDbc=50271048
    Closing connection (SQLFreeConnect), hDbc=50271048
    Closing environment (SQLFreeEnv), hEnv=50270880
    So like what these implicitly closed statements and resultsets are different from explicitly closed
    resultsets and statements..?

    Please do not crosspost/doublepost the same question again. It is rude in terms of netiquette.
    Stick to one topic: [http://forums.sun.com/thread.jspa?threadID=5393387&messageID=10745794#10745794].

  • Scrollable/Updateable ResultSet objects

    I am trying to create an instance of a scrollable/updateable ResultSet object with the following code:
    Statement stmt = con.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery("SELECT * FROM sch.a");
    The Connection object has been made successfully but am getting an AbstractMethodError Exception at line 1.
    Can anyone please help me out here.
    Thanks
    I am using JDK 1.3.1 and JDBC 2.0

    I use this and works fine for me....let me know how it goes...
    ResultSet resultSetMultCond = null;
    Statement getMultPartCond = null;
    String sqlMultCond = null;
    sqlMultCond = "SELECT #PART,#CONDS,COUNT(*) AS MCOUNT FROM MYLIB WHERE #PART = 'A123' GROUP BY #PART,#CONDS ORDER BY #PART";
    getMultPartCond = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);
    resultSetMultCond = getMultPartCond.executeQuery(sqlMultCond);

  • Controversy in two ResultSet!!!

    Could anyone please provide me a solution for this problem..
    I've created two ResultSet rs1 and rs2, both are retrieving the data from the same table. Manipulation of rs2 or any kind of processing should affect the rs1. So, if i updating something in the same table through rs2 , so it should affect the entire table . So, for other retrieval of data it should be updated. I've written this code, but it's not working.....
    Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
                    ResultSet rs,rs1;
                    rs=stmt.executeQuery("select * from checkdata");
                    while(rs.next())
                        String s1=rs.getString(1);
                        int count=1;
                        rs1=stmt.executeQuery("select phone_no from checkdata where phone_no='"+s1+"'");
                        while(rs1.next())
                            if(!(rs1.isLast()))
                                count=count+1;
                                rs1.deleteRow();
                            stmt.executeUpdate("update checkdata set count='"+count+"' where phone_no='"+s1+"'");Please help me out!!!!
    in advance thanks a lot....

    First of all i've this sample_log.txt file which i've putted into the table using bulk insert command . The text file looks like:
    123:books:java:Tue Dec 24 10:34:56 IST 2006
    123:books:java:Wed Dec 25 16:45:58 IST 2006
    123:books:java:Fri Dec 27 10:34:12 IST 2006
    234:books:C++:Mon Mar ..............................
    etc. it's a log file so it just added into the text as the request comes.
    Now i've putted all these values into the table.
    What i want is to read all these details and update the details as the last accessed. Suppose in this example, there should be only one entry for '123' and also update the details as the latest time that is 'Fri Dec 27 10:34:12 IST 2006' rest the two(2) should be deleted from the database and also there should be one more coloumn name count which is to be incremented as it encountered the same no. i.e '123' else it should be 1. The result i want is:
    after putting the logic it should appear as:
    123:books:java:Fri Dec 27 10:34:12 IST 2006:3
    234:books:c++:Mon Mar 12 10:12:10 IST 2006:1
    etc......
    I've to do all this in my jsp page using jdbc connectivity, with SQL 2005 as database.

  • The requested operation is not supported on forward only resultset.

    I have created an interface in java which is connected with SQL server 2008 r2. When I press the Next and Previous button it navigates the record successfully. But when I search a particular record in database
    and then click the Next or Previous button it not show the Next of Previous data please guide me where might be the problem. I wrote the following code to prepare a query. 
    pst=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
            rs=pst.executeQuery();
    thanks in advance 

    Good day AliShakir
    Your question has nothing do to with SQL Server, but with Application's Architecture.
    The solution can be like this:
    Each time that the buttons click, you need to check what is the value in the search field. If the value is not empty (ue trim function to clear balk spaces), then you should post a query which include a filter (I do not know Java, but make sure that you
    do not use + to add the filter or your application will be open for SQL Injection!, you should use parameters or SP)
    I recommend that you post the question on Java forum as well (as Shanky suggested), and dont forget to post code and not just images, since in most forum's interfaces no one will help you if you dont post code.
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Trying to find the number of rows in a ResultSet

    I am trying to find the number of rows in a ResultSet, using the following code:
    rs = st.executeQuery(query);
    rs.last(); // to move the cursor to the last row
    System.out.println(rs.getRow());
    However, I am getting this error:
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.last
    Whats going wrong??

    praveen_potru wrote:
    You might have not used scrollable result set..
    Try like this:
    stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);rs = stmt.executeQuery(sqlString);
    // Point to the last row in resultset.
    rs.last();
    // Get the row position which is also the number of rows in the ResultSet.
    int rowcount = rs.getRow();
    System.out.println("Total rows for the query: "+rowcount);
    cheersAnd I hope the OP would read it because the thread is a year old.

  • Problem to get ResultSet when it is used a Date type in the query condition

    hello ,
    I having a bit of nightmare getting a ResultSet how result of one simple Query for a table when the condition WHERE involve a Date type.
    To change the String value in a date to use in the query condition, I tried both:
    String strDate = "dd/mm/yyyy";
    (1.) java.sql.Date sqlDate = new java.sql.Date(strDate.getTime() )
    (2.) SimpleDateFormat formatter = new SimpleDateFormat(strDate) ; sqlDate = formatter.parse(strDate);
    and finally I use this code to get the ResultSet:
    sql = "SELECT * FROM myTable Where (idCli = " + cd_Cli + " And dateReg = " + sqlDate + ")";
    statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    resultSet = statement.executeQuery(sql);
    boolean ok = resultSet.last();
    totNumberOfRegistration = resultSet.getRow();
    But In both the cases I get a empty resultSet.
    I shoul like if someone would look my code to say me where it is the mistake...
    thank you
    tonyMrsangelo
    P.S. I tryed using PrepareStatement too to get the ResultSet, but in that case I couldn't use the ResultSet because executing the statement resultSet.last() I get the error: "Result set type is TYPE_FORWARD_ONLY"

    In a database like Oracle, you need to use a function like TO_DATE; other databases may have something similar.
    However, the proper way to do this is to use a PreparedStatement. Then you can say
    PreparedStatement ps = conn.prepareStatement("update SOMETABLE set SOME_DATE=? where SOME_ID=?");
    ps.setDate(1, new java.sql.Date(someJavaUtilDate.getTime()));
    ps.setInt(2, theId);
    ps.executeUpdate();

Maybe you are looking for

  • 3 x Mac minis, with external superdrives, incapable of importing a CD cleanly. ***?

    I have three mac minis, each without internal drive, rack mounted in sonnet rack mac enclosures. Each one is directly connected to macbook air superdrives - as sold to me by the mac dealer. None of these units is capable of importing a CD of any kind

  • How to change active partition?

    Hi experts, I have disk D which contains OS windows 7 and not in active, but my another disk E is in active with 100% free space.so, how can i change active partition from E to D ? please help me  

  • Chart Expert - Options tab question

    Post Author: training2go CA Forum: Charts and Graphs Hello, I noticed a new feature on this tab called "Auto Arrange". I looked in the help file, but could not find any info about it. I've selected the option and re-run the report, but didn't see any

  • SC gone in to error while creating with attachment

    Hi, SCs gone in to error when ever i create SC with attachement. error is : Shopping cart 3000349408 (PO 2000122875):  000 Can any one help on this..

  • Drag n Drop between JButton and third party Java object

    Hi! I want to implement drag n drop(however it is not drag n drop in its real sense) between JButton(s) placed in a JToolBar and third party Java Object i.e. Netbeans Visual Library API's Scene class that is actually like a Canvas in drawing Apps. Th