bigGuy
bigGuy

Reputation: 1744

How to determine database vendor?

I need to implement different logic for different databases (because DB2 and Mssql does not support regexp). How can I determine database vendor? (config file is not an option) I use Java.

Upvotes: 0

Views: 842

Answers (2)

lance-java
lance-java

Reputation: 27996

Take a look at DbDictionaryFactory. calculateDBDictionary(...) from open-jpa.

This utility attempts to determine the database by url and driver class and will return an appropriate DBDictionary (eg OracleDictionary or MySQLDictionary).

Upvotes: 0

amicngh
amicngh

Reputation: 7899

You can use DatabaseMetaData.getDatabaseProductName as this is implemented by driver vendors.It will give you all the information you need.

Upvotes: 4

Related Questions