java连接DBF
来源:互联网 发布:oracle批量update数据 编辑:程序博客网 时间:2024/06/02 22:56
数据库连接类:
package dbfconnection;
import java.sql.*;
public class connection {
Connection con = null;
Statement st = null;
ResultSet rs = null;
public connection() throws SQLException {
getConnection();
}
public Connection getConnection() throws SQLException {
try {
String url = "jdbc:odbc:driver={Microsoft Visual FoxPro Driver};" +
"SourceType=DBF;SourceDB=" +
"C://Program Files//Microsoft Visual Studio//Vfp98//";
/*
"C://Program Files//Microsoft Visual Studio//Vfp98//" 为dbf文件的路径
*/
con = DriverManager.getConnection(url);
} catch (Exception e) {
e.printStackTrace();
}
String sql = "select * from info";
st = con.createStatement();
rs = st.executeQuery(sql);
while (rs.next()) {
String str = "Name:" + rs.getString("Name") + "/tAddress:" + rs.getString("Address") + "/tAge:" + rs.getInt("Age");
System.out.println(str);
}
return con;
}
public void Close() {
try {
if (rs != null) {
rs.close();
}
if (st != null) {
st.close();
}
if (con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
测试代码:
package dbfconnection;
import java.io.IOException;
import java.sql.*;
public class Main {
public static void main(String[] args) throws SQLException, IOException {
System.out.println("输出:");
connection cont = new connection();
cont.Close();
}
}
- java连接DBF
- LINUX平台 java怎么直接连接access数据库dbf文件
- dbf 连接字符串问题
- asp连接dbf数据库技术
- l.net 连接dbf
- Delphi 连接DBF数据
- .net连接DBF文件
- Python 连接DBF数据库
- java读写dbf文件
- java 读写 dbf
- java操作dbf文件
- java 读取dbf文件
- java excel转dbf
- java编辑dbf文件
- Java 读取dbf文件
- java 读取,写入 dbf
- 用ODBC来连接dbf
- asp.net 连接数据库文件 dbf
- xmlDoc
- Math函数性能比较
- C# OFFICE 2007控件 第三方控件DotNetBar
- Virtools脚本语言(VSL)教程 - 结构
- Siebel Tools: How to program Browser Script & Server Script
- java连接DBF
- webservice接口测试
- 字符,字节和编码
- 第七章:常用类
- Siebel Admin: How to find the Component that associated with Application
- 090907(星期一)项目进展:学习MFC的消息映射
- 头文件和源文件的关系
- SAP R3
- android virtual Device