dbf分两种,一种是Dbase,另一种是Foxpro的
Dbase不用装驱动就可以操作
java 代码 如下:
- Connection connDbf = null;
- PreparedStatement psDbf = null;
- ResultSet rsDbf = null;
-
- String filePath = "D:/temp";
-
- 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();
另一种要装foxpro的驱动
java 代码如下:
- Connection connDbf = null;
- PreparedStatement psDbf = null;
- ResultSet rsDbf = null;
-
- String filePath = "D:/temp";
-
- 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();