All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdc.mf.ea.EapDumpJackcess Maven / Gradle / Ivy

The newest version!
package cdc.mf.ea;

import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.healthmarketscience.jackcess.Cursor;
import com.healthmarketscience.jackcess.CursorBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;
import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.Table;

/**
 * PoC file to dump EAP using Jackcess instead of UCanAccess (JDBC).
 * 

* This was done to help find String encoding issues. * * @author Damien Carbonne */ public class EapDumpJackcess { private static final Logger LOGGER = LogManager.getLogger(EapDumpJackcess.class); private static final Pattern NON_UNICODE = Pattern.compile(".*\\ufffd.*"); private static boolean check(String s) { if (LOGGER.isWarnEnabled() && s != null && NON_UNICODE.matcher(s).matches()) { LOGGER.warn(" Non unicode: '{}'", s); return false; } return true; } public static void main(String[] args) throws IOException { LOGGER.info("Start"); final File file = new File("src/main/resources/S3000L_2-0_Data_model_001-00.eap"); try (final Database db = DatabaseBuilder.open(file)) { LOGGER.info("tables: {}", db.getTableNames()); final Table t = db.getTable("t_attribute"); LOGGER.info("{} columns in {}", t.getColumnCount(), t.getName()); LOGGER.info("rows: {}", t.getRowCount()); final Cursor cursor = CursorBuilder.createCursor(t); cursor.beforeFirst(); Row row; while ((row = cursor.getNextRow()) != null) { final String notes = row.getString("Notes"); final boolean ok = check(notes); if (!ok) { LOGGER.info("Row: {}", row); // cursor.getPreviousRow(); } } } LOGGER.info("Stop"); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy