Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSSQLServer driver, cursor not updatable

Status
Not open for further replies.

sagn

Programmer
Jun 7, 2001
166
US
OK.. I have downloaded a jdbc driver from MS. version 1.4.
I create a statement as

con.createStatement
(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);

when I try to execute updateRow(), I get an exception saying the cursor is not updatable.

IF I use ResultSet.Type_FORWARD_ONLY, however, I can update.
Why?
thanks

Here is the test code, such as it is.

public static void main(String[] args) {
int i;
SQLWarning sqlwarning;
String url;

try {
Class.forName ("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch (Exception e){
i = 0;
}

url = "jdbc:sqlserver://servername;";

try {
Connection con = DriverManager.getConnection(url,user,password);
Statement stmt =
con.createStatement
(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);


ResultSet uprs = stmt.executeQuery("SELECT c1,c2,c3 FROM table where id='x'");
sqlwarning= uprs.getWarnings();
uprs.next();

uprs.updateString("c3", "beta");
uprs.updateRow();

}
catch (SQLException se){
i=0;
}
}
 
Oh sorry but the exact exception message is

Cursor is Read Only.

thanks
 
I think I found the trouble. The Table whose data populate the recordset must have a primary key.

Now on to see if I can now multiple concurrent statements and record sets with this driver.


I am sure I'll be back. :)
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top