Java学习笔记-JDBC 3 博客分类: Java学习笔记 JDBCJavaSQL
程序员文章站
2024-03-01 20:08:04
...
Scrollable Result Sets
Statement stat = conn.createStatement(type, concurrency);
PreparedStatement stat = conn.prepareStatement(command, type, concurrency);
Type Values
TYPE_FORWARD_ONLY | The result set is not scrollable (default). |
TYPE_SCROLL_INSENSITIVE | The result set is scrollable but not sensitive to database changes. |
TYPE_SCROLL_SENSITIVE | The result set is scrollable and sensitive to database changes. |
Concurrency Values
CONCUR_READ_ONLY | The result set cannot be used to update the database (default). |
CONCUR_UPDATABLE | The result set can be used to update the database. |
Updatable Result Sets
Statement stat = conn.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
The updateRow , insertRow , and deleteRow methods of the ResultSet class give you the same power as executing UPDATE , INSERT , and DELETE SQL statements.
String query = "SELECT * FROM Books"; ResultSet rs = stat.executeQuery(query); while (rs.next()) { if (. . .) { double increase = . . . double price = rs.getDouble("Price"); rs.updateDouble("Price", price + increase); rs.updateRow(); // make sure to call updateRow after updating fields } }
推荐阅读
-
Java学习笔记-JDBC 3 博客分类: Java学习笔记 JDBCJavaSQL
-
Java学习笔记-JDBC 1 博客分类: Java学习笔记 JDBCJavaMySQLSQLPostgreSQL
-
Java学习笔记-Class Loaders 博客分类: Java学习笔记 JavaEXTCC++C#
-
Java学习笔记-Class Loaders 博客分类: Java学习笔记 JavaEXTCC++C#
-
Nginx php upstream sent unexpected FastCGI record: 3 while reading response head 博客分类: Linux学习笔记web服务器技术MysqlPHP开发
-
Nginx php upstream sent unexpected FastCGI record: 3 while reading response head 博客分类: Linux学习笔记web服务器技术MysqlPHP开发
-
ActiveMQ学习笔记之四--启动嵌入式Broker(纯代码方式) 博客分类: java
-
学习JdbcProxy应用 博客分类: Java 应用服务器JDBC软件测试SQLMySQL
-
学习JdbcProxy应用 博客分类: Java 应用服务器JDBC软件测试SQLMySQL
-
JA-SIG(CAS)学习笔记3 博客分类: javaEE