[java]代码库
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;
import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;
/**
*
* 需要导入 jackcess-1.2.8.jar 包
*
*/
public class AccessJdbcDemo {
public void show() throws IOException {
System.out.println(Database.open(new File("d://new.mdb"))
.getTable("NewTable").display());
}
public void write() throws IOException, SQLException {
Database db = Database.create(new File("d://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");
}
public static void main(String[] args) throws IOException, SQLException {
AccessJdbcDemo access = new AccessJdbcDemo();
// access.write();
access.show();
}
}