This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

ResultSet object is always read only with sprinta2000

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm moving this to the JDBC forum. Please continue the discussion there.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic