1

I want to access connection on java. But i cant, because it is there odbc problem. Iam useing Windows7 x64. It's not installed odbc driver on windows 7. And is there just System DSN on Odbc Data Source Administator. I want to add but no odbc driver, only sql server.

What can i do?

2

3 Answers 3

1

If you are working on 64 bit version of Windows then you can use 64 bit and 32 bit environment. Such environment consist of Java (JDK or JRE) and database drivers. For Java applications the best way of accessing database is via JDBC driver. Then you need not to worry about 32 or 64 bit environment, you only put .jar file or files in directory that is part of CLASSPATH environment variable.

In case of MS Access you can use JDBC-ODBC bridge that is present by default in Sun (now Oracle) implementations of JRE. But before that you must configure ODBC connection with MS-Access database. This can be done via ODBC Manager or via connect string.

I think connect string is easier, because it looks like:

jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\\Nwind.mdb

all you have to do is to point at your .mdb file. This should work with 32 and 64 bit versions of JRE.

If you want to configure database access in ODBC then do it for both 32 and 64 bit environments using:

  • c:\windows\syswow64\odbcad32.exe (32 bit)
  • c:\windows\system32\odbcad32.exe (64 bit)

Then in connect string you can use DSN name you have just created like:

jdbc:odbc:DSN_NAME
1
  • 1
    The problem here is that if your java app is running in a 64-bit JRE, and the driver you've specified is a 32-bit driver, it will not work. The app will behave as if the driver did not exist. Jun 9, 2011 at 4:48
0

You should consider JDBC-ODBC bridge, for example from OpenLink.

6
  • It's better to use a pure jdbc driver, and most databases have pure jdbc drivers.
    – Kaj
    May 7, 2011 at 16:06
  • Well, if I understand the question correctly, all you have is the DSN of some ODBC data source. If you can get a JDBC driver compatible with your source, you should go with it. If it is some legacy/exotic thing that doesn't have JDBC drivers, only ODBC, you can use a JDBC-ODBC bridge as the last resort.
    – Olaf
    May 7, 2011 at 20:25
  • it is not workinng :/ default odbc 32bit "c:\windows\system32\odbcad32.exe" on windows7, so not working. but 64 bit odbc "c:\windows\sysWOW64\odbcad32.exe" and windows7 using be 32bit odbc and i cant add new odbc driver. How can i change default odbc??
    – mstfcck
    May 8, 2011 at 14:17
  • What is the database that you are trying to connect to? Based on the issues you describe looks like you have a Windows problem, not a Java problem.
    – Olaf
    May 9, 2011 at 15:57
  • Yes windows problem windows version. But how can i do?
    – mstfcck
    May 10, 2011 at 15:29
0

The usual way to access a Db with Java is with a JDBC driver. Most databases have JDBC drivers. Click here for the JDBC tutorial

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.