如何在java中直接生成dbf文件,解决即给分 用java连库,用语句新建一个库,然后,再操作本地文件目录,把新建的库copy出来,哈再放到应用程序里,提供下载!最后把新建的库再删除了,哈 是不是很简单呀!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private String userName = ""; private String password = ""; private String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";String url="jdbc:odbc:driver={Microsoft DBase Driver (*.dbf)};DBQ=D:\\Temp"; private java.sql.Connection connection; protected ResultSet resultSet = null; protected ResultSetMetaData resultSetMetaData = null; private java.sql.Statement statement=null; /* 创建一个连接 */ private Connection getNewConnection() { try { this.connection.close(); //试图关闭连接 } finally { this.connection = null; //释放连接 try { Class.forName(this.driverName); //加载驱动程序 try { this.connection = DriverManager.getConnection(this.url, this.userName,this.password);// JOptionPane.showMessageDialog(null, "数据库连接成功!"); } catch (SQLException e) { JOptionPane.showMessageDialog(null, url); //JOptionPane.showMessageDialog(null,"连不上数据库,请检查数据源"); System.exit(0); throw e; } } finally { return this.connection; //返回新建立的连接 } } } public java.sql.Connection getConnection() { if (connection != null) { try { if (connection.isClosed()) { connection = null; getNewConnection(); } } catch (SQLException ex) { } } if (connection == null) { //没有设置连接则创建一个连接 getNewConnection(); } return connection; }用SQL语句在TEMP中创建数据表,就OK了 从Oracle 查询得数据,导入DBF中就可以了 to LittleLandlord(小地主) :如何在D:\\Temp 目录下建立dbf格式的数据库表:我目前需设三个字段:姓名(varchar2(2))、帐号(varchar2(20))、工资(number(10,2)),谢谢! 用SQL语句,CREATE TABLE tablename (name CHAR(20),account CHAR(20)) String sql = "CREATE TABLE tablename (name CHAR(20),account CHAR(20),wage NUMBER(10,2))";执行SQL语句不会? 执行完SQL语句,就已经在D:\temp创建了一个tablename.DBF数据库文件 只需要安装dbase的驱动就可以了,是不是,不需按照dbase?解决完即给分,谢谢! 只需要安装dbase的驱动就可以了,是不是,不需安装dbase?解决完即给分,谢谢! java MD5加密算法问题 静态方法只能访问静态的变量的问题 想实现一个界面,请教! 崩溃了,那位高人指点 数据库连接的问题! 关于JavaMail,有大礼送~~~~~~ 请教运行jar时的classpath问题 帮帮忙!!!高分相赠 那位大虾有AWT的滚动条的代码,一百分求救。 请问有没有铁岭的朋友 关于 InputStream 和 FileInputStream 的available() ArrayList是什么意思?谢谢了!
private String password = "";
private String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
String url="jdbc:odbc:driver={Microsoft DBase Driver (*.dbf)};DBQ=D:\\Temp"; private java.sql.Connection connection;
protected ResultSet resultSet = null;
protected ResultSetMetaData resultSetMetaData = null;
private java.sql.Statement statement=null;
/*
创建一个连接
*/
private Connection getNewConnection() {
try {
this.connection.close(); //试图关闭连接
}
finally {
this.connection = null; //释放连接
try {
Class.forName(this.driverName); //加载驱动程序
try {
this.connection = DriverManager.getConnection(this.url, this.userName,this.password);
// JOptionPane.showMessageDialog(null, "数据库连接成功!");
}
catch (SQLException e) {
JOptionPane.showMessageDialog(null, url); //JOptionPane.showMessageDialog(null,"连不上数据库,请检查数据源");
System.exit(0);
throw e;
}
}
finally {
return this.connection; //返回新建立的连接
}
}
}
public java.sql.Connection getConnection() {
if (connection != null) {
try {
if (connection.isClosed()) {
connection = null;
getNewConnection();
}
}
catch (SQLException ex) {
}
}
if (connection == null) { //没有设置连接则创建一个连接
getNewConnection();
}
return connection;
}
用SQL语句在TEMP中创建数据表,就OK了
如何在D:\\Temp 目录下建立dbf格式的数据库表:我目前需设三个字段:姓名(varchar2(2))、帐号(varchar2(20))、工资(number(10,2)),谢谢!