Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problems with java dbf 64 bit

Posted on 2013-02-06
11
Medium Priority
?
1,109 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 43

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 43

Expert Comment

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

Watch some penguins on the livecam!

 

Author Comment

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

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 43

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 43

Accepted Solution

by:
pcelba earned 2000 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 43

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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.
Suggested Courses

704 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