日期:2014-05-18  浏览次数:20587 次

hibernate使用数据源的连接方式
1、站点配置xml文件:

<Resource
  name="jdbc/websitename"
  type="javax.sql.DataSource"
  driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
  password=""
  maxIdle="20"
  maxWait="5000"
  username="sa"
  url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname"
  maxActive="400"/>  

2、hiberante配置文件:
<session-factory>
<property name="hibernate.jdbc.batch_size">50</property>
<property name="show_sql">true</property>
<property name="connection.datasource">java:comp/env/jdbc/websitename</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.autocommit">false</property>
  ......
</session-factory>

------解决方案--------------------
路过,帮顶
------解决方案--------------------

<Resource
name="jdbc/websitename"
type="javax.sql.DataSource"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
password=""
maxIdle="20"
maxWait="5000"
username="sa"
url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname"
maxActive="400"/> 

2、hiberante配置文件:
<session-factory>
<property name="hibernate.jdbc.batch_size">50 </property>
<property name="show_sql">true </property>
<property name="connection.datasource">javax:comp/env/jdbc/websitename </property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect </property>
<property name="connection.autocommit">false </property>
......
</session-factory>
------解决方案--------------------
路过