【问题标题】:When hibernate gets initialized, to which db the Hibernate will be connected?当休眠被初始化时,休眠将连接到哪个数据库?
【发布时间】:2015-10-27 20:26:34
【问题描述】:

一个 Hibernate 核心应用程序在类路径目录中有以下文件,其中包含以下条目:

在hibernate.properties中:

  hibernate.connection.url = jdbc:mysql://localhost/myAppDB1

在 hibernate.cfg.xml 文件中我们有:

<property name="hibernate.connection.url">   
      jdbc:mysql://localhost/myAppDB2    
</property>

鉴于文件在文件中的正确位置有上述语句,当hibernate被初始化时,Hibernate将连接到哪个数据库?

a)myAppDB1/b)myAppDB2/c)无法决定/d)错误

【问题讨论】:

    标签: hibernate


    【解决方案1】:

    您的问题包含答案。仔细查看&lt;property&gt; 标签:

    <property name="hibernate.connection.url">
        jdbc:mysql://localhost/myAppDB2
    </property>
    

    数据库名称是连接 URL 的一部分,以 myAppDB2 结尾。所以你的答案是选择bmyAppDB2

    【讨论】:

    • ...非常感谢
    猜你喜欢
    • 2013-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-01
    • 1970-01-01
    相关资源
    最近更新 更多