Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2004

Tip: Looking for answers? Try searching our database.

Foxpro database connection

Thread view: 
Victoria - 23 Jun 2004 04:14 GMT
Dear all,

Can I use java to access Foxpro database?

If yes, how?

Thanks for helps~

Regards
Victoria
Raquel - 23 Jun 2004 04:35 GMT
While I have no idea about Foxpro, a general method is to define your
Foxpro database as an ODBC data source. Once you have done that, load a
JDBC-ODBC driver in the java program (I believe this driver comes
intrinsically packed with JDK) and access that Foxpro database.

Raquel.
Raquel - 23 Jun 2004 05:54 GMT
A sample program for your reference. This connects and retrieves data from
a database "SAMPLE" which has been already defined as a ODBC datasource.

import java.sql.*;

public class jdbc3
{
public static void main(String[] args)
{
 String data = "jdbc:odbc:SAMPLE";
 try
 {
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Connection conn =
DriverManager.getConnection(data,"userid","password");
  Statement st = conn.createStatement();
  ResultSet rec = st.executeQuery( "SELECT DEPTNO FROM
schema.DEPARTMENT");
  while(rec.next())
  {
   System.out.println(rec.getString("DEPTNO"));
  }
  st.close();
 } catch (Exception e)
 {
  System.out.println("Error -" + e.toString());
 }
}
}
Tobias Besch - 24 Jun 2004 06:32 GMT
The URL of the connection from a JDBC ODBC bridge can contain optional
arguments.
I use for instance the followin URL to connect to a FoxPro table via the
JDBC ODBC bridge:

       String url = "jdbc:odbc:VFP;"+
       "Deleted=No;"+
       "Exclusive=No;"+
       "SourceType=DBF;"+
       "SourceDB=F:\\dbase\\DATA";

       try {
           conn = DriverManager.getConnection(url);

A documentation of all parameters can be found on
<http://msdn.microsoft.com/library/en-
us/odbc/htm/vfpodbcsqldriverconnect.asp>

and
<http://msdn.microsoft.com/library/en-
us/odbc/htm/vfpodbcodbcvisualfoxprosetupdialogbox.asp>

Cheers,
   Tobias
Roedy Green - 23 Jun 2004 06:10 GMT
>Can I use java to access Foxpro database?

If Foxpro supports ODBC, you can use an ODBC-JDBC bridge.

See http://mindprod.com/jgloss/jdbc.html

Signature

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.