欢迎光临
我们一直在努力

Hibernate setProperty方法:为Configuation对象指定配置属性

setProperty 方法用于为 Configuation 对象指定配置属性。

语法:

setProperty(String propertyName,String value)

参数说明:

  • propertyName:用于指定属性名。
  • value:用于指定属性值。

返回值:Configuation 对象。

示例1

创建一个 Configuration 对象,并指定数据库使用的 SQL 方言。

Configuration cfg = new Configuration()
  .setProperty("hibernate.dialect","org.hibernate.dialect.SQLServerDialect");

示例2

创建一个 Configuration 对象,并指定连接数据库的用户名和密码。

Configuration cfg = new Configuration()
  .setProperty("connection.username","sa")
  .setProperty("connection.password","111");
赞(0) 打赏
未经允许不得转载:hosteons中文网 » Hibernate setProperty方法:为Configuation对象指定配置属性

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册