如何在Windows上连接到ODBC数据库? [英] How to connect to a ODBC database on windows?

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

问题描述

我想使用Java/.NET连接到ODBC数据库. 当我尝试连接到数据库时,出现如下错误:

I want to connect to a ODBC database using Java/.NET. When I try to connect to the database, I get errors like:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

这是为什么?我该怎么做才能使连接成功?

Why is this? What I can I do to make the connection succeed?

推荐答案

连接到ODBC数据库时出现错误可能会引起一些麻烦,这是我在发生此类错误时要检查的事项:

Errors while connecting to a ODBC database can cause some headache here is my list of things to check when such an error occurs:

  1. 位数(32/64位)问题

检查运行的位数是否与ODBC驱动程序的位数(32/64位)相同.大多数情况下,它是导致问题的尖酸刻薄.通常,大多数ODBC驱动程序都以32位的形式提供.至少所有Microsoft Office(Excel,Access,CSV等)仅作为32位驱动程序提供.因此,您也必须以32位运行必须.根本没有办法解决这个问题.您可以通过查看taskmanagers进程列表来检查您的进程是否以32位运行.如果进程名称后面有*32,则表明它以32位模式运行

Check you are running with the same bitness (32/64bit) as the ODBC driver. Most of the time is it the bitness causing problems. Usually most ODBC drivers are shipped as 32bit. At least all Microsoft Office (Excel, Access, CSV, etc.) are only shipped as 32bit drivers. So you process MUST run as 32bit, too. There simply is no way arround this. You can check if your process is running as 32bit by looking at the taskmanagers process list. If there is a *32 behind the process name it indicates that it is running in 32bit mode

错误的用户帐户

确保以与创建ODBC配置相同的用户身份运行进程.这是用户DSN与系统DSN之间的区别.用户账户绑定到特定的用户帐户.因此,如果您的应用程序是作为Windows服务运行的,则在默认的本地SYSTEM用户下运行,则可能根本看不到ODBC配置.

Make sure you are running your process as a the same user that was used to create the ODBC configuration. The is a difference between user and system DSNs. The user ones are tied to specific user accounts. So if your app is running as a windows service running under the default local SYSTEM user it might simply not see the ODBC configuration.


如果您发现发生此错误的任何其他情况,请将其添加到此答案中.对于人们每天都在寻求的所有ODBC问题,我想要一个明确的答案.


If you found any other case where this error occured, please add it to this answer. I would like one definitive answer for all ODBC issues that people are seeking day to day.

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

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