tomcat6.0中配置mysql数据源

tomcat6.0中配置mysql数据源
            
    
    博客分类: 数据库 MySQLHibernateXMLJDBCJava 


context.xml的<context>中和server.xml的<GlobalNamingResources>下添加:
<Resource
 name="jdbc/mysql"
 auth="Container"
 type="javax.sql.DataSource"
 maxActive="100"
 maxIdle="30"
 maxWait="10000"
 username="root" 
 password="123" 
 driverClassName="com.mysql.jdbc.Driver"
 url="jdbc:mysql://localhost:3306/my?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;mysqlEncoding=utf8"/> 


Hibernate.cfg.xml中的<session-factory>下添加:
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.datasource">java:comp/env/jdbc/mysql</property>
<property name="current_session_context_class">thread</property>

猜你喜欢