aspose file tools*
The moose likes JDBC and the fly likes ResultSet object is always read only with sprinta2000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet object is always read only with sprinta2000" Watch "ResultSet object is always read only with sprinta2000" New topic
Author

ResultSet object is always read only with sprinta2000

Siddhartha Asthana
Greenhorn

Joined: May 05, 2003
Posts: 3
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

Joined: Jun 26, 2001
Posts: 46
Hi,
In u'r code snippet, please replace

with

Now, please check whether the row is being updated as required.
Siddhartha Asthana
Greenhorn

Joined: May 05, 2003
Posts: 3
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

Joined: Nov 09, 2000
Posts: 6450
I'm moving this to the JDBC forum. Please continue the discussion there.
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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

Joined: May 05, 2003
Posts: 3
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

Joined: Jun 26, 2001
Posts: 46
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet object is always read only with sprinta2000