Tomcat中JDBCRealm的配置

2008-02-23 09:28:38来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

在配置Tomcat的JDBCRealm的时候,有几个应该注意的地方

1. 数据库JDBC驱动应该放在${tomcat.home}/server/lib目录下,而不能放在Webapps的lib目录下,二者的class loader不同
2. tomcat在启动时只会自动装载后缀为.jar的jar包,因此如果使用Oracle9i的驱动,应把class12.zip改名为class12.jar
3. 最好将JDBCRealm的配置信息放在webapp的context配置文件中,而不要放在server.XML中


e.g.
<!-- ======================================================================= -->
<!-- This file is deployed to Tomcat 4.1.x using the "setup-tomcat" ant -->
<!-- task. You can also manually copy it to Tomcat's webapps directory. -->
<!-- ======================================================================= -->

<!-- To use Tomcat's MemoryRealm (in $CATALINA_HOME/conf/tomcat-users.xml)
simply comment out both of the Realm's below. MemoryRealm is the
default realm for all applications, specified in
$CATALINA_HOME/conf/server.xml.

To use Tomcat's JDBCRealm, JNDIRealm or JAASRealm, uncomment the
appropriate section below. All of these 3 realms require supplemental
drivers (JAR files) in $CATALINA_HOME/common/lib.

jdbc/MySQL: http://www.mysql.com/downloads/api-jdbc-stable.html
- JAR: mysql-connector-Java-2.0.14-bin.jar
jdbc/postgresql: http://www.postgresql.org/
- JAR: postgresql-jdbc3-7.3.jar
jndi/ldap: http://java.sun.com/products/jndi/index.html#download
- JAR: ldap.jar
jaas: http://free.taGISh.net/jaas/index.JSP
- JAR: tagishauth.jar

NOTE: For the JAASRealm, you must also add the path to NTSystem.dll to
your $PATH environment variable.

-->

<!-- Simchronize-selfcare Application Context -->
<Context path="/simchronize-selfcare" docBase="simchronize-selfcare" debug="99" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="simchronize_selfcare_log." suffix=".txt" timestamp="true"/>

<!--

<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@10.168.195.62:1521:SIMCHRO"
connectionName="SIMCHR_24" connectionPassword="SIMCHR_24"
userTable="SIMCHR_SELFCARE_USERS" userNameCol="MSISDN" userCredCol="PASSWD"
userRoleTable="SIMCHR_SELFCARE_USER_ROLES" roleNameCol="ROLE" />
-->

<!-- NOTE: If you want to use a DataSourceRealm, the Resource must be a
global resource -->
<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
driverName="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@10.168.195.62:1521:SIMCHRO"
connectionName="SIMCHR_24" connectionPassword="SIMCHR_24"
userTable="SIMCHR_SELFCARE_USERS" userNameCol="MSISDN" userCredCol="PASSWD"
userRoleTable="SIMCHR_SELFCARE_USER_ROLES" roleNameCol="ROLE" />

<Resource name="jdbc/simchronize" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/simchronize">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<!-- MySQL dB username and password for dB connections -->

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Hibernate Tools

下一篇:用java获得广播地址