Java 的Access 数据库操作库 Jackcess

Jackcess 是一个Java 类库,用来读写微软的Access 数据库。

显示表格内容的源码:
System.out.println(Database.open(new File("my.mdb")).getTable("MyTable").display());

创建表并写入数据:

Database db = Database.create(new File("new.mdb"));
Table newTable = new TableBuilder("NewTable")
  .addColumn(new ColumnBuilder("a")
             .setSQLType(Types.INTEGER)
             .toColumn())
  .addColumn(new ColumnBuilder("b")
             .setSQLType(Types.VARCHAR)
             .toColumn())
  .toTable(db);
newTable.addRow(1, "foo");

批量添加

 Table newTable = new TableBuilder("table")
                  .addColumn(new ColumnBuilder("a")
                             .setSQLType(Types.VARCHAR)
                             .toColumn())
                  .addColumn(new ColumnBuilder("b")
                             .setSQLType(Types.VARCHAR)
                             .toColumn())
                  .addColumn(new ColumnBuilder("c")
                             .setSQLType(Types.VARCHAR)
                             .toColumn())
                  .toTable(db);
                ArrayList list=new ArrayList();
                for (int j = 0; j < 10000; j++){
                    Object[] obj={"第二列"+j,"第一列"+j,(j+1)};
                    list.add(obj);
                }
                newTable.addRows(list);

下载地址: http://sourceforge.net/projects/jackcess/files/

你可能感兴趣的:(Java 的Access 数据库操作库 Jackcess)