1.
在context.xml中的context标签内加入以下代码:
<Resource name="jdbc/mysql" auth="Container"
type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/yourdbname"
username="root"
password="root"
maxActive="20"
maxIdle="10"/>
2、在web.xml中web-app下加入以下代码
<resource-ref>
<description>MySql DataSource</description>
<res-ref-name>jdbc/yourdbname</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
3. 在SPRING的配置文件中加入如下代码
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/yourdbname</value>
</property>
</bean>
4. 最后在你的SPRING配置文件中加入以下代码接管HIBERNATE的配置
<beans>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>这里是加载的HIBERNATE OR 文件</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLInnoDBDialect
</prop>
</props>
</property>
</bean>
</beans>
This blogger is recording some code samples,technical skill of java,.Net,javascript, css, html for myself use. All articles are coming from my own experience and my collections which are from internet world. If you find any material have copy right issue please leave a comment to me. I will delete it immediately. These articles are writing in English or Chinese. Hope these information can help other technical guys. Thanks for reading.
Subscribe to:
Post Comments (Atom)
-
1. Change the tile of web.xml from <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "ht...
-
2011年最火爆的8大Web开发工具提到,jQuery和jQuery Mobile,CSS3 PIE,Bootstrap,LESS,Chrome开发人员工具等。一下是全部内容, 2011年最火爆的8大Web开发工具 TechFrom2011总结系列 2011年最火爆的8大...
-
1.创建文件夹 //using System.IO; Directory.CreateDirectory(%%1); 2.创建文件 //using System.IO; File.Create(%%1); 3.删除文件 //using System.IO; Fil...
No comments:
Post a Comment