Description:
When using PreparedStatements together with a CachedRowSet, it is not possible to update a tablefield that is inside a sheme, that has a "-" in the name.
How to repeat:
Shema Name: `sdemig-ngt`
Tablename: `filename`
[Java Snipplet]
public CachedRowSet getFiles() throws SQLException {
ResultSet resultSet = null;
String query = "SELECT * FROM `sdemig-ngt`.`filename`";
PreparedStatement stmt = conn.prepareStatement(query);
//stmt.setString(1,"%");
logger.fine("running statement:" + stmt.toString());
resultSet = stmt.executeQuery();
CachedRowSet cRS = new CachedRowSetImpl();
cRS.populate(resultSet);
return cRS;
}
public void writeCachedRowSet(CachedRowSet cRS) throws SyncProviderException {
cRS.acceptChanges(conn);
}
[END OF JAVA]
[EXCEPTION]
Error was:object is not a file
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-ngt.filename WHERE F1 = 'no file found: 7403-50-1-424-1| path: g:\\gas\\XXX' at line 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:933)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1027)
at com.sun.rowset.internal.CachedRowSetWriter.updateOriginalRow(CachedRowSetWriter.java:488)
at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:331)
at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:859)
at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:919)
at sde.tim.dwg_mass_converter.DBConnector.writeCachedRowSet(DBConnector.java:101)
at sde.tim.dwg_mass_converter.DwgConverter.permanent_errorAbort(DwgConverter.java:80)
at sde.tim.dwg_mass_converter.DwgConverter.checkFile(DwgConverter.java:69)
at sde.tim.dwg_mass_converter.DwgConverter.getfilenames(DwgConverter.java:47)
at sde.tim.dwg_mass_converter.DwgConverter.main(DwgConverter.java:36)
Exception in thread "main" javax.sql.rowset.spi.SyncProviderException: 16132 conflicts while synchronizing
at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:382)
at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:859)
at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:919)
at sde.tim.dwg_mass_converter.DBConnector.writeCachedRowSet(DBConnector.java:101)
at sde.tim.dwg_mass_converter.DwgConverter.permanent_errorAbort(DwgConverter.java:80)
at sde.tim.dwg_mass_converter.DwgConverter.checkFile(DwgConverter.java:69)
at sde.tim.dwg_mass_converter.DwgConverter.getfilenames(DwgConverter.java:47)
at sde.tim.dwg_mass_converter.DwgConverter.main(DwgConverter.java:36)
[END OF EXCEPTION]
Suggested fix:
Workarround: Just rename the shema, so that the "-" is no more inside the name, then it will work fine.