Solved

Problems with java dbf 64 bit

Posted on 2013-02-06
11
1,011 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 41

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 41

Expert Comment

by:pcelba
ID: 38861172
So the driver is present? What version?  Or did the update failed?
0
 

Author Comment

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

Expert Comment

by:pcelba
ID: 38861403
What connection string do you use for 64 bit version?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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 41

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 41

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 41

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now