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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • I can't see the data logger to move a lookout application to another computer

    To move a application to another PC i can't see historical logging why?
    Attachments:
    Toneleria15Jul02.rar ‏1424 KB
    Toneleria15Jul02.r00 ‏818 KB

    Claudio,
    I'm not sure if I understand your question.
    1) What version of Lookout are you using?
    2) Are you using a server-client relationship and you can't see the data in your clients?
    3) When you move your Lookout process, have you adjusted where to find your historical database (this can be set under File -> Modify Process or if you are using a hypertrend, you can make sure that your path is pointing to the appropriate location - under the trend properties).
    Please give me a little more information and I will try to help you resolve this issue. Thanks.

  • Final user's can not see the data due to limited authorization.

    We have created a InfoSet with three info Objects, 0Account, 0Costcenter and 0COMP_CODE. 0Costcenter have an attribute retail location  0RT_LOCATIO.
    0RT_LOCATIO is an authorization relevant object. We as consultants can execute the infoset properly, but final user's with limited authorizations can not see the data because of authorization failier
    We hae several options to solve the issue, deleselect the auth. flag in the infoobject; delete the infoobject from the attributes of the cost center or create an authorization object and assign it to the final user's profile. But we don't want to go that way.
    My question is, is there any way to avoid including this attribute in the infoset definition? We are not using it in the query and we don't need it, so if we could delete it from the infoset (in the same way you add or delete infoobjects from an Infocube) without changing the cost center aster data, we will have our problem solved.
    Does anyone how to do this (if possible)?
    Thanks in advance!

    Just do two things to find the authorization check failed for that user.
    1. Execute SU53 output and find out the authoirzation check failed. If yes, please send that to BASIS Team.
    2. Next one, switch on the authorization trace in ST01 and ask that user to see that data. if the user is failed with authorization issue. switch off the trace in ST01 and find out the issue.
    Do this way, if it is not successful you can go for any other alternate way.
    Hope this would help you.

  • I'm in cycle mode, and 'merge' is clicked in preferences. However, when I record, my previous track data keeps getting overwritten. Does anyone know what I'm doing wrong. Interestingly, I can still see the data in the region.

    I'm in cycle mode, and 'merge' is clicked in preferences. However, when I record, my previous track data keeps getting overwritten. Does anyone know what I'm doing wrong. Interestingly, I can still see the data in the region.

    jamestait wrote:
    when I record, my previous track data keeps getting overwritten.
    since you didn't specify, are you recording in a single take?
    http://www.bulletsandbones.com/GB/GBFAQ.html#multipassrecording
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • How can i see the date of the pictures i took? help!

    how can i see the date of the pictures i took? help!

    Import them to your computer (see http://support.apple.com/kb/HT4083) and the date and other exif data will be available.

  • How can I see the date on my photos taken from my iPod touch

    how can I see the date on my photos taken from my iPod touch...

    The requirements for the app are:
    Requirements: Compatible with iPhone, iPod touch, and iPad.Requires iOS 5.0 or later.

  • Can not see the data in the grid

    Hi,
    nice to see the new features, but I can not see the the table inserts
    in the data grid - the <data> rider is not clickable.
    Regards

    Hi annerose,
    This problem has appeared in a few other threads. It's caused by installing Release 2 Raptor over Release 1 Raptor without first deinstalling Release 1 Raptor . So what you need to do is:
    1) Back up any important Raptor files, e.g. connections etc.
    2) Remove the existing Raptor Rel 1 installation folder
    3) Install Raptor Rel 2
    Hope this helps
    ady

  • How can I see the data in the aggregates

    how can see the data available in the aggregates.
    Jay

    Hi Jay,
    its so simple,
    please goto the manage aggregates screen and copy the technical name of the aggregate and add
    /bic/exxx  xxx is the aggregate technical name, and for f fat table use /bic/fxxx, and go to se16 and enter the table name and thats it ur data is with u.
    R

  • How can i see the date and time of iPhone pictures, How can i see the date and time of iPhone pictures

    I would Like to know where i can see the date AND time on a picture i take With My iPhone? AND if not on the phone automaticly,.. Why not?... If even the cheapest phones provide this BASIC info.

    You can get this info if you have iPhoto for your phone (costs $5) - you can also try out the app I made (free) https://itunes.apple.com/us/app/photo-date/id605218393?ls=1&mt=8 Would love to know what you think!

  • Other user can not see the data from the workbook

    Hi Friends,
    I created a workbook with some worksheets in a Business area. The owner of the workbook has no problem to view all the worksheets and get all the data returned.. I granted all the neccessary privileges to other users ,they could see the workbook, but no data returnd for the query results. Tried refresh the worksheet, same no data retrieved.Checked the SQL inspector and the plan, it showed the correct paths and execution plan without any errors there. The same query run in SQL plus by other users returned data correctly.
    By the way, I had a summary folder in the workbook. During the troubleshooting, I dropped this summary folder, still the same no data return for other users.
    Any body happen to know the cause or has some ideas on this issue?
    The discoverer administrator verson is 9.0.4.00 and the PLUS /Viewer is 9.04.45.02.
    Thank you very much,
    J.K

    Hi All
    The scheduling of reports, as you have probably noticed, requires that the scheduling privilege within Discoverer Administrator tool be granted to the user NOT to a role. Scheduling will not work if you attempt this. The reason for this is that these two SYS grants must go to a user:
    GRANT SELECT ON SYS.V_$PARAMETER
    GRANT EXECUTE ON SYS.DBMS_JOB
    The user will also need to have these grants:
    CREATE PROCEDURE,
    CREATE TABLE,
    CREATE VIEW,
    EXECUTE ANY PROCEDURE,
    UNLIMITED TABLESPACE on user's tablespace
    My new Discoverer 10g Handbook, which I would recommend to anyone working with Discoverer, explains scheduling in detail and even tells you how the tables and views that are used to store the results work. You won't find this information anywhere else, as you will see if you read some of the five reviews that have been left on Amazon.com. For more information about the book please look here:
    http://learndiscoverer.com/books/books.htm
    The PUBLIC grants are not having any impact. All these do is ensure that ALL users have the same basic privileges. You can just as easily grant these to any role of your choosing and it will work just fine.
    By the way, because the PUBLIC role is the MINIMUM privileges that a user can have you might want to consider reducing the end user Discoverer privileges afforded to PUBLIC. By default, all users can Create and Edit workbooks, share workbooks, save workbooks and so on. This is far too rich a set of privileges for the basic user, who in most cases will be a VIEWER user. Whenever I create a new EUL I always recommend that my client reduces the PUBLIC user's privileges and then create new roles for more advanced VIEWER and PLUS users, adding privileges as required.
    Thus, my basic VIEWER, aka PUBLIC, has only these privileges:
    Collect Query Statistics
    Item Drill
    Drill Out
    My advanced VIEWER has this additional privilege:
    Save Workbooks to Database
    My basic PLUS user has all of the above, plus these (pardon the pun):
    Create/Edit Query
    Create Link
    and my advanced PLUS users get everything, which means they now get these as well:
    Grant Workbook
    Schedule Workbooks
    I also remove the Save / Save As Actions link from Viewer which prevents the basic VIEWER users from knowing that it is there. In essence, because these users no longer can click the Save link and because they do not have the Save to Database privilege, they will not be prompted to save within Viewer no matter what they do. This now makes 10.1.2 Viewer work the same way as previous versions.
    Even though the Save link is not there, my advanced Viewer users will be prompted to save if they have made any changes. This therefore allows you to have two classes of Viewer, one who can save and one that cannot.
    I hope this helps
    Regards
    Micahael Armstrong-Smith

  • How can I see the dates of all of my app downloads (free and paid) from the iPhone? If this is not possible, from the computer? Is there an apple website for this?

    I would like to know how I can check the download dates of all of my iPhone 4 apps from the phone itself, the free apps downloaded too. Is there a website I could go to to see these?
    If not, how can you see this on a PC?

    View Purchase History
    http://support.apple.com/kb/HT2727

  • Can't see the date on desktop !!!

    hello.
    is just a question : how can i do to see the clock and the DATE on the desktop like on 10.4 ???
    thanks in advance...

    Are you talking about the calendar widget? If so, hit F12 to bring up the widget you have running. Next click the + sign at the bottom left corner. Scroll through the widgets and look for iCal and click it. I hope this helps.

  • Data blocks in forms 6i, can not see the data

    i have built an application in forms with some data blocks. the blocks a connect to some tables in the db. i have built them connectd as "system". but when i run the applicatio as user x i can do select, insert, update, delete, but i can not se the records in the datablocks (they are empty), but i can do all transactios. why?

    First of all, developing from the System schema is not a good idea.
    Who owns the tables your form is connecting to? The table owner should create a public synonym for each table name, and also needs to grant user x access to the table.

  • Can I see the date & time I last synced my iPod?

    I have misplaced my iPod, and I would like to see the last date and time that I connected it to my PC. Is there a way to do this?

    Larry - it appears you are confirming my suspicion; that this funcionality has been lost in iPhoto 11. Is there any way to make a feature request of Apple? I wonder why they took away this feature in the newer version?!?!

  • How can we see the data in dummy profitcenter

    Hi
         i have doubt about dummy profit center.how can we display the entries in dummy profit center.can any body tell me pls........
    regards
    prasad

    Hi Prasad,
    You can check the line items with transaction KE5Z.
    Regards,
    Abhisek

Maybe you are looking for

  • HOW CAN I GET AN INVOICE FOR ADOBE FORMS CENTRAL

    I work for a community college and we would like to have the annual subscription paid through the college, but we do everything by Purchase Order.  Is there a way to get this subscription paid for through an invoice?

  • Integration repository question

    Hi all, I have imported an RFC definition to the IR. I need to create a "message type" and "message interface" according to the RFC parameters. How can I do it in the easiest and fastest way ?

  • My airport is active but cannot be found by my MAC devices?

    Hi there, I have the following issue. My airport express is active and found by my router. It also shows a green light. Unfortunately all of my MAC devices can't find it. The airport config utility indicates that the airport device can't be found. Is

  • Loosing connections with ORA-12154

    Our scenario goes like this. We run transaction(1000's) fine for a while (hours!), then we get the following errors in sequence for short period of time(~2-5 minutes): <JDBC Pool> Sleeping in createResource() <JDBC Pool> Sleeping in createResource()

  • HT3964 MacBook fan is always on

    i can't fix my macbook MC374 problem with this guide... i reset my SMC but the fan is always on... any suggestions? i have Snow Leopard 10.6.3 on that and since i update it to latest version with about 8GB download from Software Update my problem is