且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检测数据库类型?

更新时间:2023-01-03 11:29:52

第一个提示可能是如果您尝试使用mySQL数据库驱动程序连接到PostgreSQL数据库时可能会遇到的连接错误:)

The first hint might be the "connection error" you're likely to get if you try to connect to a PostgreSQL database with a mySQL database driver :)

基本上,您需要:

1)以可移植的方式编写应用程序代码(不要在查询中使用MSSQL扩展例如,可以在mySql上运行)

1) Code your application in a portable manner (don't use MSSQL extensions in a query that might be run on mySql, for example)

2)选择便携式驱动程序API(例如JDBC,ODBC,ADO.Net等)

2) Choose a portable driver API (like JDBC, ODBC, ADO.Net, etc)

3)为您的应用程序提供一些机制,以便在运行时查询实际的数据库类型(例如,.config属性文件)

3) Provide some mechanism for your application to query the actual database type at runtime (for example, an .config properties file)

4)针对每种受支持的数据库类型测试完成的应用程序。

4) Test your completed application against each of the supported database types.

'希望对您有所帮助。.PSM

'Hope that helps .. PSM