如何检测数据库类型? [英] How to detect database type?

查看:151
本文介绍了如何检测数据库类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要确定要连接的数据库是MySQL,而不是PostgreSQL或Microsoft SQL Server。如何确定正在使用的数据库类型。

I need to be sure the database I'm connecting to is MySQL and not PostgreSQL or Microsoft SQL Server.How can I find out which type of database is being used .

推荐答案

第一个提示可能是如果您尝试使用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

这篇关于如何检测数据库类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆