标签:arc 文件打开 插入 opera 创建文件 except RKE 分享 office
package access;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;
import org.junit.Test;
import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;
public class AccessUtil {
public static void main(String[] args) throws IOException {
//这里同样支持mdb和accdb
Database db = DatabaseBuilder.create(Database.FileFormat.V2000, new File("d:\\new.mdb"));
Table newTable;
try {
//刚才是创建文件,这里是在文件里创建表,字段名,字段类型
newTable = new TableBuilder("Archives")
.addColumn(new ColumnBuilder("档案号")
.setSQLType(Types.VARCHAR))
.addColumn(new ColumnBuilder("编制单位")
.setSQLType(Types.VARCHAR))
.addColumn(new ColumnBuilder("案卷正题名")
.setSQLType(Types.VARCHAR))
.addColumn(new ColumnBuilder("案卷题目长度")
.setSQLType(Types.INTEGER))
.addColumn(new ColumnBuilder("档案盒规格")
.setSQLType(Types.VARCHAR))
.addColumn(new ColumnBuilder("编制单位长度")
.setSQLType(Types.INTEGER))
.toTable(db);
//插入一条数据测试
newTable.addRow("12", "foo","212",44,"323",56);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Test
public void operator() throws Exception {
File mdbFile = new File("C:\\Users\\admin\\Desktop\\test.mdb");
if (mdbFile.exists()) {
Database dbin = DatabaseBuilder.open(mdbFile);
Table table = dbin.getTable("Archives");
table.addRow("档案号 新增测试", "编制单位新增测试", "案卷正题目新增测试",55, "档案盒规格测试", 5);
}
}
}
以下是生成的access文件打开后的效果,需用office的access软件打开
jackcess-2.1.10.jar
标签:arc 文件打开 插入 opera 创建文件 except RKE 分享 office
原文地址:https://www.cnblogs.com/woshuaile/p/10034452.html