This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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
Joined: May 05, 2003
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
Joined: Jun 26, 2001
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