TAILIEUCHUNG - Java Database Programming Bible- P4

Java Database Programming Bible- P4: Welcome to Java Database Programming Bible. This book is for readers who are already familiar with Java, and who want to know more about working with databases. The JDBC Application Programming Interface has made database programming an important aspect of Java development, particularly where Web applications are concerned. | Chapter 4 Introduction to JDBC 2. Set a new value for each column in the row by using the appropriate update method. 3. Call the method insertRowO to insert the new row into the result set and simultaneously into the database. Listing 4-9 demonstrates the use of the UpdatableResultSet to insert a new row into a database. Listing 4-9 Using UpdatableResultSet to insert a new row Connection con jdbc odbc Contacts Statement stmt ResultSet rs query Contact_ID 150 First_Name Nigel Last_Name Thornebury If you insert a row without supplying a value for every column in the row the default value for the column will be used if there is one. Otherwise if the column accepts SQL NULL values a NULL will be inserted. Failing either of those a SQLException will be thrown. You will also get a SQLException if a required table column is missing in the ResultSet you use to insert the row so the query used to get the ResultSet object should generally select all columns though you will probably want to use a WHERE clause to limit the number of rows returned by your SELECT statement. Caution If you move the cursor from the insert row before calling the method insertRow you will lose all of the values you have added to the insert row. To move the cursor from the insert row back to the result set you can use any of the methods that put the cursor on a specific row first last beforeFirst afterLast and absolute. You can also use the methods previous and relative because the result set maintains a record of the current row while accessing the insert row. In addition you can use a special method moveToCurrentRow which can be called only when the cursor is on the insert row. This method moves the cursor from the insert row back to the row that was .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.