/** {@inheritDoc} */ @Override public V load(K key) { init(); Transaction tx = transaction(); if (log.isDebugEnabled()) log.debug("Store load [key=" + key + ", tx=" + tx + ']'); Connection conn = null; PreparedStatement stmt = null; try { conn = connection(tx); stmt = conn.prepareStatement(loadQry); stmt.setObject(1, toBytes(key)); ResultSet rs = stmt.executeQuery(); if (rs.next()) return fromBytes(rs.getBytes(2)); } catch (IgniteCheckedException | SQLException e) { throw new CacheLoaderException("Failed to load object: " + key, e); } finally { end(tx, conn, stmt); } return null; }
/** {@inheritDoc} */ @Override public void delete(Object key) { init(); Transaction tx = transaction(); if (log.isDebugEnabled()) log.debug("Store remove [key=" + key + ", tx=" + tx + ']'); Connection conn = null; PreparedStatement stmt = null; try { conn = connection(tx); stmt = conn.prepareStatement(delQry); stmt.setObject(1, toBytes(key)); stmt.executeUpdate(); } catch (IgniteCheckedException | SQLException e) { throw new CacheWriterException("Failed to remove object: " + key, e); } finally { end(tx, conn, stmt); } }
init(); Transaction tx = transaction();
/** {@inheritDoc} */ @Override public void sessionEnd(boolean commit) { init(); Transaction tx = transaction(); Map<String, Connection> props = session().properties(); Connection conn = props.remove(ATTR_CONN); if (conn != null) { try { if (commit) conn.commit(); else conn.rollback(); } catch (SQLException e) { throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() + ", commit=" + commit + ']', e); } finally { closeConnection(conn); } } if (log.isDebugEnabled()) log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']'); }
/** {@inheritDoc} */ @SuppressWarnings({"RedundantTypeArguments"}) @Override public V load(K key) { init(); Transaction tx = transaction(); if (log.isDebugEnabled()) log.debug("Store load [key=" + key + ", tx=" + tx + ']'); Connection conn = null; PreparedStatement stmt = null; try { conn = connection(tx); stmt = conn.prepareStatement(loadQry); stmt.setObject(1, toBytes(key)); ResultSet rs = stmt.executeQuery(); if (rs.next()) return fromBytes(rs.getBytes(2)); } catch (IgniteCheckedException | SQLException e) { throw new CacheLoaderException("Failed to load object: " + key, e); } finally { end(tx, conn, stmt); } return null; }
/** {@inheritDoc} */ @Override public void delete(Object key) { init(); Transaction tx = transaction(); if (log.isDebugEnabled()) log.debug("Store remove [key=" + key + ", tx=" + tx + ']'); Connection conn = null; PreparedStatement stmt = null; try { conn = connection(tx); stmt = conn.prepareStatement(delQry); stmt.setObject(1, toBytes(key)); stmt.executeUpdate(); } catch (IgniteCheckedException | SQLException e) { throw new CacheWriterException("Failed to remove object: " + key, e); } finally { end(tx, conn, stmt); } }
init(); Transaction tx = transaction();
/** {@inheritDoc} */ @Override public void sessionEnd(boolean commit) { init(); Transaction tx = transaction(); Map<String, Connection> props = session().properties(); Connection conn = props.remove(ATTR_CONN); if (conn != null) { try { if (commit) conn.commit(); else conn.rollback(); } catch (SQLException e) { throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() + ", commit=" + commit + ']', e); } finally { closeConnection(conn); } } if (log.isDebugEnabled()) log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']'); }