How to know database type programmatically in JPA?

Viewed 4025

Is there possible way to know which database server is use in JPA, programmatically? I think, there is a way, otherwise, JPA cannot transform JPQL to native query at runtime. My program also need to know DB Server Type. Is there any function for that feature?

I use eclipseLink & jpa 2.0

My expected program is :

EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPA");
String dbPlatform = emf.getDBPlatform();
System.out.println(dbPlatform);

Output :

Oracle
MySql
MSSql
DB2
....
1 Answers
Related