Behavior question about updateable resultsets...
- From: devansh.dhutia@xxxxxxxxx
- Date: 1 Oct 2005 10:39:21 -0700
I have a question regarding a certain behavior of updateable
resultsets. If I update a column using any of the updateXXX methods and
then try to use the getXXX methods from the same column to see if it
updated the results locally and not on the server, I get the same old
value. I have to call updateRow() but that updates the underlying
database and still gives me the old value until I execute the same
query again and get a new resultset. Maybe the code below will clarify
my question more..
Connection con = null;
Statement stmt;
ResultSet rst;
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println("Getting connection.");
con = DriverManager.getConnection(url);
System.out.println("Connection successful.");
String st = "select age,sname,snum FROM student;";
stmt =
con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rst = stmt.executeQuery(st);
rst.last();
System.out.print(rst.getInt(1)+" ");
System.out.print(rst.getString(2)+" ");
System.out.print(rst.getLong(3)+"\n");
rst.updateInt(1,23);
rst.updateRow();
System.out.print(rst.getInt(1)+" ");
System.out.print(rst.getString(2)+" ");
System.out.print(rst.getLong(3)+"\n");
The output is:
Getting connection.
Connection successful.
25 Edward Baker 578875478
25 Edward Baker 578875478
If I were the run the same code again, I get:
Getting connection.
Connection successful.
23 Edward Baker 578875478
23 Edward Baker 578875478
Any/all help is appreciated
Thanks
Devansh Dhutia
University of Iowa
.
- Follow-Ups:
- Re: Behavior question about updateable resultsets...
- From: Angel Saenz-Badillos[MS]
- Re: Behavior question about updateable resultsets...
- Prev by Date: Re: Bug in JDBC SQL extensions parser of the Beta SQLServer driver
- Next by Date: Re: Behavior question about updateable resultsets...
- Previous by thread: Re: Bug in JDBC SQL extensions parser of the Beta SQLServer driver
- Next by thread: Re: Behavior question about updateable resultsets...
- Index(es):
Relevant Pages
|
Loading