jdbc - Reading Visual Foxpro Data From Java using ODBC -
i trying query dbf table java application. put in reference thread
i created system data source using odbc data source administrator, set data source name vfpds , set database type .dbc finaly set path .dbc file.
the following java code:
import javax.swing.* ; import java.awt.* ; import java.awt.event.* ; import java.sql.connection; import java.sql.resultset; import java.sql.sqlexception; import java.sql.sqlwarning; import java.sql.statement; // import custom library containing myradiolistener import java.sql.drivermanager; public class testodbc { public static void main( string args[] ) { try { // load database driver class.forname( "sun.jdbc.odbc.jdbcodbcdriver" ) ; // connection database connection conn = drivermanager.getconnection( "jdbc:odbc:vfpds" ) ; // print warnings for( sqlwarning warn = conn.getwarnings(); warn != null; warn = warn.getnextwarning() ) { system.out.println( "sql warning:" ) ; system.out.println( "state : " + warn.getsqlstate() ) ; system.out.println( "message: " + warn.getmessage() ) ; system.out.println( "error : " + warn.geterrorcode() ) ; } // statement connection statement stmt = conn.createstatement() ; // execute query resultset rs = stmt.executequery( "select * pmsquoteh" ) ;//code crashes here // loop through result set while( rs.next() ) system.out.println( rs.getstring(1) ) ; // close result set, statement , connection rs.close() ; stmt.close() ; conn.close() ; } catch( sqlexception se ) { se.printstacktrace(); system.out.println( "sql exception:" ) ; // loop through sql exceptions while( se != null ) { se.printstacktrace(); system.out.println( "state : " + se.getsqlstate() ) ; system.out.println( "message: " + se.getmessage() ) ; system.out.println( "error : " + se.geterrorcode() ) ; se = se.getnextexception() ; } } catch( exception e ) { system.out.println( e ) ; } } } i got exception :
java.sql.sqlexception: [microsoft][odbc visual foxpro driver]not table. @ sun.jdbc.odbc.jdbcodbc.createsqlexception(unknown source) @ sun.jdbc.odbc.jdbcodbc.standarderror(unknown source) @ sun.jdbc.odbc.jdbcodbc.sqlexecdirect(unknown source) @ sun.jdbc.odbc.jdbcodbcstatement.execute(unknown source) @ sun.jdbc.odbc.jdbcodbcstatement.executequery(unknown source) @ usingbuttons.main(testodbc.java:38) sql exception: state : s0002 message: [microsoft][odbc visual foxpro driver]not table. error : 123 i sure table pmsquoteh exits in database , machine 64 bit machine. doing wrong ? appreciate specific answers.
i able access foxpro table jdbc-odbc bridge on windows 7 took number of steps. had vfp driver installed, , don't remember downloaded from, don't have link that.
i copied code jbdc:odbc example here: http://www.java2s.com/code/java/database-sql-jdbc/simpleexampleofjdbcodbcfunctionality.htm.
the drivermanager.getconnection method takes database url. create url need use odbc manager. unfortunately me, odbc manager through control panel worked 64 bit data sources. not aware of 64 bit foxpro driver.
to generate 32 bit dsn need run 32 bit odbc manager: odbcad32.exe. machine had several copies. ran 1 c:\windows\syswow64. go system dsn tab , select microsoft visual foxpro driver. when click finish, dialog asks data source name, description , path foxpro database or tables. have specify whether want connect .dbc or free table directory. error message makes me wonder if had wrong option selected on dsn.
the database url passed in getconnection method "jdbc:odbc:mydsnname".
after ran this, received error:
[microsoft][odbc driver manager] specified dsn contains architecture mismatch between driver , application
this because using 64 bit jvm 32 bit dsn. downloaded 32 bit jvm , able use run sample class.
i not know if there switch can set on 64 bit jvm tell run 32 bit.
Comments
Post a Comment