hibernate.properties配置
hibernate.dialect net.sf.hibernate.dialect.MySQLDialecthibernate.connection.driver_class org.gjt.mm.mysql.Driver
hibernate.connection.url jdbc:mysql:///test?useUnicode=true&characterEncoding=gb2312
hibernate.connection.username root
hibernate.connection.password 123456
hibernate.dialect net.sf.hibernate.dialect.MySQLDialecthibernate.connection.driver_class org.gjt.mm.mysql.Driver
hibernate.connection.url jdbc:mysql:///test?useUnicode=true&characterEncoding=gb2312
hibernate.connection.username root
hibernate.connection.password 123456
hibernate.connection.username=sa
hibernate.connection.password=123456
hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver
hibernate.connection.url jdbc:microsoft:sqlserver://192.168.0.111;DatabaseName=db;SelectMethod=cursor记得改sa password 还有连接地址等等
http://www.hibernate.org.cn/87.html
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"><!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<hibernate-configuration> <session-factory>
<!-- properties -->
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property> <!-- mapping files -->
<mapping resource="Customer.hbm.xml"/>
<mapping resource="Cat.hbm.xml"/>
<mapping resource="Item.hbm.xml"/> </session-factory></hibernate-configuration>
希望对你有帮助!
#hibernate.connection.username sa
#hibernate.connection.password sa
## Microsoft Driver (not recommended!)
#hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver
#hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor//********************
not recommended
//********************
不推荐,那我应该怎么用法呢
有没有推荐的用法!
还记得配置连接池
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://zhh:1433 </property>
<property name="hibernate.connection.username">kfzxweb</property>
<property name="hibernate.connection.password">kfzxweb</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<mapping resource="com/kfzx/hibernate/Bjxx.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Gcsxx.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Khfk.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Khxx.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Rwfp.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Wxbj.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Wxdj.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Wxzd.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Xtcs.hbm.xml"/>
</session-factory>
</hibernate-configuration>
//jndi的,用的weblogic
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">kfzx</property>
<property name="hibernate.connection.provider_class">net.sf.hibernate.connection.DatasourceConnectionProvider</property>
<property name="hibernate.jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="show_sql">false</property>
<property name="hibernate.jdbc.fetch_size">100</property>
<property name="hibernate.jdbc.batch_size">50</property>
<property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<mapping resource="com/kfzx/hibernate/Bjxx.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Gcsxx.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Khfk.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Khxx.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Rwfp.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Wxbj.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Wxdj.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Vwxdj.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Wxzd.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Xtcs.hbm.xml"/>
<mapping resource="com/kfzx/hibernate/Vfwslhz.hbm.xml"/>
</session-factory>
</hibernate-configuration>