How to determine database type for a given JDBC connection?

前端 未结 2 346
刺人心
刺人心 2021-02-01 14:58

I need to handle resultsets returning stored procedures/functions for three databases (Oracle, sybase, MS-Server). The procedures/functions are generally the same but the call i

相关标签:
2条回答
  • 2021-02-01 15:28

    I suspect you would want to use the DatabaseMetaData class. Most likely DatabaseMetaData.getDatabaseProductName would be sufficient, though you may also want to use the getDatabaseProductVersion method if you have code that depends on the particular version of the particular database you're working with.

    0 讨论(0)
  • 2021-02-01 15:34

    You can use org.apache.ddlutils, class Platformutils:

    databaseName = new PlatformUtils().determineDatabaseType(dataSource)
    
    0 讨论(0)
提交回复
热议问题