通过java程序从Hibernate.cfg.xml获取数据库名称
我只是想知道如何使用java程序从通过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 =
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类在运行时获取配置的数据库名称?