Java Database Programming Bible- P7

Java Database Programming Bible- P7: 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 i0 Building a Client Server Application catch SQLException e reportException e return typevector The method getTableTypes returns a ResultSet containing a single String column per row identifying the table type. Typically these types are as follows TABLE VIEW SYSTEM TABLE Using this table-type information you can get the actual table names using the getTables method. An example is shown in Listing 10-5. Listing 10-5 Retrieving tables public Vector getTables String types Vector tablevector new Vector try Connection con url userName password DatabaseMetaData dbmd ResultSet rs null null types ResultSetMetaData md int nColumns while y TABLE_NAME catch SQLException e reportException e return tableVector The code to get the table names is similar to that used to get the table types. The most significant difference is in the argument list for the getTables method. Since these types of arguments are fairly common when using metadata methods it is worth discussing them in some detail. The getTables method takes these four arguments getTables String catalog String schemaPattern String tableNamePattern String types Here are explanations of each argument -300- Team-Fly Please purchase PDF Split-Merge on to remove this watermark. Chapter i0 Building a Client Server Application Catalog a pair of double quotes retrieves tables without a catalog and null retrieves all tables. SchemaPattern a pair of double quotes retrieves tables without a schema and null retrieves all tables. TableNamePattern This is a table-name pattern similar to the argument used with SQL LIKE . The matches any substring of 0 or more characters and _ matches any one character. Types an array of table types to include null returns all types. The getTables method returns a ResultSet containing descriptions of the tables available in a catalog. The result

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
Đã 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.