Setting ResultSet CONCUR_UPDATABLE

In SaveLoad class I make a connection to my mysql server;
by "jdbc:mysql://195.1.215.170:1433/inventory_mapping"
then I create a Statement;
DB_Statement = DB_Connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
after that, I create the resultset for updating my database but
I could not make the resultset CONCUR_UPDATABLE so it does not update.
Also I do not use select with * for selecting all the table columns.
Now the question is; is the problem about mysql or what?
Note: database server is on my comp. and I connect it as administrator
and I can delete any row I want but I cannot update.

You might provide a little information the next time you post a question. Such as how you know you can't update, for one thing. Is your question number 4.5 in the Troubleshooting section of this document which is easily found on the MySQL website?
http://www.mysql.com/documentation/connector-j/index.html
If not, post some information about the problem.

Similar Messages

  • ResultSet.CONCUR_UPDATABLE

    I want to perform a query with the ResultSet.CONCUR_UPDATABLE option, because I want to delete some rows depending on some conditions.
    The problem is that I get no row in the result set, since the first next() invocation returns false.
    But when I perform the same query with just the same SQL sentence without the ResultSet.CONCUR_UPDATABLE option, I get the rows actually matching the WHERE condition.
    Any idea about what I am missing?
    Thanks in advance.

    Nothing at all.
    It has been defined in the CREATE statement as PTOVTA CHAR(20)
    What I can't understand is that the same SQL sentence behaves differently when the Statement instance is created with createStatement() (all columns are recognized without any problem) and when it is created with
    createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE) where it only works if I avoid to refer to that column in the sentence.

  • SQLException JDBC 2.0 ResultSet.CONCUR_UPDATABLE

    Hi, i have a problem using JDBC 2.0, my cod is:
    Statement c = conn.createStatement();
    Statement =conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet rest = n.executeQuery("select * from t_prueba");
    rest.last();
    rest.updateBlob("C", null);
    rest.updateRow();
    rest.close();c.close();conn.close();
    at time to execute this code, i have this error:
    java.sql.SQLException: Operaci�n no v�lida para el juego de resultados de s�lo lectura: updateBlob
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
         at oracle.jdbc.driver.BaseResultSet.updateBlob(BaseResultSet.java:482)
         at oracle.jdbc.driver.OracleResultSet.updateBlob(OracleResultSet.java:1230)
         at mypackage3.Conversor.leerImagenBase64(Conversor.java:51)
         at mypackage3.Conversor.main(Conversor.java:77)
    why is this problem if i using ResultSet.CONCUR_UPDATABLE in my statement.
    i 'm using jdeveloper 10.1.2 whith j2se 1.4.2_04
    please anyone can help me please
    tanks
    alex

    for updateable resultset your query must specify column names to select.

  • Exist SQLServer driver implement JDBC20 createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)?

    Hello,
    I have to perform a kind of "SELECT FOR UPDATE" in a database transaction. My
    DBMS is SQLServer. I think the best approach is to use the createStatement(ResultSet.TYPE_FORWARD_ONLY,
    ResultSet.CONCUR_UPDATABLE) sentence, as this should properly work in other DBMS
    like Oracle as well.
    The problem is that the driver which is provided with WebLogic Server 6.1 beta
    (weblogic.jdbc20.pool.Driver because I am using pools) does not implement this
    sentence. What should I do to get another driver which implements that? Does it
    exist? Do I have to buy it to a third company?
    I have read dozens of messages in this newsgroup regarding JDBC20, but questions
    are usually from Oracle users. I even would not understand how to solve the problem
    if I had Oracle, I think a good explanation about all this mess is missing in
    the Weblogic documentation.
    Any help would be appreciated. Regards,
    David

    David,
    Have a look at the Merant DataDirect drivers.
    Free type 3 and 4 evals are available at www.merant.com/datadirect.
    Cheers,
    Dimitri
    "Sree Bodapati" <[email protected]> wrote in message
    news:[email protected]..
    hi david,
    MS SQL Server driver that ships with WLS does not support JDBC 2.0methods.
    You will have to use a third party driver for this.
    hth
    sree
    "David Ruana" <[email protected]> wrote in message
    news:3b681248$[email protected]..
    Hello,
    I have to perform a kind of "SELECT FOR UPDATE" in a database
    transaction.
    My
    DBMS is SQLServer. I think the best approach is to use thecreateStatement(ResultSet.TYPE_FORWARD_ONLY,
    ResultSet.CONCUR_UPDATABLE) sentence, as this should properly work inother DBMS
    like Oracle as well.
    The problem is that the driver which is provided with WebLogic Server
    6.1
    beta
    (weblogic.jdbc20.pool.Driver because I am using pools) does not
    implement
    this
    sentence. What should I do to get another driver which implements that?Does it
    exist? Do I have to buy it to a third company?
    I have read dozens of messages in this newsgroup regarding JDBC20, butquestions
    are usually from Oracle users. I even would not understand how to solvethe problem
    if I had Oracle, I think a good explanation about all this mess is
    missing
    in
    the Weblogic documentation.
    Any help would be appreciated. Regards,
    David

  • How to set ResultSet not null?

    Hello !
    How can I set my ResultSet null? rs.next( ) is null.
    Thanks in advance.

    "...Hey, do you guys have an idea how to apply operator to method getTime() e.g rs.getTime("TimeOut") - rs.getTime("TimeIn")?..."
    It can't be done.
    One thing you should be checking is whether or not the last value returned from the result set was null, using the wasNull() method.
    If you're getting a NPE, it could be that one of the values you think you're getting back from the database is really null.
    Are you sure you want java.sql.Time? Not java.sql.Timestamp?
    Code it like this:
    java.sql.Timestamp timeIn = rs.getTimestamp("TimeIn");
    java.sql.Timestamp.timeOut = rs.getTimestamp("TimeOut");
    long duration = 0L;
    if ((timeIn != null) && (timeOut != null))
        long millisecondsIn = timeIn.getTime();
        long millisecondsOut = timeOut.getTime();
        duration = millisecondsOut - millisecondsIn;
        assert (duration >= 0L);
    }MOD

  • ResultSet.CONCUR_UPDATABLE Problem

    Hi!,
    I am using JDK1.3, and in my application i open the statement in updatable mode, while executing it gives me exception as follows
    java.sql.SQL.Exception(Option Feature Not Implemented).
    To avoid this i download JDBC2.0 Standerd Extension as
    jdbc2_0-stdext.jar file from sun.
    I added this file in classpath but still it is giving me the same problem.
    Tell me the solution for this.

    Not every driver implements all methods from the JDBC-interaces.
    You should have a look for other drivers for your database.

  • Bad character encoding when ResultSet is CONCUR_UPDATABLE

    Hi,
    I have a problem with encoding of texts loaded from database (slovak, czech).
    My application environment first:
    MS SQL Server 2000, standard JDBC drivers from Microsoft
    DB table encoded in windows-1250
    SAP WAS application server on UNIX, file.encoding property = iso-8859-1
    Here is part of JSP (using only for tests ):
    <%@ page language="java" contentType="text/html;charset=iso-8859-2"%>
    <% request.setCharacterEncoding("iso-8859-2"); %>
    <%
      try {
        // ... getting connection  
        java.sql.Statement stmt = conn.createStatement (
          ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
        String q = "SELECT col FROM table where id='1'";
        java.sql.ResultSet result = stat.executeQuery(q);
        if ( result.next() )
          out.write( result.getString(1) );
      catch ( SQLException sqle )
    %>
    Special characters {Slovak, Czech} are corrupted. 
    In first two lines I've tried utf-8, iso-8859-1, windows-1250 (also with pageEncoding directive) and I've check browser encoding setting in every case.
    Then I've tried tens of combination in this way:
    out.write( new String (result.getString(1).getBytes("windows-1250"), "iso-8859-1"));
    Nothing from this helps.
    And now, for me the most interesting part. When I change line with statement creation from:
    stmt = conn.createStatement ( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    to:
    stmt = conn.createStatement ( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    diacritic works... (for every setting {iso-8859-2, utf-8, windows-1250} )
    I've tried to do these changes in environment configuration::
    1. SAP WAS on UNIX + Oracle 10g
    2. SAP WAS on Windows + MS SQL 2000
    3. standalone java application + MS SQL 2000
    All 3 works fine with ResultSet.CONCUR_UPDATABLE...
    Can you give me advice, how to solve this problem? Thanks for any answer.
    Regards,
    Juraj

    Hi Juraj,
    If the column containing the texts is supporting unicode (with nVarchar, nChar,etc), don't bother to set the charset;
    otherwise
    You can try to put "charset=iso-8859-1;" in your JDBC URL if the "iso-8859-1" is the corresponding charset for slovak,czech.
    For instance,
    jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=XXX;SelectMethod=cursor;charset=iso-8859-1
    By the way, you can output the texts after they are retrieved from database to see if the problem is related to JDBC or JSP.
    for instance,
    Put the following line to the if block,
    System.out.println( result.getString(1));
    if ( result.next() ){
          String stringFromDB = result.getString(1);
          System.out.println(StringFromDB);
          out.write( [stringFromDB );
    Dennis

  • SCROLL_SENSITIVE result set can't see the data inserted.

    hi all ,
    I am trying to display all the latest data available in the table through SCROLL_SENSITIVE and UPDATABLE result set after inserting a new record in the table.
    But the result set obtained after executing the query initially is not able to see the newly inserted record in the table and hence same result is getting printed out in both the cases.
    Can u explain me what's happening in this case ?? And how can i get the updated record also without executing the statement query twice to get the latest result set.
    My full code is given below.
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class Misc3 {
    public static void main(String[] args) {
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
    int empid;
    String lname;
    String fname;
    int deptno;
    int mngrid;
    con = JDBCUtil.getOracleConnection();
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    String query = "select employee_id , last_name , first_name , department_number , manager_id from employees ";
    rs = stmt.executeQuery(query);
    System.out.println("Before inserting the new record.....");
    while (rs.next()) {
    empid = rs.getInt(1);
    lname = rs.getString(2);
    fname = rs.getString(3);
    deptno = rs.getInt(4);
    mngrid = rs.getInt(5);
    System.out.println(empid + "\t" + lname + "\t" + fname + "\t" + deptno + "\t" + mngrid);
    System.out.println("Going to insert the new record.....");
    rs.moveToInsertRow();
    rs.updateInt(1, 10);
    rs.updateString(2, "Clark");
    rs.updateString(3, "John");
    rs.updateInt(4, 2);
    rs.updateInt(5, 2);
    rs.insertRow();
    System.out.println("New record inserted successfully.....");
    System.out.println("After inserting the new record.....");
    rs.beforeFirst();
    while (rs.next()) {
    empid = rs.getInt(1);
    lname = rs.getString(2);
    fname = rs.getString(3);
    deptno = rs.getInt(4);
    mngrid = rs.getInt(5);
    System.out.println(empid + "\t" + lname + "\t" + fname + "\t" + deptno + "\t" + mngrid);
    } catch (SQLException ex) {
    System.out.println("error code : " + ex.getErrorCode());
    System.out.println("error message : " + ex.getMessage());
    } finally {
    JDBCUtil.cleanUp(con, stmt);
    *** JDBCUtil Class ****
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;
    public class JDBCUtil {
    public static Connection getOracleConnection(){
    Connection con = null;
    try{
    // Load the driver
    Class.forName("oracle.jdbc.driver.OracleDriver");
    //Establish Connection
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","ex","ex");
    }catch(Exception ex){
    ex.printStackTrace();
    return con;
    public static void cleanUp (Connection con , Statement stmt){
    // Release the resource
    try{
    if(con != null){
    con.close();
    if(stmt != null){
    stmt.close();
    }catch(Exception ex){
    ex.printStackTrace();
    Edited by: user12848632 on Aug 13, 2012 2:06 PM

    >
    Can u explain me what's happening in this case ?? And how can i get the updated record also without executing the statement query twice to get the latest result set.
    >
    Sure - but you could have answered your own question if you had read the doc link I gave you in your other thread and next time you post code use \ tags on the lines before and after the code - see the FAQ for info
    17076 : Invalid operation for read only resultset
    {quote}
    •Internal INSERT operations are never visible, regardless of the result set type.
    {quote}
    See •Seeing Database Changes Made Internally and Externally in the JDBC Dev doc I pointed you to
    http://docs.oracle.com/cd/B28359_01/java.111/b31224/resltset.htm#i1024720
    Did you notice the words 'never visible'? You won't see them as part of the result set unless you requery.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 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].

  • 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.

  • No updateable ResultSet

    Hi,
    I'm trying to do an update with the ResultSet, but I always get an exception
    that I can't do an update on a read-only ResultSet. I set the
    ResultSet.CONCUR_UPDATABLE but it is not working.
    Here is the code:
    //-------------------------------------------PreparedStatement stmt = conn.prepareStatement(SELECT_CD,
    ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    // debug message
    cat.debug("Statement: " + stmt.getResultSetConcurrency());
    // do some filling of the prepared statement
    ResultSet rs = stmt.executeQuery();
    // debug messages
    cat.debug("CONCUR_UPDATABLE: " + rs.CONCUR_UPDATABLE);
    cat.debug("CONCUR_READ_ONLY: " + rs.CONCUR_READ_ONLY);
    cat.debug("ResultSet: " + rs.getConcurrency());
    // update
    if(rs.next())
    // we have an entry
    rs.updateString(4, srcSystemInstance());
    rs.updateString(5, srcSystemType());
    rs.updateRow();
    The output of the debug messages:
    Statement: 1008
    CONCUR_UPDATABLE: 1008
    CONCUR_READ_ONLY: 1007
    ResultSet: 1007
    Even the statement is updateable, the ResultSet is still read-only.
    I'm using JDK1.3 under Window2000 and connecting to an Oracle 8.1.6 database
    with the OCI driver. (Oracle driver version 8.1.7.0.0).
    Any ideas what is wrong?
    Best Regards
    Juergen
    null

    When I tried it I did something like where dbConn is a working connection to Oracle (I can fetch data just fine). I tried a regular SELECT *, SELECT * with a WHERE clause, and using FOR UPDATE. All combinations fail
    and the dbConn is not read only, the statement is CONCUR_UPDATABLE, but the resultset is always read only.
    stmtw=
    dbConn.createStatement(
    ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    System.out.println("STMTW Concurrency is "+stmtw.getResultSetConcurrency()+" and should be "+ResultSet.CONCUR_UPDATABLE +" and not "+ResultSet.CONCUR_READ_ONLY);
    rsw=
    stmtw.executeQuery(
    "SELECT * FROM WTHR FOR UPDATE");
    System.out.println("DB READONLY :"+dbConn.isReadOnly());
    System.out.println("RSW Concurrency is "+rsw.getConcurrency()+" and should be "+ResultSet.CONCUR_UPDATABLE +" and not "+ResultSet.CONCUR_READ_ONLY);
    null

  • Please help - Scrollable result set in sql server 2000

    Hi can some one please help me. I'm trying to create scrollable result set in sql server 2000, but i just can't get it to work. I've been trying to do this for the past 12 hours. I want to go home, but I can't till I get this going! please help!!! My crap code is as follows:
    package transact;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JInternalFrame;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class DummyFrame extends Dummy
    protected String name, surname;
    protected Connection conn;
    protected CallableStatement cstatement;
    public DummyFrame()
    createFrame();
    private void createFrame()
    try
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    conn = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://server:1433;" +
    "user=user;password=pwd;DatabaseName=Northwind");
    catch (Exception e)
    e.getMessage();
    populateFields();
    menuAction();
    show();
    private void menuAction()
    btncontacts.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    getRecords();
    populateFields();
    btncontacts.setText("NEXT");
    btnkeywords.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    // transaction.getRecords();
    nextRecord();
    populateFields();
    btncontacts.setText("NEXT");
    protected void nextRecord()
    try
    // CallableStatement cstatement = null;
    cstatement = conn.prepareCall(
    "{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = cstatement.executeQuery();
    while (rs.next())
    surname = rs.getString("Lastname");
    cstatement.getMoreResults();
    catch (Exception e)
    e.getMessage();
    protected void getRecords()
    try
    CallableStatement cstatement = null;
    cstatement = conn.prepareCall(
    "{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = cstatement.executeQuery();
    while (rs.next())
    surname = rs.getString("Lastname");
    name = rs.getString("Firstname");
    rs.first();
    // call stored procedure
    catch (Exception e)
    e.getMessage();
    // populate the fields;
    private void populateFields()
    txtfirstname.setText(name);
    txtsurname.setText(surname);
    }

    ummm ok i think the logic in your code is kinda screwy...
    here is what your should be doing.
    create the gui.
    get the resultset...
    have code that looks like this for nextRecord...
    protected void displayNextRecord(){
      // we do not call next here because we already called it last time
      surname = rs.getString("Lastname");
      name = rs.getString("Firstname");
      populateFields();
      if(!rs.next(){
        btncontacts.setEnabled(false);// i'm not sure what btncontacts is but we want to disable next becuase there are no more records...
    // in your intitalization code you need to do this...
    // you old stuff ending with...
    ResultSet rs = cstatement.executeQuery();
    // the new stuff...
    if(rs.first()){
      displayNextRecord();
    }else{
      btncontacts.setEnabled(false);//the result set is empty
    }ok the real problem you are having is that you are trying to display one record at a time but you are scrolling
    through the entire result set using while(rs.next()... what you
    want to do is create the result set once and scroll through
    it one item at a time with your gui.
    the example method i have given displays the data from the current
    row in your gui. then it advances the result set forward one row if possible. this method assumes that the result set will always
    be positioned on a valid row thus the need for calling
    rs.first() before we originally call displayNextRecord()
    well i hope you find this helpful.

  • Problem with Sensitive ResultSet in SQL Server 2000

    Hi,
    I am trying to use SCROLL_SENSITIVE and CONCUR_UPDATABLE ResultSet accessing SQL Server 2000. I am using JDK 1.3 and supported JDBC driver. When I tried to insert a row, I got the following message:
    sp_cursor: The cursor identifier value provided (0) is not valid
    Is there any setting in SQL Server that I need to configure or do I miss something in my code?
    Thanks,
    Andi Setiyadi
    Here are my codes:
    cs = connection.prepareCall("{call sp_deptInfo (?,?,?)}", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    cs.setInt(1, 0);
    cs.setString(2, "");
    cs.setString(3, "name/orderbyid");
    rs = cs.executeQuery();
    rs.last();
    int rows = rs.getRow();
    rs.afterLast();
    rs.moveToInsertRow();
    rs.updateInt(1, rows + 1);
    rs.updateInt(2, Integer.parseInt(parentDept));
    rs.updateString(3, newDept);
    rs.updateInt(4, 1);
    rs.insertRow();

    I am getting the resultset by calling a stored procedure. I am not changing the stored procedure itself.Database drivers create 'connections' and 'statements' which match the SQL that you pass it. You are passing it a stored proc. The only information that it has is on a stored proc. It doesn't matter where the stored proc got its info from. The stored proc doesn't return tables and indexes into tables. It returns a result set (that is what your code suggests.) That is all the information that the driver has.
    Consider your stored proc might return this
    select * from mytable where ....
    But it could also do this
    select 'value1', 'value2', ... from dual
    On the java side it isn't not going to know which of the above that you did. Nor should it. And you can't update/insert into that second example.
    Or at least that is how I look at it.
    Your code looks like it is trying to 'update' the result set that a stored proc returned. And I simply don't see how that is possible. Or even why anyone would want to do it.

  • ResultSet loop back to first record

    I have an Access table : products
    I have a total of 7 products. When I use rs.next(), it will scroll for each record until the last record.
    How do I make it go back to the first record after it hit the last record ?
    I hv tried rs.first() and rs.last(0 method, but it doesn't work and give me TYPE FORWARD kind of error, further clarify with some expert, they said it is because my cursor state is the Forward Type only ... so cannot loop back....
    Then I also use the cn.createConnection(ResultSet.InSensitive Result ... kind of stuff ... all cannot work as Access seems like cannot go backward ...
    Any other good suggestion ?

    1. Use this, st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    Or,
    2. Store your result set in a temporary array and scroll thru this array for subsequent repetitive iterations.
    Sudha

  • 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.

Maybe you are looking for

  • How to create a form value bean.

    Hi to all, In my page I have one lov. It gives Address and Addressid. I want to show the address details (only ) to User. I dnt want to show the addressid. But I passed the addressid to database. Set the Addressid in form value and set the Address in

  • Diffrence in xi 3.0 and  pi( xi 7.0)

    hi all. what is the difference between xi 3.0 and pi(xi 7.0) and what are the compnents list in both the version thanks and regards viju

  • Why do the photos on my iPhone 4 revert to the original after I try editing them on iPhoto?

    Ever since I've had my iPhone 4 the photos won't edit (denoise, and sharpness). They continue to revert to the original, this is not the case for cropping and other editing methods. I have tried everything, updating iPhoto and my computer, changing a

  • An unexpected error occurred. I-200

    Hi, I have been having issues in launching Adobe Muse. Everytime I attempt to launch the program it asks me to sign in and then gives me the screen: 'An unexpected error occurred processing your request. Please try again later. I-200'. I have also at

  • Converting Line item dimension to non line item dimension

    I have some BI 7.0 issues. For some of the existing cubes I had certain dimension as line item dimension  - I wanted to add some characteristic to these dimensions. I am able to do this change and activate the cube. But we noticed that the data which