@Override protected BlobHandler setObject(Connection c, PreparedStatement ps, int i, Object obj) { if (obj instanceof byte[]) { byte[] bytes = (byte[]) obj; PTInputStream is = new PTInputStream(new ByteArrayInputStream(bytes), bytes.length); return handlePtInputStream(c, ps, i, is); } else if (obj instanceof PTInputStream) { return handlePtInputStream(c, ps, i, (PTInputStream) obj); } else if (obj instanceof ArrayHandler) { setOracleStructArray(c, ps, i, (ArrayHandler) obj); return null; } else { return super.setObject(c, ps, i, obj); } }
/** Encapsulates the logic for creating a prepared statement with the arguments set*/ private PreparedStatement createPreparedStatement(Connection c, String sql, Object[] vs) throws PalantirSqlException { PreparedStatement ps; ps = Connections.prepareStatement(c, sql); List<BlobHandler> toClean = Lists.newArrayList(); if (vs != null) { try { for (int i=0; i < vs.length; i++) { BlobHandler cleanup = setObject(c, ps, i+1, vs[i]); if (cleanup != null) { toClean.add(cleanup); } } } catch (Exception e) { // if we throw, we need to clean up any blobs we have already made for (BlobHandler cleanupBlob : toClean) { try { cleanupBlob.freeTemporary(); } catch (Exception e1) { SqlLoggers.LOGGER.error("failed to free temp blob", e1); //$NON-NLS-1$ } } BasicSQLUtils.throwUncheckedIfSQLException(e); throw Throwables.throwUncheckedException(e); } } return BlobCleanupPreparedStatement.create(ps, toClean); }
for (int j=0; j < vs[i].length; j++) { Object obj = vs[i][j]; BlobHandler cleanup = setObject(c, ps, j+1, obj); if (cleanup != null) { cleanups.add(cleanup);
for (int j=0; j < vs[i].length; j++) { Object obj = vs[i][j]; BlobHandler cleanup = setObject(c, ps, j+1, obj); if (cleanup != null) { cleanups.add(cleanup);
@Override protected BlobHandler setObject(Connection c, PreparedStatement ps, int i, Object obj) { if (obj instanceof byte[]) { byte[] bytes = (byte[]) obj; PTInputStream is = new PTInputStream(new ByteArrayInputStream(bytes), bytes.length); return handlePtInputStream(c, ps, i, is); } else if (obj instanceof PTInputStream) { return handlePtInputStream(c, ps, i, (PTInputStream) obj); } else if (obj instanceof ArrayHandler) { setOracleStructArray(c, ps, i, (ArrayHandler) obj); return null; } else { return super.setObject(c, ps, i, obj); } }
/** Encapsulates the logic for creating a prepared statement with the arguments set*/ private PreparedStatement createPreparedStatement(Connection c, String sql, Object[] vs) throws PalantirSqlException { PreparedStatement ps; ps = Connections.prepareStatement(c, sql); List<BlobHandler> toClean = Lists.newArrayList(); if (vs != null) { try { for (int i=0; i < vs.length; i++) { BlobHandler cleanup = setObject(c, ps, i+1, vs[i]); if (cleanup != null) { toClean.add(cleanup); } } } catch (Exception e) { // if we throw, we need to clean up any blobs we have already made for (BlobHandler cleanupBlob : toClean) { try { cleanupBlob.freeTemporary(); } catch (Exception e1) { SqlLoggers.LOGGER.error("failed to free temp blob", e1); //$NON-NLS-1$ } } BasicSQLUtils.throwUncheckedIfSQLException(e); throw Throwables.throwUncheckedException(e); } } return BlobCleanupPreparedStatement.create(ps, toClean); }
for (int j=0; j < vs[i].length; j++) { Object obj = vs[i][j]; BlobHandler cleanup = setObject(c, ps, j+1, obj); if (cleanup != null) { cleanups.add(cleanup);
for (int j=0; j < vs[i].length; j++) { Object obj = vs[i][j]; BlobHandler cleanup = setObject(c, ps, j+1, obj); if (cleanup != null) { cleanups.add(cleanup);