如何在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?解决完即给分,谢谢! 在SWT 中怎么移动树节点 问一个很菜的java传值问题。 一个编程问题! 2D画线形图(求座标映射) 关于如何在java程序中调用ie的问题 java中如何调用存储过程并获得out参数!高分 请问谁有UML或者JDBC的电子书籍? 请问awt中有树这个控件么,对象命是什么 javax.naming.NoInitialContextException求解 问个关于反射的问题 关于 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)),谢谢!