tailieunhanh - My SQL and Java Developer’s Guide phần 6
thông tin được lưu trữ trong một bảng cơ sở dữ liệu là không phải lúc nào cũng tất cả mọi thứ bạn cần khi phát triển một ứng dụng. Nếu bạn đang viết một servlet sẽ được sử dụng để quản trị từ xa cơ sở dữ liệu, bạn có thể muốn biết về các tính năng cơ sở dữ liệu hiện tại, các cơ sở dữ liệu được định nghĩa, và các thông tin khác. | Using Metadata The information stored in a database table isn t always everything you need when developing an application. If you are writing a servlet that will be used to remotely administer the database you might like to know about current database features what databases are defined and other information. The JDBC specification and Connector J provide access to several methods that allow an application to access information about the database as well as information about a ResultSet object. In this chapter we cover some of the more common and useful methods found in the DatabaseMetaData object. For a complete listing refer to Appendix C. Many of the methods allow arguments for determining which databases and tables the methods should return information from. In these cases you can use the full string name of the table or you can use string patterns in which the character is used to match 0 or more characters and the underscore _ is used to match one character. Using Database Metadata Connector J provides information about the database server behind a connection by using the DatabaseMetaData object. This object is designed to provide information in five major areas General Source Information Feature Support 197 198 Using Metadata Data Source Limits SQL Objects Available Transaction Support The code in Listing provides a glimpse at some of the methods in each of these five areas. The current JDBC specification and Connector J implement hundreds of attributes and methods in the DatabaseMetaData object and we can t cover all of them here. See Appendix B to learn about all the attributes and methods. import . import . import . import . import . import import public class DatabaseInfo extends HttpServlet public void doGet HttpServletRequest inRequest HttpServletResponse outResponse throws ServletException IOException PrintWriter out null Connection .
đang nạp các trang xem trước