Understanding J2EE Support
The following sections document how the Microsoft SQL Server 2005 JDBC Driver provides support for the J2EE and JDBC 3.0 optional API features. The source code examples provided in this Help system provide a good reference for getting started with these features.
First, make sure that your Java environment (JDK, JRE) includes the javax.sql package. This is a required package for any JDBC application that uses the optional API. JDK 1.4 and later versions already contain this package, so you do not have to install it separately.
The driver class name is com.microsoft.sqlserver.jdbc.SQLServerDriver. The driver is contained in the sqljdbc.jar file.
The class name is used whenever you load the driver with the JDBC DriverManager class. It is also used whenever you must specify the class name of the driver in any driver configuration. For example, configuring a data source within a J2EE application server might require that you enter the driver class name.
The JDBC driver provides support for J2EE / JDBC 3.0 data sources. The JDBC driver SQLServerXADataSource class is implemented by com.microsoft.sqlserver.jdbc.SQLServerXADataSource.
You can make database connections by using data sources. The data sources available with JDBC driver are described in the following table:
|DataSource Type||Class Name||Description|
The non pooling data source.
The data source to configure J2EE application server connection pools. Typically used when the application runs within a J2EE application server.
The data source to configure J2EE XA data sources. Typically used when the application runs within a J2EE application server and an XA transaction manager.
Data Source Properties
All data sources support the ability to set and get any property that is associated with the underlying driver's property set.
The following shows how an application connects by using a data source:
initialize JNDI .. Context ctx = new InitialContext(System.getProperties()); ... DataSource ds = (DataSource) ctx.lookup("MyDataSource"); Connection c = ds.getConnection("user", "pwd");
For more information about the data source properties, see Setting the Data Source Properties.