RSS
 

Connecting to 32 bit / 64 bit data sources from Tomcat (Java).

03 Mar

Problem:

When running tomcat your receive the following error when connecting to an ODBC data source
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Solution:

There are *two* ODBC managers in 64 bit windows. 64 bit ODBC data sources are separate from 32 bit data sources.

The ODBC manager accessed from the Control Panel contains the *64 bit* ODBC data sources.

Launch C:\windows\syswow64\odbcad32.exe to configure the 32 bit ODBC data sources.

If your running a 64 bit app, you’ll have access to the 64 bit data sources. Likewise, if your running a 32 bit app you’ll have access to the 32 bit data sources.

For Java apps, you’ll need to invoke the app with the correct JVM (32 bit or 64 bit) to have access to the desired data sources (32 bit or 64 bit).

On Vista, the 32 bit JVM(s) can be found (by default) at C:\Program Files (x86)\Java\jre6\bin. The 64 bit JVM is at C:\Program Files\Java\jre6

Catalina.bat (used to start tomcat) looks to see if JRE_HOME is defined so make sure this is pointing to the correct JRE or update catalina.bat accordingly.

 
4 Comments

Posted in RIA

 

Leave a Reply

 

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

 
  1. rekha

    March 25, 2009 at 11:58 pm

    I am using Access 2003 and Jdk6.
    The same error occurs in my system when I tried to connect Access using JSP and Tomcat. But when I use java, it get connected.

    What I should do ? Please help me

     
  2. Joshua

    March 26, 2009 at 3:05 pm

    Rekha,
    You need to ensure that that you have a data source defined for the JVM your JSP/Tomcat is invoking.

    Note that Vista has *two* OBDC managers one for 32bit connections another for 64 bit.

    Sun provides *two* JDKs as well, 32bit and 64bit. If your running a 32bit JVM your java app will only ‘see’ the 32bit data sources. If your running a 64bit JVM your java app will only see the 64bit data sources.

    If it helps, type java -version at a command propt. Assuming the java on your system PATH is what your using to invoke your ‘working’ java app – this (java -version) will let you know *which* JVM has access to the data source :)

    i.e.
    (64 bit JVM)
    java version “1.6.0_10″
    Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
    Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)

    or

    (32bit JVM)
    java version “1.6.0_12″
    Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
    Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)

     
  3. Elena

    December 16, 2009 at 6:20 am

    Thanks a million Joshua, I found your post very very useful.

     
  4. dileep

    February 10, 2010 at 3:41 am

    dileep said,

    i am using windows 7 64 bit operation system in my laptop. And my desktop is also windows 7 32 bit operation system.Iam a hardware engineer.two systems cross connenting 32 bit os lo data 64 bit os sent very good.but data is not sent for 64 bit os to 32 bit os.but data is not sent for 64 bit os to 32 bit os.please tell me this problem.

    Thank You…