hibernate.cfg.xml
利用SQL数据库:
<?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 >
<!--数据库JDBC驱动类-->
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<!--数据库密码-->
<property name="hibernate.connection.password"></property>
<!--数据库的URL-->
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://localhost:1433;databaseName=demo</property>
<!--数据库的用户名-->
<property name="hibernate.connection.username">sa</property>
<!--每个数据库都有其对应的Dialet以匹配其平台特性-->
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="show_sql">true</property>
<mapping resource="com/mytest/entity/TestUser2.hbm.xml" />
</session-factory>
</hibernate-configuration>
利用Oracle9i数据库:
<session-factory>
<property name="connection.url">
jdbc:oracle:thin:@localhost:1521:Oracle1
</property>
<property name="connection.username">hello</property>
<property name="connection.password">hello</property>
<property name="connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property>
<property name="dialect">
org.hibernate.dialect.Oracle9Dialect
</property>
<property name="show_sql">true</property>
<mapping resource="com/mytest/entity/TestUser2.hbm.xml" />
</session-factory>
利用:mySql数据库:
<session-factory>
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost:3306/quickstart</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.password">pwd</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver(或org.gjt.mm.mysql.Driver)</property>
<property name="show_sql">true</property>
<mapping resource="com/bbs/hibernate/User.hbm.xml"></mapping>
</session-factory>
hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class org.gjt.mm.mysql.Driver
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost:3306/quickstart
hibernate.connection.username root
hibernate.connection.password
数据源的配置:
<property name="connection.datasource">java:comp/env/jdbc/quickstart</property>
分享到:
相关推荐
Hibernate配置文件中配置各种数据库的driver、URL
hibernate支持的所有数据库方言。用起来很方便。
文档中列出了hibernate连接各种数据库的配置,同时也提供了使用c3p0连接各种数据库的配置,非常方便您的开发。
hibernate连接数据库的连接配置。包括oracle等一系列配置。
这个附件中存放了从配置hibernate 访问Access数据库所需要的JDBC驱动和言语库以及一个配置模板。只需要作一点修改就可以使用了。 注意要使用该库需要使用jdk1.6及hibernate3.5以上版本。
hibernate同时配置多个数据库连接 可以同时连接不同IP的不同数据库
在hibernate中配置多数据库,并自由切换
Hibernate与JDBC对于数据库的性能操作对比事例,配置,更多信息资源
达梦数据库各版本的hibernate方言包,包含版本 DmDialect-for-hibernate2.0、DmDialect-for-hibernate2.1、DmDialect-for-hibernate3.0、DmDialect-for-hibernate3.1、DmDialect-for-hibernate3.6、DmDialect-for-...
//该方法将到classpath下解析hibernate.cfg.xml中的配置,如果不用Hibernate默认的配置文件名和路径,可在该方法中指定Hibernate配置文件的名称和路径 2.用Configuration对象获取SessionFactory和Session对象:...
Hibernate不同数据库的连接及SQL方言
设置在 hibernate.cfg.xml文件中,hibernate与数据库的连接
Hibernate多数据库支持解决方案 一、 去掉数据库级的外键关联 二、 如何动态加载.hbm.xml文件 三、 配置文件的加载 四、 大字段处理 五、 hibernate主键生成器(数值型主键操作方法) 六、 Oracle 转换 SQL Server ...
hibernate配置数据库连接池的三种方法(数据库连接池的概念)
hibernate数据库中文乱码问题2008年09月16日 星期二 下午 12:00我的数据库用的是mysq,编码我设成了utf-8! 用自己写的连接池可以设置编码
根据hibernate配置文件生成数据库.zip
hibernate映射的创建数据库连接时的配置。教你怎么写那个配置。
Hibernate配置数据库连接;操作技巧;减少写代码
博文链接:https://yefeishan.iteye.com/blog/237456
2.2、打开此文件,将“<property name="hibernate.connection.url">jdbc:sqlite:D:/EGSDatabase.egsdata”一行中的数据库文件("D:/EGSDatabase.egsdata")修改为合适的数据库文件。 注:附件包含了...