Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过java程序从Hibernate.cfg.xml获取数据库名称_Java_Hibernate - Fatal编程技术网

通过java程序从Hibernate.cfg.xml获取数据库名称

通过java程序从Hibernate.cfg.xml获取数据库名称,java,hibernate,Java,Hibernate,我只是想知道如何使用java程序从hibernate.cfg.xml获取数据库名称 谁能帮我弄到数据库名吗 提前感谢。使用hibernate.properties而不是hibernate.cfg.xml 在hibernate.properties中,,,可以为数据库设置以下属性:- hibernate.database.application=database\u name 您可以通过以下代码轻松找到数据库名称:- private static Properties props; props =

我只是想知道如何使用java程序从
hibernate.cfg.xml
获取数据库名称

谁能帮我弄到数据库名吗


提前感谢。

使用
hibernate.properties
而不是
hibernate.cfg.xml

在hibernate.properties中,,,可以为数据库设置以下属性:-

hibernate.database.application=database\u name

您可以通过以下代码轻松找到数据库名称:-

private static Properties props;
props = new Properties();     
props.load(PropertiesManager.class.getClassLoader().getResourceAsStream("hibernate.properties"));
String databaseNmae = prop.getProperty("hibernate.database.application");
您想知道如何“解析”该XML文件并提取数据库名称吗?或者您想知道如何使用Hibernate类在运行时获取配置的数据库名称?