Java Data Access—JDBC, JNDI, and JAXP phần 4

Chương 6: Làm việc với kết quả Sets Xref Phụ lục C, "Xử lý lỗi JDBC," cung cấp thêm chi tiết về các ngoại lệ SQLWarning. Đối với kết quả của bạn được thiết lập để được updateable, truy vấn SQL phải đáp ứng các tiêu chí nhất định. | Chapter 6 Working with Result Sets Xref Appendix C JDBC Error Handling provides more details on the SQLWarning exception. For your result set to be updateable the SQL query must meet certain criteria. In general to create a updateable ResultSet object the query should adhere to the following rules If you intend to insert rows into a table then the SQL query must return the primary key s of the table. An error occurs if you try to insert a row without specifying values for the primary key s . However some DBMS can auto-generate primary keys such systems may allow this behavior. Be sure to check your driver or DBMS documentation for details. The SQL statement cannot use aggregation or sorting clauses such as GROUP BY or ORDER BY. You cannot update result sets created from SQL query statements that request data from multiple tables. Changes to these result sets would need to effect multiple tables and this is not possible in current versions of JDBC. The remainder of this section focuses on how to create and use updateable ResultSet objects. Creating updateable result sets You create updateable ResultSet objects with the same Connection object methods you use to create scrollable result sets. The following are the Connection object methods you use to create updateable ResultSet objects createStatement int resultSetType int resultsetconcurrency prepareStatement String sql int resultSetType int resultsetconcurrency prepareCall String sql int resultSetType int resultSetConcurrency You use the resultSetType parameter to specify scrollable result sets. Notice that you can create a forward-only result set that is also updateable. Also notice that you must supply a parameter even if you want a default result set object. The last section covered the resultSetType parameter and how to use it. The second parameter resultSetConcurrency defines the concurrency level you want the result set to have. This parameter has the following two options CONCUR_UPDATABLE which creates an .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
2    814    2    01-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.