Archive for November, 2006

JDBC and Connector/J 22 JDBC Support (Adult webspace) within 3.0.1

Thursday, November 30th, 2006

JDBC and Connector/J 22 JDBC Support within 3.0.1 As we mentioned earlier, the Connector/J JDBC driver is able to support only those features of the specification that the underlying MySQL database supports. Instead of explaining what is supported from the specification, we document here what currently is not supported. From a class standpoint, the following classes have some functionality not supported: Blob Clob Connection PreparedStatement ResultSet UpdatableResultSet CallableStatement Next we list each of the major interfaces with the individual methods not supported in the current version. As the MySQL database begins to support the underlying functionality needed for each of the classes and methods, the list will get shorter. For example, stored procedures are planned for a future release of the database and thus the CallableResultSet interface could then be implemented. Blob Blob.setBinaryStream() Blob.setBytes() Blob.truncate() Clob setAsciiStream() setCharacterStream() setString() truncate() Connection Connection.setSavePoint() Connection.setTypeMap() Connection.getTypeMap()
Quick Hint: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

Understanding Connector/J 21 Figure (J2ee web hosting) 2.7 shows how the

Wednesday, November 29th, 2006

Understanding Connector/J 21 Figure 2.7 shows how the RowSet classes are constructed from the base Result and ResultSetMetaData classes. ResultSet Rowset RowsetEvent Rowsetinternal RowsetMetaData RowsetWriter RowsetListener RowsetReader creates Figure 2.7 RowSet classes. Understanding Connector/J Up to this point, our discussion has centered on the general JDBC specification and its related interfaces and classes. In this section, we turn our attention to MySQL s JDBC driver, Connector/J. At the time of this writing, there are two versions of the driver: 2.0.14 and 3.0.1. The drivers can be found at www.mysql.com/downloads/api-jdbc-stable.html and www.mysql.com/downloads/api-jdbc-dev.html, respectively. The Connector/J driver started as MM.MySQL (written by Mark Matthews) and has been the primary JDBC driver for MySQL. During 2002, Mark joined the MySQL team and subsequently updated the driver and renamed it to Connector/J. The 2.0.14 version is basically the last MM.MySQL version made available on the mmmysql.sourceforge.net Web site. The 3.0.1 version contains numerous changes to the original code. These features will be discussed shortly. Connector/J is designed specifically for MySQL and attempts to adhere to the JDBC API as much as possible. However, in order for a driver to adhere to the full JDBC specification, the underlying database must support all of the features supported in the latest 3.0 version. For MySQL and Connector/J, strict adherence is impossible because MySQL currently doesn t support stored procedures, savepoints, references, and various other small pieces of functionality. These differences with the specification are noted in Appendix C. For the remainder of this blog, we use the latest 3.0 version of Connector/J.
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services

J D BC and Connector/ J 20 javax.sql.XADataSource: (Web hosting and file sharing)

Tuesday, November 28th, 2006

J D BC and Connector/ J 20 javax.sql.XADataSource: The XADataSource interface is an internal fac tory for DataSource connections using JNDI. The classes and interfaces within the Optional API are linked together, as shown in Figures 2.5, 2.6, 2.7, and 2.8, which are referenced within the version 3.0 specification. Figure 2.5 shows the relationship between the DataSource and Connection classes. The DataSource doesn t act on its own, but instead must obtain a connection to the database through the Connection class. javax.sql.DataSource Instantiates a java.sql.Connection Figure 2.5 DataSource/Connection classes. Figure 2.6 shows how a PooledConnection class will also use the Connection class to obtain a link to the database. Note the ConnectionEventListener associated with PooledConnection. Any events created by PooledConnection will be sent to those objects that register with the ConnectionEventListener. ConnectionPoolDataSource getConnection throws javax.sql.Connection ConnectionEvent javax.sql.PooledConnection ConnectionEventListener Instantiates 1+ Figure 2.6 PooledConnection/Connection classes.

Hint: If you are looking for very good and affordable webspace to host and run your tomcat hosting application check Virtualwebstudio tomcat web hosting provider

Examining the JDBC Interface 19 javax.sql.ConnectionEvent: The ConnectionEvent (Hsphere web hosting)

Monday, November 27th, 2006

Examining the JDBC Interface 19 javax.sql.ConnectionEvent: The ConnectionEvent class is used to signal a closed pooled connection and an error. javax.sql.ConnectionEventListener: The ConnectionEventListener interface is used by applications that want to be notified when a Pooled- Connection object generates an event. javax.sql.ConnectionPoolDataSource: The ConnectionPoolDataSource is a factor for PooledConnection objects. The object implementing the interface can be registered using Java Naming and Directory Interface (JNDI). javax.sql.DataSource: The DataSource is a factory for connections. The object implementing the interface can be registered using JNDI. javax.sql.PooledConnection: The PooledConnection interface provides a connection to the database, but is part of a larger pool. The application developer doesn t use the interface directly. javax.sql.RowSet: The RowSet is a JavaBeans component that is created and configured at design time and executed at runtime. The RowSet can be configured to connect to a JDBC source and to read data. javax.sql.RowSetEvent: The RowSetEvent is created when a single row in a RowSet is changed, the internal cursor moves to a different location, or the entire RowSet has changed. javax.sql.RowSetInternal: The RowSetInternal interface is implemented to allow the RowSetReader and RowSetWriter objects access to the internals of a RowSet. javax.sql.RowSetListener: The RowSetListener interface is implemented by a component that wants to be notified when an event occurs in a RowSet object. The component calls the addRowSetListener() method of the RowSet in which it is interested. javax.sql.RowSetMetaData: The RowSetMetaData interface provides information about a RowSet. The information centers around the columns returned from a result. javax.sql.RowSetReader: The RowSetReader interface is used by a RowSet to obtain results from the database. javax.sql.RowSetWriter: The RowSetWriter interface is used to write changed data back to the database. javax.sql.XAConnection: The XAConnection interface allows a connection to handle distributed transactions.
Quick Hint: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

JDBC and Connector/J 18 java.sql.Statement: The Statement (Private jvm hosting) interface

Sunday, November 26th, 2006

JDBC and Connector/J 18 java.sql.Statement: The Statement interface is probably one of the most important interfaces in the JDBC specification. All SQL statements are exe cuted through a Statement object. Each Statement object returns single ResultSet objects. java.sql.Struct: The Struct interface is a mapping from a SQL structured type to the Java language. java.sql.Time: The Time class is a wrapper around java.util.Date to sup port the mapping from SQL TIME to Java. java.sql.Timestamp: The Timestamp class is a wrapper around java.util.Date to support the mapping from SQL TIMESTAMP to Java. java.sql.Types: The Types class is an internal class used to identify generic SQL types or JDBC types. The classes and interfaces within the Core API are linked together, as shown in Figure 2.4. There is a natural progression from a Connection object to a Result- Set. The path from one to the other occurs using a Statement, PreparedStatement, or CallableStatement; and the Statement class is a parent to both of the others. All of the Statement classes will eventually execute SQL to produce a ResultSet. ResultSet Connection DataTypes Statement Prepared Statement Callable Statement createStatement executeQuery Figure 2.4 JDBC Core API class/interface links. The javax.sql Package The Optional API within the JDBC specification is implemented within the javax.sql package. The classes and interfaces are as follows:
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check Actions tomcat hosting services

Examining the JDBC Interface 17 java.sql.DriverPropertyInfo: (Web hosting linux) The DriverPropertyInfo

Sunday, November 26th, 2006

Examining the JDBC Interface 17 java.sql.DriverPropertyInfo: The DriverPropertyInfo class provides information for advanced developers who need to set specific properties for loading a Driver object. java.sql.ParameterMetaData: The ParameterMetaData interface provides information about the parameters in a PreparedStatement object. java.sql.PreparedStatement: The PreparedStatement interface provides an object for executing precompiled SQL statements against the connected database. java.sql.Ref: The Ref interface is a mapping between Java and an SQL REF value. A REF value is a reference to an SQL structured type value. java.sql.ResultSet: A ResultSet interface is designed to represent a Result- Set produced from a query of the database. An internal cursor points to the current row of data, and it can be pointed before and after the data. Meth ods are used to move the cursor to different rows in the ResultSet. By default, the ResultSet isn’t updatable, but can be made both scrollable and updatable. java.sql.ResultSetMetaData: The ResultSetMetaData interface is used to return specific information about the data within a ResultSet object. The information could include the number of columns, column names, float col umn precision, and total column size, among other data. java.sql.Savepoint: The Savepoint interface is used along with transac tions to provide rollback points. This allows for the completion of large transactions even when an error occurs. java.sql.SQLData: The SQLData interface is used to map the SQL user- defined type to the Java language. java.sql.SQLException: The SQLException exception will be thrown when an error occurs during an attempt to access a database or when the database itself returns an error. java.sql.SQLInput: The SQLInput interface is used by the developer of a JDBC driver to stream values from the database results. The interface isn t designed to be instantiated by the application developer. java.sql.SQLOutput: The SQLOutput interface is used by the developer of a JDBC driver to stream data to the database. The interface isn t designed to be instantiated by the application developer. java.sql.SQLPermission: The SQLPermission interface is designed to allow the driver to determine its permission when an applet calls the Driver- Manager.setLogWriter or setLogStream methods. java.sql.SQLWarning: The SQLWarning interface is used to return any database access warnings from the database. Warnings are available in the Connection, Statement, and ResultSet objects.

Hint: This post is supported by Gama web hosting hrvatska services

JDBC and Connector/J 16 in version (Earthlink web hosting) 3.0 of

Sunday, November 26th, 2006

JDBC and Connector/J 16 in version 3.0 of the specification are shown in italics. The full Javadoc can be found at http://java.sun.com/j2se/1.4/docs/api/java/sql/package-summary.html. java.sql.Array: The Array interface is a mapping between the Java language and the SQL ARRAY type. The interface includes methods for bringing an ARRAY value to a client as a Java array or in a ResultSet. java.sql.BatchUpdateException: The BatchUpdateException is thrown when a batch update operation has failed. The exception includes all of the successful update commands that executed before the failure. java.sql.Blob: The Blob Java interface is a mapping to the SQL BLOB value. java.sql.CallableStatement: The CallableStatement interface is used to execute stored procedures if supported on the database. Parameters are allowed with the interface as well as escape syntax. java.sql.Clob: Clob is a mapping from the Java programming language to the SQL CLOB type. A CLOB is a Character Large Object. java.sql.Connection: The Connection interface provides a method for cre ating a connection to a specific database. All SQL is executed in the context of a Connection object. java.sql.DataTruncation: The DataTruncaction exception is thrown when data will be truncated. On a write, the exception is an error, but on a read, the exception is a warning. java.sql.DatabaseMetaData: The DatabaseMetaData interface is designed to provide information about the remote database that a connection has been made to previously. The information available to the DatabaseMeta- Data object will be different based on the database vendor and the informa tion it wants to provide. java.sql.Date: The Date class is a wrapper for JDBC to use as a map to the SQL DATE value. The value of Date is the number of milliseconds since Jan uary 1, 1970, 00:00:00:000 GMT. A thin wrapper around a millisecond value that allows JDBC to identify this as an SQL DATE value. A milliseconds value represents the number of mil liseconds that have passed since January 1, 1970, 00:00:00.000 GMT. java.sql.Driver: The Driver interface is implemented by all vendor drivers so that they can be loaded by a static class called DriverManager. The Dri ver object will automatically create an instance of itself and register with DriverManager. java.sql.DriverManager: The DriverManager class is used to manage all Driver objects.
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services

Examining the JDBC (Subdomain web hosting) Interface 15 A developer can

Saturday, November 25th, 2006

Examining the JDBC Interface 15 A developer can also work with standardization by using metadata supplied from the database. Many times, a database will return information in the form of metadata, indicating whether it supports specific features. Examining the JDBC Interface Now that we know what JDBC is, where it came from, and its place in a typical system, let s turn our attention to the interfaces used to create the driver. Figure 2.3 shows how all of the core interfaces in the specification are designed to work together. Statement Prepared Statement Callable Statement ResultSet ResultSetResultSet Connection DriverManager Connector/J MySQL Figure 2.3 The Core JDBC API structure. As we mentioned earlier, the specification is broken up into two different packages: the Core API and the Optional API. The Core API is implemented in the java.sql package. In this section, we look at the interfaces available in the specification (although we don t indicate here whether Connector/J supports the functionality that can be found in Appendix C). The java.sql Package You can find this information both in Appendix C and in the section Understanding Connector/J later in this chapter. The interfaces specifically defined
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check Actions tomcat hosting services

JDBC and Connector/J 14 In a Type 1 (J2ee web hosting)

Saturday, November 25th, 2006

JDBC and Connector/J 14 In a Type 1 driver, a JDBC bridge is used to access ODBC drivers installed on each client machine. (This is the JDBC-ODBC Bridge we discussed earlier.) From the standpoint of Java, this is merely a stopgap solution until a Java-based JDBC driver can be obtained. In a Type 2 driver, JDBC API calls are converted and supplied to a vendor- specific driver. Used in the same manner as the JDBC-ODBC Bridge, the vendor-specific driver must be installed on each client machine. These drivers suffer the same problems found in a bridge situation. In a Type 3 driver, a pure Java-based driver translates API calls into a DBMS- independent network protocol, which is further translated by a server to a vendor-specific protocol. In a Type 4 driver, a pure Java-based driver translates API calls directly into the protocol needed by a vendor s database. This is the highest performance driver available for the database and is usually provided by the vendor itself. MySQL s Connector/J driver is a Type 4 driver. SQL Standards The standardization of access to a database has been a hot topic in recent years. The standard is called Structured Query Language, or SQL. Although the idea of a standard is appealing, not all database vendors follow the standard, and some cannot because of the feature set of the database itself. SQL92 used to be the defining specification for SQL, but recently a new standard called SQL99 has been adopted. The JDBC version 3.0 specification is designed to support SQL99. When working with different database systems through JDBC, you can be relatively sure that basic functionality like SELECT, INSERT, UPDATE, and DELETE will work without much change. Beyond the basics, though, getting SQL working from one database to another requires some effort on your part. By far the most important issue facing standardization is data typing. As you have probably already experienced in your development history, data types between C, C++, Java, PHP, and others can be quite different, especially in the area of data and time. Combine these differences with the various data types that can be stored in a database and you have the makings of a problem. In Chapter 7, MySQL Type Mapping, we cover the JDBC data types and how they are represented in MySQL and subsequently with a Java application. Another issue facing standardization is the use of quotes within SQL statements. JDBC attempts to handle this by using escaping and by requiring vendors to implement the escaping as appropriate for their databases.
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services

JDBC Versions 13 JDBC Versions Throughout the history (Web hosting macintosh)

Saturday, November 25th, 2006

JDBC Versions 13 JDBC Versions Throughout the history of JDBC, Sun has introduced several different versions, beginning with version 1.0 in January of 1997. This initial specification defined the interfaces necessary to create an instance of the driver in a Java application, building SQL statements to execute against the underlying database, return results through a ResultSet object, and obtain various pieces of metadata about the database as well as the ResultSet. Next, the 2.0/2.1 specification was released; this broke the original 1.0 specification into two parts. The Core API for 2.0 didn t add much to the original 1.0 specification but instead concentrated on performance and SQL 99 data types. The added functionality included programmatic SQL statements, scrollable ResultSets, streams, and other small updates. The second part of the 2.0/2.1 specification is called the JDBC 2.0 Optional Package. This package includes interfaces for data source interfaces, connection pooling, distributed transactions, and RowSets. Recently, version 3.0 of the JDBC specification was released. Supported in the 1.4.x version of Java, the new specification includes many enhancements to ResultSets, data types, connection pools, and basic SQL statements. New functionality includes savepoint support (for checkpointing within transactions) and support for ParameterMetaData. You can find a complete discussion of the 3.0 specification at http://java.sun.com/products/jdbc/download.html#corespec30. In the section JDBC Support within 3.0.1 later in this chapter, we provide a complete overview of MySQL Connector/J s support of the functionality found in the specification. Appendix C, JDBC API and Connector/J also contains a detailed review of the complete specification and Connector/J support. JDBC Driver Types This section discusses the basic programming model of the JDBC driver itself. There are four different ways a JDBC driver can be created by vendors to support their database: Type 1: JDBC-ODBC Bridge Type 2: Native-API partly Java Type 3: JDBC-Net pure Java Type 4: Native-protocol pure Java
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services