Đang chuẩn bị liên kết để tải về tài liệu:
Java Database Programming Bible- P10

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Java Database Programming Bible- P10: 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 i8 Using Rowsets to Display Data when the RowSet.updateRow method is called. A RowSet is made updatable by setting its concurrency property to Resultset.coNCUR_uPDATABLE. Once you have an updatable RowSet you can insert a new row delete an existing row or modify one or more column values. Since requesting an updatable Rowset does not guarantee that you will actually get one you should check whether the Rowset is updatable by using RowSet.getconcurrency . Listing 18-3 illustrates the use of the rowSet.setConcurrency ResultSet.CONCUR_UPDATABLE method to make a RowSet updatable and the use of RowSet.getconcurrency to ensure that the RowSet actually is updatable. Listing 18-3 Making a RowSet updatable package JavaDatabaseBible.ch18 import java.sql. import com.inet.tds.JDBCRowSet public class JDBCUpdatableRowSet public static void main String argv String url jdbc inetdae7 localhost 1433 database LEDES String login jod . String password jod try Class.forName com.inet.tds.TdsDriver .newInstance JDBCRowSet rowSet new JDBCRowSet set url login and password rowSet.setUrl url rowSet.setUsername login rowSet.setPassword password make the rowset scrollable and updatable rowSet.setType ResultSet.TYPE_SCROLL_INSENSITIVE rowSet.setConcurrency ResultSet.CONCUR_UPDATABLE set the sql command rowSet.setCommand SELECT ID FName LName EMail FROM CONTACTS WHERE FName Ichabod execute the command rowSet.execute -451- Team-Fly Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Chapter i8 Using Rowsets to Display Data check whether the RowSet can be updated if rowSet.getConcurrency ResultSet.CONCUR_UPDATABLE System.out.println Rowset is UPDATABLE else System.out.println Rowset is READ_ONLY update the record and output it to the console while rowSet.next rowSet.updateString FName Igor rowSet.updateRow for int j 1 j rowSet.getMetaData .getColumnCount j System.out.print rowSet.getObject j t System.out.println rowSet.close catch Exception e e.printStackTrace .