tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shining" <n...@bb163.net>
Subject Help Using Tyrex on Tomcat 4.1.12
Date Wed, 23 Oct 2002 13:01:15 GMT
Hi,

  I try to use tyrex connect pool in Tomcat 4.1.12. After configure the Tomcat according to
the "JNDI Datasource HOW-TO", it doesn't work. 
  Follwing is my configure: 
  tyrex.xml in the WEB-INF/classes directory.
  ---------------------------------------------------------------------------
<domain>
  <name>xtglDomain</name>
  <resources>
    <dataSource>
      <name>NBJL_XTGL</name>
      <jar>C:\Program Files\Apache Group\Tomcat 4.1\common\lib\mssqlserver.jar</jar>
      <class>com.microsoft.jdbc.sqlserver.SQLServerDriver</class>
      <config>
        <user>sa</user>
        <password></password>
        <serverName>192.168.0.12</serverName>
        <port>1433</port>
        <database>NBJL_XTGL</database>
      </config>
    </dataSource>
  </resources>
</domain>
  ---------------------------------------------------------------------------
  Server.xml 
  ---------------------------------------------------------------------------
    <Environment name="tyrexDomainConfig" type="java.lang.String" value="tyrex.xml"/>
    <Environment name="tyrexDomainName" type="java.lang.String" value="xtglDomain"/>

    <Context path="/DBTest" docBase="DBTest"
            debug="5" reloadable="true" crossContext="true">

      <Logger className="org.apache.catalina.logger.FileLogger"
                prefix="localhost_DBTest_log." suffix=".txt"
                timestamp="true"/>

      <Resource name="jdbc/NBJL_XTGL" auth="Container" type="tyrex.resource.Resource"/>
      <ResourceParams name="jdbc/NBJL_XTGL">
        <parameter>
          <name>name</name>
          <value>NBJL_XTGL</value>
        </parameter>
      </ResourceParams>
    </Context>
  ---------------------------------------------------------------------------
  Web.xml
  ---------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <description>MSSQL Test App</description>
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/NBJL_XTGL</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
</web-app>
  ---------------------------------------------------------------------------
  DBTest.java
  ---------------------------------------------------------------------------
package foo;

import javax.naming.*;
import javax.sql.*;
import java.sql.*;

public class DBTest {

  String dm = "Not Connected";
  String xm = "Not Connected";
  String mm = "Not Connected";
    
  public void init() {
    try{
      Context ctx = new InitialContext();
      if(ctx == null ) 
          throw new Exception("Boom - No Context");

      DataSource ds = 
            (DataSource)ctx.lookup(
               "java:comp/env/NBJL_XTGL");

      if (ds != null) {
        Connection conn = ds.getConnection();
              
        if(conn != null)  {
            Statement stmt = conn.createStatement();
            ResultSet rst = 
                stmt.executeQuery(
                  "select * from TBL_XTYH");
            if(rst.next()) {
               dm=rst.getString("XTYH_DM");
               xm=rst.getString("XTYH_XM");
               mm=rst.getString("XTYH_MM");
            }
            conn.close();
        }
      }
    }catch(Exception e) {
      e.printStackTrace();
    }
 }

 public String getDM() { return dm; }
 public String getXM() { return xm;}
 public String getMM() { return mm;}
}
  ---------------------------------------------------------------------------

  Can you tell me what's wrong with these config.

Goodluck

Shining
Mime
View raw message