Hibernate 可以配置两种数据库访问策略
1. 指定 JDBC 参数进行数据库连接
2. 通过 JNDI 完成数据库连接获取
JDBC 连接配置
[code]
hibernate.dialect net.sf.hiberante.dialect.MysqlDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost/sample
hibernate.connection.username root
hibernate.connection.password mysql
[/code]
JDBC 连接配置
1.数据库适配器 (dialect)
2.JDBC 驱动类
3.数据库联接 URL
4.数据库用户
5.数据库密码
2. JNDI 连接所需要的配置
[code]
hibernate.connection.datasource jdbc/test
hibernate.connection.username user
hibernate.connection.password pwd
hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
[/code]
JNDI 连接配置
1. JNDI 连接名称
2. 数据库用户名
3. 数据库密码
4. 数据库适配器 (dialect)
1. 指定 JDBC 参数进行数据库连接
2. 通过 JNDI 完成数据库连接获取
JDBC 连接配置
[code]
hibernate.dialect net.sf.hiberante.dialect.MysqlDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost/sample
hibernate.connection.username root
hibernate.connection.password mysql
[/code]
JDBC 连接配置
1.数据库适配器 (dialect)
2.JDBC 驱动类
3.数据库联接 URL
4.数据库用户
5.数据库密码
2. JNDI 连接所需要的配置
[code]
hibernate.connection.datasource jdbc/test
hibernate.connection.username user
hibernate.connection.password pwd
hibernate.dialect net.sf.hibernate.dialect.MySQLDialect
[/code]
JNDI 连接配置
1. JNDI 连接名称
2. 数据库用户名
3. 数据库密码
4. 数据库适配器 (dialect)