J2EE and SQL Server: Making a JDBC Connection : Page 4
Using a SQL Server back end with a Java application server may sound like an unnatural proposition but there's no need to bow to such arbitrary limitations. In this article you'll get step-by-step instructions on making a JDBC connection between the four most popular Java application servers and Microsoft SQL Server.
by Deepak Vohra
Feb 6, 2007
Page 4 of 5
Configuring WebSphere with SQL Server
Once installed you'll need to launch WebSphere Admin server and the administration console as the JDBC connection is configured in the WebSphere administration console.
Access the administration console with the URL http://localhost:9060/ibm/console. Specify user ID as websphere and click on Log In. Select the Resources>JDBC Providers node in the administration console. Select the server scope as Server=server1 and click on the New button to configure a new JDBC provider (see Figure 17).
In the Configuration dialog select SQL Server as the database type as shown in Figure 18. Select the provider type Websphere embedded ConnectJDBC driver for MS SQL Server. Next select the Implementation type Connection pool data source and click Next.
In the row for the Implementation class name com.ibm.websphere.jdbcx.sqlserver.SQLServerDataSource gets specified, as shown in Figure 19; this is the SQL Server 2000 and SQL Server 2005 data source class. Click on Finish.
This will configure the JDBC Provider and add it to the JDBC Providers table as shown in Figure 20. Save the settings in the Master configuration with the Save link.
The next step is to configure a JDBC datasource to use with SQL Server. This requires a J2EE Connection (J2C) Authentication data entry, which specifies the login credentials for SQL Server. Select the Security>Secure administration, applications, and Infrastructure node in the administration console. Select the Authentication>JASS Configuration>J2C Authentication data link (see Figure 21), and click on the New button to add a data entry.
On the next page specify an alias for the data entry and provide the userid (sa) and password to login to the SQL Server database. Click on the Apply button. Click on the OK button to create the entry then be sure to hit the Save link.
Now that you've created a JDBC Provider, you need create a WebSphere data source in order to enable it for use. Select Resources>JDBC Providers and select the link for the JDBC Provider you created above. Select the Additional Properties>Data Sources link and in the table of data sources click on the New button to configure a new data source as shown in Figure 22.
In the window that follows specify a data source name and a JNDI name for the data source. In the Component-managed authentication alias field select the J2C authentication data entry you already configured. Click on Next.
Finally, in the Create a data source frame, specify the database name as NA, the Server name as localhost and the Port number as 1433 or the port number for SQL Server 2005 (see the sidebar "Obtaining the Port Values") and click Next to add the data source (see Figure 23).
Figure 23. Specifying the server name and port number.
Save the data source configuration to the Master configuration with the Save link. Select the datasource link in the Data sources page. Previously, the database name was specified as NA; now, set the Database Name field to empty and click on Apply (see Figure 24).
To test the data source select its checkbox and click on the Test connection button as shown in Figure 25.
If the JDBC connection is properly established you will see the following message:
Test connection for data source WebSphere embedded ConnectJDBC for SQL Server DataSource on server server1 at node d207-6-39-2Node01 was successful.