none
How to install JDBC driver Microsoft sqljdbc.jar in tomcat 7

    Question

  • I want to know if it is possible to use this JDBC driver with Tomcat 7.

    If so, how do I input the server.xml, web.xml(WEB-INF), and context.xml(WEB-INF) ?

    Here is my context.xml...

    <Context>
      <Resource name="jdbc/Contacts"
                auth="Container"
                type="javax.sql.DataSource"
                username="E-Mail Address"
                password="Last Name"
                driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
                url="jdbc:sqlserver://localhost;DatabaseName=mydb;SelectMethod=cursor;"
                maxActive="8"
                />
    </Context>

    Here is what I have in my web.xml .

       <security-constraint>
          <display-name>My First Application Security Constraint</display-name>
          <web-resource-collection>
             <web-resource-name>First App Protected Area</web-resource-name>
             <!-- Define the context-relative URL(s) to be protected -->
             <url-pattern>/jsp/security/protected/*</url-pattern>
             <!-- If you list http methods, only those methods are protected -->
             <http-method>DELETE</http-method>
             <http-method>GET</http-method>
             <http-method>POST</http-method>
             <http-method>PUT</http-method>
          </web-resource-collection>
          <auth-constraint>
             <!-- Anyone with one of the listed roles may access this area -->
             <role-name>somename</role-name>
             <role-name>role1</role-name>
          </auth-constraint>
        </security-constraint>

        <!-- Default login configuration uses form-based authentication -->
        <login-config>
          <auth-method>FORM</auth-method>
          <realm-name>Example Form-Based Authentication Area</realm-name>
          <form-login-config>
            <form-login-page>/jsp/security/protected/login.jsp</form-login-page>
            <form-error-page>/jsp/security/protected/error.jsp</form-error-page>
          </form-login-config>
        </login-config>
           
        <!-- Security roles referenced by this web application -->
        <security-role>
          <role-name>role1</role-name>
        </security-role>
        <security-role>
          <role-name>somename</role-name>
        </security-role>

    I assume something must be put in the server.xml but im not sure what.

    Here is what I have....

          <Realm className="org.apache.catalina.realm.LockOutRealm">
            <!-- This Realm uses the UserDatabase configured in the global JNDI
                 resources under the key "UserDatabase".  Any edits
                 that are performed against this UserDatabase are immediately
                 available for use by the Realm.  -->
            <!-- <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                   resourceName="UserDatabase"/> -->
             <Realm className="org.apache.catalina.realm.DataSourceRealm"
      dataSourceName="jdbc/Pubs"
      userRoleTable="RolesTable" roleNameCol="Role Name"/>
             userTable="Contacts" userNameCol="E-mail Address" userCredCol="Last Name"/>
          </Realm>

    What am I missing??? I have placed the sqljdbc.jar file in the tomcat/lib directory. Tomcat accepts

    the file by starting the application. I am using form based authentication. I have basically used the

    tomcat form example which includes other stuff that needs to be used to authenticate the app. If you

    look at the web.xml you can see that access to the app will only take place by accessing the login

    form. Then it will access any form on the web app. The form continually loops if it does not find an

    entry or even if the db is not working.


    Adrian Aguinaga

    Thursday, July 11, 2013 10:01 PM

All replies