Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet object is always read only with sprinta2000

 
Siddhartha Asthana
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am using sprinta2000.jar to connect to MS SQL Server 2000. The code i am using is as follows :
Class.forName("com.inet.tds.TdsDriver");
Connection con = DriverManager.getConnection("jdbc:inetdae7:walnut:1433?database=asthana" , "siddhartha" , "siddhartha");
DatabaseMetaData data = con.getMetaData();
PreparedStatement pst = con.prepareStatement("Select * from experiment " , ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE );
pst.executeUpdate();
ResultSet rs = pst.getResultSet();
rs.moveToCurrentRow();
System.out.println(" result set cursor name " + rs.getCursorName());
rs.updateString("LastName" , "anything");
rs.updateRow();
the error i am getting is java.sql.SQLException: [TDS Driver]ResultSet is read only.
Can any body let me know where i am going wrong?

Thanx in advance
 
Jacob George
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In u'r code snippet, please replace

with

Now, please check whether the row is being updated as required.
 
Siddhartha Asthana
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did that. The error changed to :
java.sql.SQLException: [WALNUT]The cursor is READ ONLY
where WALNUT is the hostname of the m/c where my SQL server is installed.
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to the JDBC forum. Please continue the discussion there.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with your specific driver, but would like to point out that not all drivers necessarily support updateable result sets (and those that do, will not support them on all queries; you query is simple enough not to be a problem however). Rather than throwing an exception, such a driver will give you the type of ResultSet it supports that comes closest to what you're asking for -- for example, a simple read-only result set.
So the question is: did you verify in the driver documentation that it does support updateable result sets?
- Peter
 
Siddhartha Asthana
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter
The documentaion does say that the updatable resultset is supported
http://www.inetsoftware.de/English/Produkte/JDBC2/readme.txt
however...it also mentions that if a perticuler query is not supported by the databse then i might get a readonly resultset.
But as u mentioned my query is simple enough not to pose any problem....dont know where i am going wrong
 
Jacob George
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try this code snippet instead; this will work (atleast it works in my machine)

The changes I made are,
1) Usage of ResultSet.TYPE_SCROLL_SENSITIVE+1 instead. Please don't ask me why I did it. I have heard that some drivers got this problem(not sure whether its a problem. This should be in their docs)
2) You have to scroll/position the ResultSet before updating the data.
I have noticed that for the new Sprinta2000 driver, "select" won't work inside executeUpdate(). May be you have an older version.
regards Jacob
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic