diff --git a/source/jdbcDriverOOo/Drivers.xcu b/source/jdbcDriverOOo/Drivers.xcu index 1f167a7e..08798297 100644 --- a/source/jdbcDriverOOo/Drivers.xcu +++ b/source/jdbcDriverOOo/Drivers.xcu @@ -335,7 +335,7 @@ - %origin%/driver/hsqldb-2.7.4-releasecandidate2.jar + %origin%/driver/hsqldb-2.7.4-releasecandidate3.jar diff --git a/source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate1.jar b/source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate1.jar deleted file mode 100644 index 336c5654..00000000 Binary files a/source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate1.jar and /dev/null differ diff --git a/source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate2.jar b/source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate3.jar similarity index 87% rename from source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate2.jar rename to source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate3.jar index ef5be4bd..ba2d806e 100644 Binary files a/source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate2.jar and b/source/jdbcDriverOOo/driver/hsqldb-2.7.4-releasecandidate3.jar differ diff --git a/source/jdbcDriverOOo/resource/Driver_en_US.properties b/source/jdbcDriverOOo/resource/Driver_en_US.properties index 882c2a5a..d7a04f64 100644 --- a/source/jdbcDriverOOo/resource/Driver_en_US.properties +++ b/source/jdbcDriverOOo/resource/Driver_en_US.properties @@ -140,12 +140,14 @@ 10444=%s: is positioned on current row. 10445=%s: is positioned on insert row. -10450=%s: insert row with SQL command: %s. -10451=%s: update row with SQL command: %s. -10452=%s: delete row with SQL command: %s. -10453=%s: cancel row update on cache. -10454=%s: is positioned on cached current row. -10455=%s: is positioned on cached insert row. +10450=%s: use SQL mode for deletes / inserts / updates: <%s / %s / %s> +10451=%s: supports visibility for deletes / inserts / updates: <%s / %s / %s> +10452=%s: insert row with SQL command: %s. +10453=%s: update row with SQL command: %s. +10454=%s: delete row with SQL command: %s. +10455=%s: cancel row update on cache. +10456=%s: is positioned on cached current row. +10457=%s: is positioned on cached insert row. 10500=%s: creating . 10501=%s: created , id: %s diff --git a/source/jdbcDriverOOo/resource/Driver_fr_FR.properties b/source/jdbcDriverOOo/resource/Driver_fr_FR.properties index aa77f132..7b9e16cf 100644 --- a/source/jdbcDriverOOo/resource/Driver_fr_FR.properties +++ b/source/jdbcDriverOOo/resource/Driver_fr_FR.properties @@ -140,12 +140,14 @@ 10444=%s: est positionné sur la ligne actuelle. 10445=%s: est positionné sur la ligne d'insertion. -10450=%s: insère une ligne avec la commande SQL: %s. -10451=%s: met à jour une ligne avec la commande SQL: %s. -10452=%s: supprime une ligne avec la commande SQL: %s. -10453=%s: annule la mise à jour en cache. -10454=%s: est positionné sur la ligne actuelle en cache. -10455=%s: est positionné sur la ligne d'insertion en cache. +10450=%s: utilise le mode SQL pour les suppressions / les insertions / les mises à jour: <%s / %s / %s> +10451=%s: supporte la visibilité pour les suppressions / les insertions / les mises à jour: <%s / %s / %s> +10452=%s: insère une ligne avec la commande SQL: %s. +10453=%s: met à jour une ligne avec la commande SQL: %s. +10454=%s: supprime une ligne avec la commande SQL: %s. +10455=%s: annule la mise à jour en cache. +10456=%s: est positionné sur la ligne actuelle en cache. +10457=%s: est positionné sur la ligne d'insertion en cache. 10500=%s: création d'un . 10501=%s: créé, id: %s diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DriverProviderMain.java b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DriverProviderMain.java index cd38b3a8..4f4e66d7 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DriverProviderMain.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/DriverProviderMain.java @@ -796,7 +796,6 @@ public void setConnection(XInterface source, throws SQLException { try { - System.out.println("DriverProvider.setConnection() 1"); m_infos = infos; // XXX: SQLCommandSuffix is needed for building query from sql command. m_SQLCommandSuffix = getDriverStringProperty(config1, "SQLCommandSuffix", m_SQLCommandSuffix); @@ -869,9 +868,7 @@ public void setConnection(XInterface source, m_enhanced = enhanced; String url = getConnectionUrl(location, level); - System.out.println("DriverProvider.setConnection() 2"); java.sql.Connection connection = DriverManager.getConnection(url, getJdbcConnectionProperties(infos)); - System.out.println("DriverProvider.setConnection() 3"); java.sql.DatabaseMetaData metadata = connection.getMetaData(); m_CatalogsInTableDefinitions = metadata.supportsCatalogsInTableDefinitions(); @@ -894,7 +891,6 @@ public void setConnection(XInterface source, // XXX: We do not keep the connection but the statement // XXX: which allows us to find the connection if necessary. m_statement = connection.createStatement(); - System.out.println("DriverProvider.setConnection() 4"); } catch (java.sql.SQLException e) { int resource = Resources.STR_LOG_NO_SYSTEM_CONNECTION; @@ -922,7 +918,6 @@ else if (rstype == ResultSet.TYPE_SCROLL_SENSITIVE && m_InsertVisibleSensitive ! } else { visible = getConnection().getMetaData().ownInsertsAreVisible(rstype); - System.out.println("DriverProvider.isInsertVisible() 1: " + visible); } return visible; } @@ -965,23 +960,18 @@ private boolean isDeleteVisible(int rstype) throws java.sql.SQLException { boolean visible = false; - System.out.println("DriverProviderMain.isDeleteVisible() 1 rstype: " + rstype); if (rstype == ResultSet.TYPE_SCROLL_INSENSITIVE && m_DeleteVisibleInsensitive != null) { - System.out.println("DriverProviderMain.isDeleteVisible() 2 visible: " + m_DeleteVisibleInsensitive); visible = m_DeleteVisibleInsensitive; } else if (rstype == ResultSet.TYPE_SCROLL_SENSITIVE && m_DeleteVisibleSensitive != null) { visible = m_DeleteVisibleSensitive; } else { - System.out.println("DriverProviderMain.isDeleteVisible() 3"); visible = getConnection().getMetaData().ownDeletesAreVisible(rstype); if (visible) { - System.out.println("DriverProviderMain.isDeleteVisible() 4"); visible = !getConnection().getMetaData().deletesAreDetected(rstype); } } - System.out.println("DriverProviderMain.isDeleteVisible() 5 visible: " + visible); return visible; } diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/Resources.java b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/Resources.java index e44cbdcd..dbf5a37e 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/Resources.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/Resources.java @@ -199,12 +199,14 @@ public class Resources { public static final int STR_LOG_RESULTSET_MOVE_TO_INSERT_ROW = (STR_LOG_MESSAGE_BASE + 445); // com.sun.star.sdbc.XResultSetUpdate: - public static final int STR_LOG_CACHED_RESULTSET_INSERT_ROW = (STR_LOG_MESSAGE_BASE + 450); - public static final int STR_LOG_CACHED_RESULTSET_UPDATE_ROW = (STR_LOG_MESSAGE_BASE + 451); - public static final int STR_LOG_CACHED_RESULTSET_DELETE_ROW = (STR_LOG_MESSAGE_BASE + 452); - public static final int STR_LOG_CACHED_RESULTSET_CANCEL_ROW_UPDATES = (STR_LOG_MESSAGE_BASE + 453); - public static final int STR_LOG_CACHED_RESULTSET_MOVE_TO_CURRENT_ROW = (STR_LOG_MESSAGE_BASE + 454); - public static final int STR_LOG_CACHED_RESULTSET_MOVE_TO_INSERT_ROW = (STR_LOG_MESSAGE_BASE + 455); + public static final int STR_LOG_CACHED_RESULTSET_SQL_MODE_USED = (STR_LOG_MESSAGE_BASE + 450); + public static final int STR_LOG_CACHED_RESULTSET_VISIBILITY = (STR_LOG_MESSAGE_BASE + 451); + public static final int STR_LOG_CACHED_RESULTSET_INSERT_ROW = (STR_LOG_MESSAGE_BASE + 452); + public static final int STR_LOG_CACHED_RESULTSET_UPDATE_ROW = (STR_LOG_MESSAGE_BASE + 453); + public static final int STR_LOG_CACHED_RESULTSET_DELETE_ROW = (STR_LOG_MESSAGE_BASE + 454); + public static final int STR_LOG_CACHED_RESULTSET_CANCEL_ROW_UPDATES = (STR_LOG_MESSAGE_BASE + 455); + public static final int STR_LOG_CACHED_RESULTSET_MOVE_TO_CURRENT_ROW = (STR_LOG_MESSAGE_BASE + 456); + public static final int STR_LOG_CACHED_RESULTSET_MOVE_TO_INSERT_ROW = (STR_LOG_MESSAGE_BASE + 457); // io.github.prrvchr.uno.sdbcx.TableContainerBase: public static final int STR_LOG_CREATE_TABLES = (STR_LOG_MESSAGE_BASE + 500); diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/resultset/ScrollableResultSet.java b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/resultset/ScrollableResultSet.java index e9b80a5d..5c22313e 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/resultset/ScrollableResultSet.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/resultset/ScrollableResultSet.java @@ -45,8 +45,11 @@ import java.util.Map; import java.util.Vector; +import com.sun.star.logging.LogLevel; + import io.github.prrvchr.jdbcdriver.ConnectionLog; import io.github.prrvchr.jdbcdriver.DriverProvider; +import io.github.prrvchr.jdbcdriver.Resources; import io.github.prrvchr.jdbcdriver.rowset.BaseRow; import io.github.prrvchr.jdbcdriver.rowset.InsertRow; import io.github.prrvchr.jdbcdriver.rowset.Row; @@ -79,6 +82,7 @@ public ScrollableResultSet(DriverProvider provider, public void moveToCurrentRow() throws SQLException { + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_MOVE_TO_CURRENT_ROW); setInsertMode(false); } @@ -86,6 +90,7 @@ public void moveToCurrentRow() public void moveToInsertRow() throws SQLException { + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_MOVE_TO_INSERT_ROW); setInsertMode(true); } @@ -107,17 +112,18 @@ public void insertRow() } // XXX: The result set cannot be updated, the insert // XXX: will be done by a SQL command from the cached insert row. - int cursor = getRowCount() + 1; - int position = getMaxPosition() + 1; InsertRow insert = m_InsertRow.clown(); getRowSetWriter().insertRow(insert); + for (String query : insert.getQueries()) { + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_INSERT_ROW, query); + } getRowData().add(new Row(insert)); // XXX: cursor and absolute position must be set on the inserted row - m_Cursor = cursor; - m_Position = position; + m_Cursor = getRowCount(); + m_Position = getMaxPosition(); setInsertMode(false); // XXX: We must be able to respond positively to the insert - m_InsertedRow = cursor; + m_InsertedRow = m_Cursor; } @Override @@ -150,8 +156,9 @@ public void updateRow() // XXX: The result set cannot be updated, the update // XXX: will be done by a SQL command from the cached current row. Row row = (Row) getCurrentRow(); - if (row.isUpdated()) { - getRowSetWriter().updateRow(row); + getRowSetWriter().updateRow(row); + for (String query : row.getQueries()) { + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_UPDATE_ROW, query); } } @@ -167,6 +174,9 @@ public void deleteRow() int position = m_Cursor; Row row = (Row) getCurrentRow(); getRowSetWriter().deleteRow(row); + for (String query : row.getQueries()) { + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_DELETE_ROW, query); + } m_DeletedRows.add(position); } diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/resultset/SensitiveResultSet.java b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/resultset/SensitiveResultSet.java index 3ab1836d..0b0b8daf 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/resultset/SensitiveResultSet.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/resultset/SensitiveResultSet.java @@ -106,9 +106,11 @@ public SensitiveResultSet(DriverProvider provider, m_SQLDelete = SQLMode || provider.useSQLDelete(); m_SQLInsert = SQLMode || provider.useSQLInsert(); m_SQLUpdate = SQLMode || provider.useSQLUpdate(); + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_SQL_MODE_USED, m_SQLDelete, m_SQLInsert, m_SQLUpdate); m_IsDeleteVisible = !m_SQLDelete && provider.isDeleteVisible(result); m_IsInsertVisible = !m_SQLInsert && provider.isInsertVisible(result); m_IsUpdateVisible = !m_SQLUpdate && provider.isUpdateVisible(result); + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_VISIBILITY, m_IsDeleteVisible, m_IsInsertVisible, m_IsUpdateVisible); System.out.println("SensitiveResultSet() 1"); System.out.println("SensitiveResultSet() Use SQL Delete: " + m_SQLDelete); System.out.println("SensitiveResultSet() Use SQL Insert: " + m_SQLInsert); @@ -123,14 +125,12 @@ public SensitiveResultSet(DriverProvider provider, public void moveToCurrentRow() throws SQLException { - System.out.println("SensitiveResultSet.moveToCurrentRow() 1"); if (m_OnInsert) { if (m_SQLInsert) { m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_MOVE_TO_CURRENT_ROW); } // XXX: We move to current row only if we don't use SQL mode for insert else { - System.out.println("SensitiveResultSet.moveToCurrentRow() 2"); m_Result.moveToCurrentRow(); m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_RESULTSET_MOVE_TO_CURRENT_ROW); } @@ -144,23 +144,19 @@ public void moveToCurrentRow() public void moveToInsertRow() throws SQLException { - System.out.println("SensitiveResultSet.moveToInsertRow() 1"); if (!m_OnInsert) { // XXX: We create an cached insert row only if insert is not visible // XXX: and the inserted row must be put in cache. if (!m_IsInsertVisible) { - System.out.println("SensitiveResultSet.moveToInsertRow() 2"); m_InsertRow = new InsertRow(m_ColumnCount); m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_MOVE_TO_INSERT_ROW); } // XXX: We move to insert row only if we don't use SQL mode for insert if (!m_SQLInsert) { - System.out.println("SensitiveResultSet.moveToInsertRow() 3"); m_Result.moveToInsertRow(); m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_RESULTSET_MOVE_TO_INSERT_ROW); } m_OnInsert = true; - System.out.println("SensitiveResultSet.moveToInsertRow() 4"); } } @@ -168,7 +164,6 @@ public void moveToInsertRow() public void cancelRowUpdates() throws SQLException { - System.out.println("SensitiveResultSet.cancelRowUpdates() 1"); // XXX: It seems that LibreOffice uses cancelRowUpdates() to exit the insert row // XXX: after a call to moveToInsertRow() while JDBC forbids this. // XXX: See: libreoffice/dbaccess/source/core/api/RowSetCache.cxx @@ -190,46 +185,40 @@ else if (!m_SQLUpdate){ public void insertRow() throws SQLException { - System.out.println("SensitiveResultSet.insertRow() 1 Cursor: " + m_Cursor + " - InsertVisible: " + m_IsInsertVisible); if (!m_OnInsert) { throw new SQLException("ERROR: insertRow() cannot be called when moveToInsertRow has not been called !"); } BaseRow row = m_InsertRow != null ? m_InsertRow.clown() : null; if (m_SQLInsert) { - System.out.println("SensitiveResultSet.insertRow() 2"); getRowSetWriter().insertRow(row); - m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_INSERT_ROW, row.getQuery()); + for (String query : row.getQueries()) { + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_INSERT_ROW, query); + } } else { - System.out.println("SensitiveResultSet.insertRow() 3"); // XXX: Base does not allow auto-increment columns to be entered, // XXX: some drivers force us to update these columns to null RowHelper.setDefaultColumnValues(m_Result, m_InsertedColumns); m_InsertedColumns.clear(); m_Result.insertRow(); - System.out.println("SensitiveResultSet.insertRow() 4"); m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_RESULTSET_INSERT_ROW); } moveToCurrentRow(); // XXX: Positioned insert also must be put in the cache if inserted row are not visible if (row != null) { - System.out.println("SensitiveResultSet.insertRow() 5"); int index = getRowCount() + 1; m_InsertedData.add(new Row(row)); m_InsertedRows.add(index); - System.out.println("SensitiveResultSet.insertRow() 6 at Cursor: " + index); } // XXX: Since we are maintaining the row count of the ResultSet, we need to increment it. else { m_RowCount ++; - System.out.println("SensitiveResultSet.insertRow() 7 RowCount: " + m_RowCount); } // XXX: cursor and position must be set on the inserted row m_Cursor = getRowCount(); m_Position = getMaxPosition(); // XXX: We must be able to respond positively to the insert m_Inserted = m_Cursor; - System.out.println("SensitiveResultSet.insertRow() 8 Cursor: " + m_Cursor); } @Override @@ -238,7 +227,6 @@ public boolean rowDeleted() { boolean deleted = isDeleted(m_Deleted); m_Deleted = -1; - System.out.println("SensitiveResultSet.rowDeleted() 1 : " + deleted); return deleted; } @@ -246,12 +234,10 @@ public boolean rowDeleted() public boolean rowInserted() throws SQLException { - System.out.println("SensitiveResultSet.rowInserted() 1"); // XXX: We can assume the insertion is valid without any // XXX: movement in the ResultSet since the insertion. boolean inserted = m_Inserted == m_Cursor; m_Inserted = -1; - System.out.println("SensitiveResultSet.rowInserted() 2 : " + inserted); return inserted; } @@ -259,21 +245,19 @@ public boolean rowInserted() public void updateRow() throws SQLException { - System.out.println("SensitiveResultSet.updateRow() 1"); // XXX: In addition to SQL updates we must be able to update inserted // XXX: row when insert are not visible (ie: inserted row are in cache) if (isInsertedRow() || m_SQLUpdate) { - System.out.println("SensitiveResultSet.updateRow() 2"); Row row = getCachedRow(); getRowSetWriter().updateRow(row); - m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_UPDATE_ROW, row.getQuery()); + for (String query : row.getQueries()) { + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_UPDATE_ROW, query); + } } else { - System.out.println("SensitiveResultSet.updateRow() 3"); m_Result.updateRow(); m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_RESULTSET_UPDATE_ROW); } - System.out.println("SensitiveResultSet.updateRow() 4"); } @Override @@ -282,7 +266,6 @@ public boolean rowUpdated() { System.out.println("SensitiveResultSet.rowUpdated() 1 **************************************************"); boolean updated = m_Result.rowUpdated(); - System.out.println("SensitiveResultSet.rowUpdated() 2 : " + updated); return updated; } @@ -291,22 +274,21 @@ public void deleteRow() throws SQLException { m_Deleted = m_Cursor; - System.out.println("SensitiveResultSet.deleteRow() 1 Position: " + m_Deleted); // XXX: Are we trying to delete a row that has been inserted or updated and which will be in cache? boolean cached = isCachedRow(); // XXX: In addition to SQL deletes we must be able to delete inserted or updated row // XXX: when insert or update are not visible (ie: inserted or updated row are in cache) if (m_SQLDelete || cached) { - System.out.println("SensitiveResultSet.deleteRow() 2"); Row row = cached ? getCachedRow() : getResultRow(); getRowSetWriter().deleteRow(row); - m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_DELETE_ROW, row.getQuery()); + for (String query : row.getQueries()) { + m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_CACHED_RESULTSET_DELETE_ROW, query); + } } else { m_Result.deleteRow(); // XXX: The row preceding the deleted row becomes the current row previous(); - System.out.println("SensitiveResultSet.deleteRow() 3 getRow: " + m_Result.getRow()); m_logger.logprb(LogLevel.FINE, Resources.STR_LOG_RESULTSET_DELETE_ROW); } if (cached) { @@ -314,7 +296,6 @@ public void deleteRow() } // XXX: Managing bookmark requires us to manage a cursor taking into account the deleted lines. m_DeletedRows.add(m_Deleted); - System.out.println("SensitiveResultSet.deleteRow() 4"); } @@ -356,12 +337,8 @@ public boolean first() public boolean last() throws SQLException { - System.out.println("SensitiveResultSet.last() 1"); boolean last = super.last(); - System.out.println("SensitiveResultSet.last() 2 : " + last + " - IsInCache: " + isInCache()); - System.out.println("SensitiveResultSet.last() 3 isUpdated: " + isUpdated() + " - isInserted: " + isInserted() + " - isDeleted: " + isDeleted() + " - isOnInsertRow: " + isOnInsertRow()); if (last && !isInCache()) { - System.out.println("SensitiveResultSet.last() 4 Cursor: " + m_Cursor + " - Position: " + m_Position); last = moveResultSet(); } return last; @@ -398,12 +375,10 @@ public String getString(int index) m_WasNull = row.isColumnNull(index); if (!m_WasNull) { value = (String) row.getColumnObject(index); - System.out.println("SensitiveResultSet.getString() 1 : " + value); } } else { value = m_Result.getString(index); - System.out.println("SensitiveResultSet.getString() 2 : " + value + " - Row: " + m_Result.getRow()); m_WasNull = m_Result.wasNull(); } return value; @@ -1163,16 +1138,12 @@ public void updateDouble(int index, double value) { // XXX: Base using updateDouble() for most numeric SQL types, // XXX: it is necessary to convert to the native column type - System.out.println("SensitiveResultSet.updateDouble() 1 Value: " + value); if (updateCache()) { - System.out.println("SensitiveResultSet.updateDouble() 2"); setColumnDouble(index, value); } if (updateResultSet()) { - System.out.println("SensitiveResultSet.updateDouble() 3"); super.updateDouble(index, value); } - System.out.println("SensitiveResultSet.updateDouble() 4"); } @Override @@ -1191,16 +1162,12 @@ public void updateBigDecimal(int index, BigDecimal value) public void updateString(int index, String value) throws SQLException { - System.out.println("SensitiveResultSet.updateString() 1 Value: " + value); if (updateCache()) { - System.out.println("SensitiveResultSet.updateString() 2"); setColumnObject(index, value); } if (updateResultSet()) { - System.out.println("SensitiveResultSet.updateString() 3"); super.updateString(index, value); } - System.out.println("SensitiveResultSet.updateString() 4"); } @Override @@ -1602,19 +1569,11 @@ protected boolean moveResultSet(Integer position, int row) throws SQLException { boolean moved = false; - try { - if (isAfterLast() || isBeforeFirst()) { - return false; - } - // XXX: For loading the first row Base use absolute(1) will the current row is beforeFirst. - boolean cached = isCachedRow(); - System.out.println("SensitiveResultSet.moveResultSet() 1 Cursor: " + m_Cursor + " - Cached: " + cached); - moved = cached ? true : moveResultSet(); - System.out.println("SensitiveResultSet.moveResultSet() 2 Cursor: " + m_Cursor); - } - catch (Exception e) { - e.printStackTrace(); + if (isAfterLast() || isBeforeFirst()) { + return false; } + // XXX: For loading the first row Base use absolute(1) will the current row is beforeFirst. + moved = isCachedRow() ? true : moveResultSet(); return moved; } diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/BaseRow.java b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/BaseRow.java index a5bd2428..6412b06f 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/BaseRow.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/BaseRow.java @@ -27,6 +27,8 @@ import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public abstract class BaseRow @@ -34,7 +36,7 @@ public abstract class BaseRow protected Object[] m_OldValues; protected int m_Count; - protected String m_Query; + protected List m_Queries = new ArrayList<>(); public BaseRow(int count) @@ -72,15 +74,18 @@ public void initColumnObject(int index, m_OldValues[index - 1] = value; } - public String getQuery() + public String[] getQueries() { - return m_Query; + String[] queries = m_Queries.toArray(new String[0]); + m_Queries = new ArrayList<>(); + return queries; } - public String buildQuery(String query, Object... objects) + public String getQuery(String sql, Object... arguments) { - m_Query = String.format(query, objects); - return m_Query; + String query = String.format(sql, arguments); + m_Queries.add(query); + return query; } public abstract boolean isColumnNull(int index); diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/InsertRow.java b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/InsertRow.java index 0ed43c93..039fd7d5 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/InsertRow.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/InsertRow.java @@ -25,7 +25,6 @@ */ package io.github.prrvchr.jdbcdriver.rowset; -import java.sql.SQLException; import java.util.BitSet; @@ -53,18 +52,6 @@ public InsertRow(InsertRow row) } } - public InsertRow(java.sql.ResultSet result, int count) - throws SQLException - { - super(count); - m_Inserted = new BitSet(count); - for (int i = 0; i < count; i++) { - m_OldValues[i] = RowHelper.getResultSetValue(result, i + 1); - m_Inserted.set(i); - } - } - - public InsertRow clown() { return new InsertRow(this); diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/RowHelper.java b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/RowHelper.java index 13650c2e..c66818fc 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/RowHelper.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/RowHelper.java @@ -135,7 +135,6 @@ public static void setWhereParameter(PreparedStatement statement, for (String key : table.getRowIdentifier()) { RowColumn column = table.getColumn(key); Object value = row.getOldColumnObject(column.getIndex()); - System.out.println("RowSetWriter.getModifiedColumns() Column: " + column.getName() + " - Value: " + value); RowHelper.setStatementValue(statement, column.getType(), index, value); index ++; } diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/RowSetWriter.java b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/RowSetWriter.java index 1f85a7d8..92654fba 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/RowSetWriter.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/jdbcdriver/rowset/RowSetWriter.java @@ -53,7 +53,8 @@ public RowSetWriter(DriverProvider provider, throws SQLException { m_Provider = provider; - // XXX: We can make lazy loading on catalog if ResultSet is updatable + // XXX: We can do lazy loading on the catalog if ResultSet is updatable, because if + // XXX: positioned update is available it will be preferred over SQL mode (ie: RowSetWriter) if (catalog == null) { catalog = new RowCatalog(provider, result, table); } @@ -67,7 +68,9 @@ public boolean insertRow(BaseRow row) for (RowTable table: m_Catalog.getTables()) { List columns = getModifiedColumns(table, row); if (!columns.isEmpty()) { - try (PreparedStatement statement = getInsertStatement(row, table, columns)) { + String query = row.getQuery(m_InsertCmd, table.getComposedName(true), + getInsertColumns(table, columns), getInsertParameter(table, columns)); + try (PreparedStatement statement = getInsertStatement(query)) { setStatementParameter(statement, columns, row); status = statement.executeUpdate(); if (status == 1) { @@ -88,7 +91,9 @@ public boolean updateRow(Row row) List columns = getModifiedColumns(table, row); if (!columns.isEmpty()) { checkForUpdate(table, row, columns); - try (PreparedStatement statement = getUpdateStatement(row, table, columns)) { + String query = row.getQuery(m_UpdateCmd, table.getComposedName(true), + getUpdatedColumns(table, columns), table.getWhereCmd()); + try (PreparedStatement statement = m_Provider.getConnection().prepareStatement(query)) { int index = setStatementParameter(statement, columns, row); RowHelper.setWhereParameter(statement, m_Catalog, table, row, index); status = statement.executeUpdate(); @@ -106,7 +111,8 @@ public boolean deleteRow(Row row) for (RowTable table: m_Catalog.getTables()) { status = 0; checkForDelete(table, row); - try (PreparedStatement statement = getDeleteStatement(row, table)) { + String query = row.getQuery(m_DeleteCmd, table.getComposedName(true), table.getWhereCmd()); + try (PreparedStatement statement = m_Provider.getConnection().prepareStatement(query)) { RowHelper.setWhereParameter(statement, m_Catalog, table, row); status = statement.executeUpdate(); } @@ -151,7 +157,7 @@ private void checkForDelete(RowTable table, } private int getResultRowCount(RowTable table, - Row row) + Row row) throws SQLException { int count = 0; @@ -168,14 +174,10 @@ private int getResultRowCount(RowTable table, return count; } - private PreparedStatement getInsertStatement(BaseRow row, - RowTable table, - List columns) + private PreparedStatement getInsertStatement(String query) throws SQLException { PreparedStatement statement = null; - String query = row.buildQuery(m_InsertCmd, table.getComposedName(true), getInsertColumns(table, columns), getInsertParameter(table, columns)); - System.out.println("RowSetWriter.getInsertStatement() Query: " + query); if (m_Provider.isAutoRetrievingEnabled()) { statement = m_Provider.getConnection().prepareStatement(query, Statement.RETURN_GENERATED_KEYS); } @@ -185,25 +187,6 @@ private PreparedStatement getInsertStatement(BaseRow row, return statement; } - private PreparedStatement getUpdateStatement(Row row, - RowTable table, - List columns) - throws SQLException - { - String query = row.buildQuery(m_UpdateCmd, table.getComposedName(true), getUpdatedColumns(table, columns), table.getWhereCmd()); - System.out.println("RowSetWriter.getUpdateStatement() Query: " + query); - return m_Provider.getConnection().prepareStatement(query); - } - - private PreparedStatement getDeleteStatement(Row row, - RowTable table) - throws SQLException - { - String query = row.buildQuery(m_DeleteCmd, table.getComposedName(true), table.getWhereCmd()); - System.out.println("RowSetWriter.getDeleteStatement() Query: " + query); - return m_Provider.getConnection().prepareStatement(query); - } - private String getInsertColumns(RowTable table, List columns) { diff --git a/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbc/StatementBase.java b/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbc/StatementBase.java index 056da278..1cef4c1a 100644 --- a/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbc/StatementBase.java +++ b/source/jdbcDriverOOo/source/io/github/prrvchr/uno/sdbc/StatementBase.java @@ -80,7 +80,6 @@ protected void registerProperties(Map properties) { @Override public Object getValue() throws WrappedTargetException { - System.out.println("sdbc.StatementBase._getEscapeProcessing(): " + m_EscapeProcessing); return _getEscapeProcessing(); } }, @@ -90,7 +89,6 @@ public void setValue(Object value) throws PropertyVetoException, IllegalArgumentException, WrappedTargetException { - System.out.println("sdbc.StatementBase._setEscapeProcessing(): " + (boolean) value); _setEscapeProcessing((boolean) value); } }));