admin 管理员组

文章数量: 1184232


默认先在目录下生成common.mdb文件


/**

* Project Name:MonitoringPlatform-commons-util
* File Name:MdbUtils.java
* Package Name:com.monitoring.common.util
* Date:2017年4月20日上午10:40:50
* Copyright (c) 2017, chenzhou1025@126.com All Rights Reserved.
*
*/

package com.monitoring.common.util;

import java.io.File;
import java.sql.Types;
import java.util.Map;



import org.apache.commons.io.Charsets;

import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.Database.FileFormat;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;

/**
* ClassName:MdbUtils <br/>
* Function:  ADD FUNCTION. <br/>
* Reason:      ADD REASON. <br/>
* Date:     2017年4月20日 上午10:40:50 <br/>
* @author   wpengfei
* @version
* @since    JDK 1.6
* @see
*/
public class MdbUtils {
public static void operator() throws Exception {
File mdbFile = new File("E:\\hospital\\trunk\\MonitoringPlatform-commons-util\\src\\main\\java\\com\\monitoring\\common\\util\\common.mdb");
if (mdbFile.exists()) {
Database dbin = Database.open(mdbFile);

Table table = dbin.getTable("InfoTable");
/*for (Map<String, Object> map : table) {  //打印原先该文件中的数据
System.out.println(map);
}  */
}
Database db = Database.create(FileFormat.V2000, mdbFile, true,
Charsets.UTF_16LE, null);
Table newTable = new TableBuilder("InfoTable")
.addColumn(
new ColumnBuilder("名称").setSQLType(Types.VARCHAR)
.toColumn())
.addColumn(
new ColumnBuilder("年龄112").setSQLType(Types.VARCHAR)
.toColumn()).toTable(db);
newTable.addRow("2鹏23", "123423");
System.out.println(true
);
}

public static void main(String[] args) throws Exception {
operator();
}
}



maven依赖

  1. < dependency >
  2. < groupId > org.hsqldb </ groupId >
  3. < artifactId > hsqldb </ artifactId >
  4. < version > 2.2.8 </ version >
  5. < type > jar </ type >
  6. < optional > false </ optional >
  7. </ dependency >
  8. < dependency >
  9. < groupId > com.healthmarketscience.jackcess </ groupId >
  10. < artifactId > jackcess </ artifactId >
  11. < version > 1.2.14.2 </ version >
  12. < type > jar </ type >
  13. < optional > false </ optional >
  14. </ dependency >


本文标签: 作方法和 文件的操 教程系列