How to get Hibernate configuration properties?

前端 未结 2 416
孤街浪徒
孤街浪徒 2021-01-15 15:07

I`m using hibernate with jpa, and it is configured with persistence.xml Is it possible to get hibernate connection properties from web application?

Thanks.

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 15:52

    If you are using JDBC you can always get a connection and its metadata. If you are using a Spring transaction manager you could get it like this:

    transactionManager.getDataSource().getConnection().getMetaData()
    

    This shows tons of information about your database and its connection including the username. There is some information in the persistence.xml that might deal with database connection pooling which usually isn't stored anywhere in Hibernate but in the actually connection pooling code.

    What information do you need to get from the persistence.xml file?

提交回复
热议问题