Inquiry about JDBC, not supported ResultSet

I have got two questions related to the same bit of code:

CachedRowSet cachedRow = new CachedRowSetImpl();
cachedRow.setUrl("jdbc:mysql://localhost:3306/test");
cachedRow.setUsername("root");
cachedRow.setPassword("StackOverKindOfThing");
cachedRow.setCommand("SELECT * FROM books");
cachedRow.execute();
int [] arrayKey = {1};

//cachedRow.setKeyColumns(arrayKey); // I can even omit this line and it works anyway;
cachedRow.next();
cachedRow.updateString(2, "ball");
cachedRow.updateRow();  
cachedRow.acceptChanges();//it works with cachedRow.acceptChanges(con) where con
                          //has been initialized and has been set on setAutoCommit(false);

That's the exception I am getting by using a CachedRowSet set with .setUrl("url");

at CachedThingSet.main(CachedThingSet.java:31)
javax.sql.rowset.spi.SyncProviderException: Can't call commit when autocommit=true

1) I would like to know why I can insert data into the database even though the tutorial says it cannot be possible (the setKeyColumn() method is commented out):

Setting Key Columns

If you are going make any updates to the crs object and want those updates saved in the database, you must set one more piece of information: the key columns.

And why I have to set up a connection with autocommit(false) in order to use a CachedRowSet (updating a row) otherwise I get a SyncProviderException: can't call commit when autocommit=true Is there anyway I can set the connection got from setUrl("url"); without using acceptChanges(con) where con is another connection set with autocommit(false)

Answers


Need Your Help

Need help querying unused id's in relational table

mysql sql

I'm trying to query my database for unused listId's but can't quite seem to get the query syntax correct. Here is what I've tried:

Custom component creation - how to add small icon representing component in Tool Palette?

delphi icons delphi-2009 custom-component

Please bear in mind that I've read all the instructions I could find about adding component icon to my custom component. And I am able to do this when we talk about the icon size which is 24x24 pix...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.