Solved

Problems with java dbf 64 bit

Posted on 2013-02-06
11
1,095 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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.
Suggested Courses

617 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