Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8400699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:37:33+00:00 2026-06-09T21:37:33+00:00

I’m trying to throw together a quick JDBC app using Postgres as the DB

  • 0

I’m trying to throw together a quick JDBC app using Postgres as the DB and am running into an interesting issue.

I currently have 2 tables, table1 and table2.

CREATE TABLE table1
(
      a character varying NOT NULL,
      b integer NOT NULL,
      CONSTRAINT table1_pkey PRIMARY KEY (b)
)

CREATE TABLE table2
(
      c character varying NOT NULL,
      d integer,
      CONSTRAINT table2_pkey PRIMARY KEY (c),
      CONSTRAINT table2_d_fkey FOREIGN KEY (d),
          REFERENCES table1(b) MATCH SIMPLE
          ON UPDATE CSCADE ON DELETE CASCADE
)

As the backend of my program I’m SELECTing * and holding on to the ResultSet from my query. Each table has 1 row of simple values in it, doesn’t seem to matter what they are.

My statement is created with the flags ResultSet.TYPE_SCROLL_INSENSITIVE and ResultSet.CONCUR_UPDATE. Although I have tried SCROLL_SENSITIVE as well.

If I try the following (assumgin ResultSet rs/rs2 are valid and point to table1/table2 respectively:

rs.first(); // move to the first row (only row)
rs.updateInt(2, 50); // update our primary key, which is also the cascading fk
                     // 50 could be any number
print(rs); // Will show the old value
rs.updateRow();
print(rs);  // Will show the new value

rs2.refreshRow(); // make sure we get the latest data from table2
print(rs2); // will show the old data?

I was hoping to see the new values due to the cascade. If I quit and re-run the app, not changing any input, then it will print the correct table2 values. I’m guessing this is due to re-running the SELECT statement. If I look at the table by running psql or pgadmin3, the values seem like they’re changing. So it seems like refreshRow() isn’t bringing down the latest stuff. Would anyone have any idea why?

I’m using:

  • java 1.6_29
  • postgresql-9.1-901.jdbc4.jar

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:37:35+00:00Added an answer on June 9, 2026 at 9:37 pm

    I hope you got it sorted out since it’s an old question but just for the record I post here a snippet that I tried and which is working for me:

    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery("SELECT * FROM table1");
    
    Statement stmt2 = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs2 = stmt2.executeQuery("SELECT * FROM table2");
    
    rs.first(); // move to the first row (only row)
    rs.updateInt(2, 50); // update our primary key, which is also the
                                // cascading fk 50 could be any number
    System.out.println(rs.getString(2)); // Prints the old value 12
    rs.updateRow();
    System.out.println(rs.getString(2)); // Prints the new value 50
    
    rs2.first();
    rs2.refreshRow(); // make sure we get the latest data from table2
    System.out.println(rs2.getString(2)); // Prints the new value 50
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.