Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

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.


advertisement
Configuring WebSphere with SQL Server
  1. 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.
  2. 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).
  3.  
    Figure 17. Creating a new JDBC provider.
     
    Figure 18. Specifying the database type.
     
    Figure 19. Settings for a new JDBC provider.
  4. 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.
  5. 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.
  6.  
    Figure 20. A new JDBC provider.
     
    Figure 21. Adding a J2C Authentication data entry.
     
    Figure 22. Adding a new datasource.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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).
  12.  
    Figure 23. Specifying the server name and port number.
     
    Figure 24. Setting the database name.
     
    Figure 25. Testing the datasource connection.
  13. 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.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap