Oracle:
1.hibernate.hbm.xml文件:
<?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="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.username">system</property>
<property name="connection.password">111111</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="show_sql">true</property>
<mapping resource="User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
注:hibernate的jar可由Myeclipse添加,但是还需要添加一个jdbc连接的jar包,Oracle为ojdbc6.jar。Mysql为mysql-connector-java-5.0.8-bin.jar
2.mysql的hibernate.hbm.xml文件的配置
<?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>
<!-- 连接本机的mysql的hibernate数据库 -->
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property>
<!-- 连接数据库的用户名和密码 -->
<property name="connection.username">root</property>
<property name="connection.password">000000</property>
<!-- mysql数据库的驱动类 -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- mysql数据库的方言 -->
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<!-- 显示sql语句 -->
<property name="show_sql">true</property>
<mapping resource="Person.hbm.xml"/>
</session-factory>
</hibernate-configuration>