step1:在server.xml中配置jndi数据源
<GlobalNamingResources>
<Environment
name="simpleValue"
type="java.lang.Integer"
value="30"/>
<Resource
auth="Container"
description="User database that can be updated and saved"
name="UserDatabase"
type="org.apache.catalina.UserDatabase"
pathname="conf/tomcat-users.xml"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource
name="js_local"
type="javax.sql.DataSource"
driverClassName="com.sybase.jdbc2.jdbc.SybDriver"
password="1234"
maxIdle="2"
maxWait="5000"
username="sybase"
url="jdbc:sybase:Tds:192.168.9.211:5000/test?charset=eucgb&jconnect_version=0"
maxActive="20"/>
</GlobalNamingResources>
step2:在context.xml中配置
<ResourceLink name="js_local" global="js_local" type="javax.sql.DataSource" />
step3:在hibernate.cfg.xml中配置
<session-factory>
<property name="connection.datasource">java:comp/env/js_local</property>
<property name="dialect"> org.hibernate.dialect.SybaseDialect </property>
<mapping resource="hbn/Trunk.hbm.xml" />
</session-factory>