[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Setup SQL server 2000 with Tomcat 5.x

Hello,

I am trying to setup a SQL server 2000 with tomcat 5.x to run a  webapp. Can anyone please tell me how to configure my server.xml, we.xml and installing SQL drivers in \lib folder of Tomcat.
I would love to have a straight forward xml snippet with directions and I will follow up on this thread if I have more doubts.

thanks,
Kanishk.
0
kanishkpanwar
Asked:
kanishkpanwar
  • 6
  • 2
1 Solution
 
KuldeepchaturvediCommented:
instead of server.xml. you should be creating a context file in conf /catalina/localhost it will look something like this

<Context path="/ACProspero" docBase="C:/Tomcat5.0/webapps/ACProspero" debug="0" reloadable="true" crossContext="true">
  <Resource name="jdbc/SQLServerSuppData" auth="Container" type="com.microsoft.jdbcx.sqlserver.SQLServerDataSource" />
 <ResourceParams name="jdbc/SQLServerSuppData">
 <parameter>
  <name>user</name>
  <value>sa</value>
  </parameter>
 <parameter>
  <name>password</name>
  <value>password</value>
  </parameter>
 <parameter>
  <name>serverName</name>
  <value>machinename</value>
  </parameter>
 <parameter>
  <name>port</name>
  <value>1433</value>
  </parameter>
 <parameter>
  <name>driverClassName</name>
  <value>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</value>
  </parameter>
 <parameter>
  <name>driverName</name>
  <value>SQLServer</value>
  </parameter>
 <parameter>
  <name>factory</name>
  <value>com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFactory</value>
  </parameter>
 <parameter>
  <name>DatabaseName</name>
  <value>AC_DEV</value>
  </parameter>
 <parameter>
  <name>url</name>
  <value>jdbc:microsoft:sqlserver</value>
  </parameter>
 <parameter>
  <name>maxActive</name>
  <value>2</value>
  </parameter>
 <parameter>
  <name>maxIdle</name>
  <value>1</value>
  </parameter>
  </ResourceParams>


after this you will have to add following in  web.xml
<resource-ref>
        <description>DataSource</description>        
        <res-ref-name>jdbc/SQLServerSuppData</res-ref-name>
             <res-type>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</res-type>        
        <res-auth>Container</res-auth>
    </resource-ref>

and you shd keep following jar file in your tomcat/lib
msutil.jar
msbase.jar
msssqlserver.jar
0
 
kanishkpanwarAuthor Commented:
" instead of server.xml. you should be creating a context file in conf /catalina/localhost it will look something like this"
-- why is that?

Resource name="jdbc/SQLServerSuppData"....
what is this? Name of the Database or just a unique name given for JNDI lookup?
0
 
kanishkpanwarAuthor Commented:
also,
Can you please post links to download the mentioned 3 jar files ?

thanks.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
KuldeepchaturvediCommented:
>>instead of server.xml. you should
because in tomcat 5.x you can create a separate file for each context. It helps maintaining them better the resource name is the unique name for your JNDI look up
database name goes in the parameters

as far as downloading these jars are concerned you can download them from microsoft... just google the name & it will give you the link..
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html

check out the MySql configuration and make the changes to server.xml like server name , username & pass word.


it will be like

server.xml
------------
   
 <Context path="/DBTest" docBase="DBTest"
        debug="5" reloadable="true" crossContext="true">

  <Resource name="jdbc/TestDB" auth="Container" type="com.microsoft.jdbcx.sqlserver.SQLServerDataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="yourUsername" password="yourPassword" driverClassName="com.microsoft.jdbcx.sqlserver.SQLServerDataSource"
               url="jdbc:microsoft:sqlserver://localhost:1433/databaseName"/>

</Context>

web.xml
----------

   
 <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
  <description>SQL Server Test App</description>
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/TestDB</res-ref-name>
      <res-type>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
</web-app>

 and you get the required Jars at.

http://www.microsoft.com/downloads/details.aspx?FamilyID=4f8f2f01-1ed7-4c4d-8f7b-3d47969e66ae&displaylang=en

and for reference just check out

http://www.akadia.com/services/sqlsrv_jdbc.html.

Thank You.

0
 
kanishkpanwarAuthor Commented:
Hello,
Just to let you know..I have not forgotten about this thread. I am a bit busy with some other work. I'll respond in a day or 2. I am sorry for the trouble.
0
 
kanishkpanwarAuthor Commented:
my system has crashed. I am arranging for a new copy of SQL SERVER. Please bear with me. thank you.
0
 
kanishkpanwarAuthor Commented:
btw, I want to use j_security_check mechanism to login.
Can anyone tell me SQL server settings with respect to that?
0
 
kanishkpanwarAuthor Commented:
Sadly, none of the experts answered the question I had asked. but still..I awarded points to one of the experts.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now