您的位置:首页 > 数据库

hibernate连接数据库的配置

2010-09-28 11:13 363 查看
连接mysql的配置

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate_second</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">1234</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping resource="hibernate/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>


连接sql server 2005的配置

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                                     -->
<hibernate-configuration>

<session-factory>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<property name="connection.url">
jdbc:sqlserver://localhost:1433;databaseName=Test
</property>
<property name="connection.username">sa</property>
<property name="connection.password">sa</property>
<property name="connection.driver_class">
com.microsoft.sqlserver.jdbc.SQLServerDriver
</property>

<property name="show_sql">true</property>
<mapping resource="com/visionsky/domain/User.hbm.xml"/>

</session-factory>

</hibernate-configuration>


连接oracle9i的配置

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!--程序执行的时候是否显示真正的sql语句-->
<property name="show_sql">true</property>
<!--使用的SQL对应的“方言”,此处是Oracle9的“方言”-->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect
</property>
<!--连接数据库的Driver-->
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<!--数据库连接url-->
<property name="connection.url">
jdbc:oracle:thin:@localhost:1521:nitpro
</property>
<!--用户名-->
<property name="connection.username">system</property>
<!--密码-->
<property name="connection.password">manager</property>
</session-factory>
</hibernate-configuration>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: