Open source jdbc driver for foxpro

Does anyone know about the free / open source JDBC driver for fox pro dbf?

because the jdbc-odbc bridge does not work for me! check my previous question click here

+4
source share
1 answer

Use the ODBC JDBC driver, I found from your previous question that you received the error "Data source name not found." The DSN name you gave "VFPDS" is not created in the control panel.

I will explain to you the steps that you must take to establish a connection on Windows.

  • Create a DSN (data source name) through the control panel. Go to Control Panel-> Administration Tools-> Data Sources (ODBC) → Custom DSN-> Add-> Microsoft FoxPro VFP Driver (*. Dbf) → Click Finsih

    If you cannot create a DSN, you need to download the Visual Fox Pro Driver from the MicroSoft website

  • Now you need to enter the DSN name there and select "Database Type → Catalog of Free Tables". View the path to the .dbf file.

  • Now use the DSN name in your "DriverManager"

    Eg. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:dsnname"); 
  • If this does not work, you need to download the new ODBC driver from the Microsoft website.

I will send my code for you to understand completely.

  package javaapplication2; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; /** * * @author Ajeesh */ public class JavaApplication2 { public static void main(String[] args) { Connection con=null; Statement st=null; ResultSet rs=null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:testdsn"); st=con.createStatement(); rs=st.executeQuery("SELECT * FROM TESTFOXD"); while(rs.next()) { System.out.println("Results Field-1: "+rs.getString("FIELD1")); System.out.println("Results Field-2: "+rs.getString("FIELD2")); } } catch(Exception e) { e.printStackTrace(); } } } 

Here, "TESTFOXD" is my database name, and "testdsn" is my data source name.

0
source

Source: https://habr.com/ru/post/1481701/


All Articles