Login | Register   
LinkedIn
Google+
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 3

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 JBoss with SQL Server
  1. Assuming you've already downloaded and unzipped JBoss 4.0, the first step is to add the SQL Server JDBC driver JAR files to the classpath of the server. For SQL Server 2000, copy msbase.jar, mssqlserver.jar, and msutil.jar to the <JBoss>/server/default/lib directory. For SQL Server 2005 Express, copy the sqljdbc.jar file to the lib directory. <JBoss> is the directory in which the JBoss server is installed.
  2. Copy the MS SQL Server datasource file <JBoss>\docs\examples\jca\mssql-ds.xml to the <JBoss>\server\default\deploy directory.
  3. In the mssql-ds.xml datasource file specify the JDBC driver class in the <driver-class/> element as com.microsoft.jdbc.sqlserver.SQLServerDriver for SQL Server 2000, and com.microsoft.sqlserver.jdbc.SQLServerDriver for SQL Server 2005 Express. <li>Specify the connection URL in the <connection-url/> element using the URL specified in the sidebar "Obtaining the Port Values."
  4. Specify the username as sa and password as the SQL Server password. In the <jndi-name/> field specify a JNDI name for the datasource.
  5. Next, modify the <JBoss>server\default\conf\login-config.xml configuration file by adding the following <application-policy/> element to login-config.xml:

    <application-policy name = "MSSQLDbRealm"> <authentication> <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required"> <module-option name = "principal"></module-option> <module-option name = "userName">sa</module-option> <module-option name = "password"></module-option> <module-option name ="managedConnectionFactoryName"> jboss.jca:service=LocalTxCM,name=MSSQLDS </module-option> </login-module> </authentication> </application-policy>

    This will configure JBoss to work with SQL Server.

    If you want to develop an entity EJB, you also have to modify the <JBoss>\server\default\conf\standardjbosscmp-jdbc.xml configuration file. To configure the standardjbosscmp-jdbc.xml with the SQL Server database modify the <datasource/> and <datasource-mapping/> elements as shown:



    <jbosscmp-jdbc> <defaults> <datasource>java:/ MSSQLDS</datasource> <datasource-mapping> MS SQLSERVER2000</datasource-mapping> </defaults> </jbosscmp-jdbc>



Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap