• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Updateable ResultSet Help

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a code snippet of my problem, I basically traverse the whole ResultSet and check each value and replace them with a corrected value if I found any violating a fix set of rules, for simplicity sake in this example I test if the value is lowercase and change it to uppercase: (I'm using an Oracle 8i database)
Connection con = DriverManager.getConnection(url,
"myLogin", "myPassword");
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
String schema = "Schema1";
ResultSet rs = stmt.executeQuery("Select alias.* from " + schema + ".mytable alias");
ResultSetMetaData rsMeta = rs.getMetaData();
int count = rsMeta.getColumnCount();
boolean change;
while (rs.next()){
change = false;
for (int ctr = 1; ctr <= count; ++ ctr){
String temp = rs.getString(ctr);
if (!temp.equals(temp.toUpperCase())){
rs.updateString(ctr,
temp.toUpperCase());
change = true;
}
}
if (change == true) {
rs.updateRow(); // Update changes
}
}
We have two table setup one for testing and one for development, configured as different schemas but with table structures created similarly. I use the above mentioned code on the development table and it works nicely. However, when I tested it against the testing table (by changing schema variable), the application seems to hang at the rs.updateRow() call. What are the possible explanation for this and how do I resolve this?
Please help. Thanks in advance.
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic