Solved

Problems with java dbf 64 bit

Posted on 2013-02-06
11
1,065 Views
Last Modified: 2013-02-06
Heya all,

I am having some issues and maybe someone has an answer for me!

I am trying to read write some *DBF table from a java application. I have found this code :

try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String connString="jdbc:odbc:Driver={Microsoft dBASE Driver *.dbf)};DefaultDir=C:\\test";//DefaultDir indicates the location of the db
            Connection connection=DriverManager.getConnection(connString);
            String sql="SELECT * FROM table_name where condition";// usual sql query
            Statement stmt=connection.createStatement();
            ResultSet resultSet=stmt.executeQuery(sql);
            while(resultSet.next())
            {
                System.out.println();
            }
            System.out.println();
        }
        catch (ClassNotFoundException e)
        {
            e.printStackTrace();
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }

Open in new window


This code is working fine with a 32-bit version of windows but when I try on 64 bit, it gives me the error :

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

I have looked it up and the best answer found was about something to do with playing with the DNs in system32 or sysWOW64 but I wasent able to get threw it or my understanding was no good enough....

Here is the link with that answer:

http://stackoverflow.com/questions/8895823/the-specified-dsn-contains-an-architecture-mismatch-between-the-driver-and-appli/12537390#12537390

Is there a simple solution to my problem?
0
Comment
Question by:Bamizas
  • 6
  • 5
11 Comments
 
LVL 42

Expert Comment

by:pcelba
ID: 38861042
You need 64 bit driver for Microsoft Office which is available e.g. here: http://www.microsoft.com/en-us/download/details.aspx?id=13255

You have to use c:\windows\system32\odbcad32.exe to check whether or not the driver is installed. It will also tell the exact driver name used for connection string. I would guess the name is   Microsoft Access dBASE Driver (.dbf, .ndx, .mdx).
0
 

Author Comment

by:Bamizas
ID: 38861088
Already tried updating the 64 bit driver with no further success.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 38861172
So the driver is present? What version?  Or did the update failed?
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:Bamizas
ID: 38861382
I have thé 2010 64 bit driver already installed, no chance on that solution
0
 
LVL 42

Expert Comment

by:pcelba
ID: 38861403
What connection string do you use for 64 bit version?
0
 

Author Comment

by:Bamizas
ID: 38861779
Same one has the code mentioned higher:

String connString="jdbc:odbc:Driver={Microsoft dBASE Driver *.dbf)};DefaultDir=C:\\test";
0
 
LVL 42

Expert Comment

by:pcelba
ID: 38861830
OK. That explains your problems probably.

{Microsoft dBASE Driver *.dbf)} does not describe the 64 bit driver. This one is available in the 32 bit version only.

You have to look for the correct 64 bit driver name as described in my first answer.
0
 

Author Comment

by:Bamizas
ID: 38861920
I had also tried with the :

Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx )

but same error message, is there another one?
0
 
LVL 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 38861974
This is correct driver name. If you see it from ODBC administrator executed from c:\windows\system32\odbcad32.exe then create a DSN (named e.g. myDSN) from this driver and test it with the following connection string:

String connString="jdbc:odbc:myDSN" ;
0
 

Author Closing Comment

by:Bamizas
ID: 38861992
Yup that got it working....

Thank you
0
 
LVL 42

Expert Comment

by:pcelba
ID: 38862010
Great!  I believe it should also work without DSN...

Something like:

String connString="jdbc:odbc:Driver={Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx )};DefaultDir=C:\\test";
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question