Solved

Problems with java dbf 64 bit

Posted on 2013-02-06
11
1,047 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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
 

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

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 195
Fox pro using the copy command 5 32
throw exception 21 44
How to run a script in foxpro 6 32
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
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 covers a step-by-step guide to install VisualVM launcher in eclipse.

773 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