问题
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?
回答1:
Errors while connecting to a ODBC database can cause some headache here is my list of things to check when such an error occurs:
Bitness (32/64bit) Issues
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 modeWrong user account
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.
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.
来源:https://stackoverflow.com/questions/36793610/how-to-connect-to-a-odbc-database-on-windows