I l @ ve RuBoard |
Using CursorsAnother way to update or delete data is to use a cursor. While looping through the results of a query, you can modify, delete, or add records, but only if you set up the statement the right way. By default, when you execute a query, it's run in a kind of "read-only" mode. You can step through the values using the next () method on the record set, but that's it. If the code hands an extra pair of arguments to createConnection or prepareStatement , you can create a ResultSet that can move back and forth inside the query, as well as update and append to. Unfortunately, as of the current release of the MySQL JDBC driver, this is a not-ready-for-prime-time feature. Luckily, most of the time you are better off doing an explicit insert or update anyway because code that iterates through the rows with cursors is likely to be less efficient and harder to understand. |
I l @ ve RuBoard |