This is my first attempt at building something in Java, and the end goal here is to simply import an excel file into a MS Access database.
I suspect there's some sort of data incompatibility error, or something that UCA is doing to clean queries, but I don't know enough about Java or UCanAccess to track it down.
Here's the query I have assembled, which runs fine to insert data in MS Access directly:
INSERT INTO XXXX_XA_Data_1 ([Date],[Fund Ticker],[Unique ID],[Cash & Cash Equiv],[Mkt Value of Security Holdings],[Today's Future Variation Margin],[Other Net Assets],[Total Net Assets],[Fund Shares],[NAV],[Fund Sales ($)],[Fund Sales (Shares)],[Fund Redemptions ($)],[Fund Redemptions (Shares)])
VALUES (#12/01/2001#,"XXXXX","00000000-XXXXX",0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000,0.0000);
Some data has been replaced with X's and 0s, but all of the column names are the same.
I've tried several variants to see what will work, and I can get it to insert Fund Ticker, Unique ID and Cash & Cash Equiv. Based on these attempts, I'm thinking that the date format is breaking it, or some of the column names, but I can't find anyone else who's encountered this exact issue.
Here's the java:
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
db = DriverManager.getConnection("jdbc:ucanaccess://C:" + path_db);
...
Statement s = db.createStatement();
try {
int result = s.executeUpdate(rowquery);
} catch (Exception e) {
e.printStackTrace();
}
And the full trace:
[2016-02-18 13:37:29.053]: SQL Insert failed for item 1. Aborting with exception: net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::3.0.3.1 unexpected token: [
at net.ucanaccess.jdbc.UcanaccessStatement.executeUpdate(UcanaccessStatement.java:222)
at DailyImporter.main(DailyImporter.java:226)
Caused by: java.sql.SQLSyntaxErrorException: unexpected token: [
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.executeUpdate(Unknown Source)
at net.ucanaccess.jdbc.ExecuteUpdate.executeWrapped(ExecuteUpdate.java:67)
at net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:152)
at net.ucanaccess.jdbc.ExecuteUpdate.execute(ExecuteUpdate.java:50)
at net.ucanaccess.jdbc.UcanaccessStatement.executeUpdate(UcanaccessStatement.java:220)
... 1 more
Caused by: org.hsqldb.HsqlException: unexpected token: [
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserBase.checkIsIdentifier(Unknown Source)
at org.hsqldb.ParserDQL.readSimpleColumnName(Unknown Source)
at org.hsqldb.ParserDQL.readSimpleColumnNames(Unknown Source)
at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 7 more
Are there column names or other data format issues that need to be resolved here? Or libraries other than UCanAccess that can simply run SELECT/INSERT queries on a MS Access db?