dbf分两种,一种是Dbase,另一种是Foxpro的
1、Dbase不用装驱动就可以操作
Connection connDbf = null;
PreparedStatement psDbf = null;
ResultSet rsDbf = null;
//一个目录名称,下面存放DBF文件
String filePath = "D:/temp";
//一个DBF文件夹,实际文件名称为tbUser.dbf,这里做为表名不用扩展名就可以
String fileName = "tbUser";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connDbf = DriverManager.getConnection("jdbc:odbc:DRIVER={Microsoft dBase Driver (*.dbf)};DBQ=" + filePath + ";","","");
sql = "select * from " + fileName;
psDbf = connDbf.prepareStatement(sql);
rsDbf = psDbf.executeQuery();
2、另一种要装foxpro的驱动
Connection connDbf = null;
PreparedStatement psDbf = null;
ResultSet rsDbf = null;
//一个目录名称,下面存放DBF文件
String filePath = "D:/temp";
//一个DBF文件夹,实际文件名称为tbUser.dbf,这里做为表名不用扩展名就可以
String fileName = "tbUser";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String strurl = "jdbc:odbc:Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + filePath + ";Exclusive=No;";
connDbf = DriverManager.getConnection(strurl);
sql = "select * from " + fileName;
psDbf = connDbf.prepareStatement(sql);
rsDbf = psDbf.executeQuery();