JdbcParameterMetaData(Trace trace, JdbcPreparedStatement prep, CommandInterface command, int id) { setTrace(trace, TraceObject.PARAMETER_META_DATA, id); this.prep = prep; this.parameters = command.getParameters(); this.paramCount = parameters.size(); }
private void setParameter(int parameterIndex, Value value) { checkClosed(); parameterIndex--; ArrayList<? extends ParameterInterface> parameters = command.getParameters(); if (parameterIndex < 0 || parameterIndex >= parameters.size()) { throw DbException.getInvalidValueException("parameterIndex", parameterIndex + 1); } ParameterInterface param = parameters.get(parameterIndex); // can only delete old temp files if they are not in the batch param.setValue(value, batchParameters == null); }
@Override protected boolean checkClosed(boolean write) { if (super.checkClosed(write)) { // if the session was re-connected, re-prepare the statement ArrayList<? extends ParameterInterface> oldParams = command.getParameters(); command = conn.prepareCommand(sqlStatement, fetchSize); ArrayList<? extends ParameterInterface> newParams = command.getParameters(); for (int i = 0, size = oldParams.size(); i < size; i++) { ParameterInterface old = oldParams.get(i); Value value = old.getParamValue(); if (value != null) { ParameterInterface n = newParams.get(i); n.setValue(value, false); } } return true; } return false; }
/** * Clears all parameters. * * @throws SQLException if this object is closed or invalid */ @Override public void clearParameters() throws SQLException { try { debugCodeCall("clearParameters"); checkClosed(); ArrayList<? extends ParameterInterface> parameters = command.getParameters(); for (ParameterInterface param : parameters) { // can only delete old temp files if they are not in the batch param.setValue(null, batchParameters == null); } } catch (Exception e) { throw logAndConvert(e); } }
/** * Adds the current settings to the batch. */ @Override public void addBatch() throws SQLException { try { debugCodeCall("addBatch"); checkClosedForWrite(); try { ArrayList<? extends ParameterInterface> parameters = command.getParameters(); int size = parameters.size(); Value[] set = new Value[size]; for (int i = 0; i < size; i++) { ParameterInterface param = parameters.get(i); param.checkSet(); Value value = param.getParamValue(); set[i] = value; } if (batchParameters == null) { batchParameters = New.arrayList(); } batchParameters.add(set); } finally { afterWriting(); } } catch (Exception e) { throw logAndConvert(e); } }
/** * INTERNAL */ public void setQueryTimeout(int seconds) throws SQLException { try { debugCodeCall("setQueryTimeout", seconds); checkClosed(); setQueryTimeout = prepareCommand("SET QUERY_TIMEOUT ?", setQueryTimeout); setQueryTimeout.getParameters().get(0) .setValue(ValueInt.get(seconds * 1000), false); setQueryTimeout.executeUpdate(false); queryTimeoutCache = seconds; } catch (Exception e) { throw logAndConvert(e); } }
private void registerOutParameter(int parameterIndex) throws SQLException { try { checkClosed(); if (outParameters == null) { maxOutParameters = Math.min( getParameterMetaData().getParameterCount(), getCheckedMetaData().getColumnCount()); outParameters = new BitField(); } checkIndexBounds(parameterIndex); ParameterInterface param = command.getParameters().get(--parameterIndex); if (!param.isValueSet()) { param.setValue(ValueNull.INSTANCE, false); } outParameters.set(parameterIndex); } catch (Exception e) { throw logAndConvert(e); } }
/** * INTERNAL */ int getQueryTimeout() throws SQLException { try { if (queryTimeoutCache == -1) { checkClosed(); getQueryTimeout = prepareCommand( "SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS " + "WHERE NAME=?", getQueryTimeout); getQueryTimeout.getParameters().get(0) .setValue(ValueString.get("QUERY_TIMEOUT"), false); ResultInterface result = getQueryTimeout.executeQuery(0, false); result.next(); int queryTimeout = result.currentRow()[0].getInt(); result.close(); if (queryTimeout != 0) { // round to the next second, otherwise 999 millis would // return 0 seconds queryTimeout = (queryTimeout + 999) / 1000; } queryTimeoutCache = queryTimeout; } return queryTimeoutCache; } catch (Exception e) { throw logAndConvert(e); } }
Value[] set = batchParameters.get(i); ArrayList<? extends ParameterInterface> parameters = command.getParameters(); for (int j = 0; j < set.length; j++) { Value value = set[j];
setLockMode.getParameters().get(0).setValue(ValueInt.get(lockMode), false); setLockMode.executeUpdate(false);
JdbcParameterMetaData(Trace trace, JdbcPreparedStatement prep, CommandInterface command, int id) { setTrace(trace, TraceObject.PARAMETER_META_DATA, id); this.prep = prep; this.parameters = command.getParameters(); this.paramCount = parameters.size(); }
JdbcParameterMetaData(Trace trace, JdbcPreparedStatement prep, CommandInterface command, int id) { setTrace(trace, TraceObject.PARAMETER_META_DATA, id); this.prep = prep; this.parameters = command.getParameters(); this.paramCount = parameters.size(); }
private void setParameter(int parameterIndex, Value value) { checkClosed(); parameterIndex--; ArrayList<? extends ParameterInterface> parameters = command.getParameters(); if (parameterIndex < 0 || parameterIndex >= parameters.size()) { throw DbException.getInvalidValueException("parameterIndex", parameterIndex + 1); } ParameterInterface param = parameters.get(parameterIndex); // can only delete old temp files if they are not in the batch param.setValue(value, batchParameters == null); }
private void setParameter(int parameterIndex, Value value) { checkClosed(); parameterIndex--; ArrayList<? extends ParameterInterface> parameters = command.getParameters(); if (parameterIndex < 0 || parameterIndex >= parameters.size()) { throw DbException.getInvalidValueException("parameterIndex", parameterIndex + 1); } ParameterInterface param = parameters.get(parameterIndex); // can only delete old temp files if they are not in the batch param.setValue(value, batchParameters == null); }
JdbcParameterMetaData(SessionInterface session, JdbcPreparedStatement prep, CommandInterface command, int id) { setTrace(session.getTrace(), TraceObject.PARAMETER_META_DATA, id); this.prep = prep; this.paramCount = command.getParameters().size(); }
private void setParameter(int parameterIndex, Value value) throws SQLException { checkClosed(); parameterIndex--; ObjectArray parameters = command.getParameters(); if (parameterIndex < 0 || parameterIndex >= parameters.size()) { throw Message.getInvalidValueException("" + (parameterIndex + 1), "parameterIndex"); } ParameterInterface param = (ParameterInterface) parameters.get(parameterIndex); param.setValue(value); }
private void registerOutParameter(int parameterIndex) throws SQLException { try { checkClosed(); if (outParameters == null) { maxOutParameters = Math.min( getParameterMetaData().getParameterCount(), getCheckedMetaData().getColumnCount()); outParameters = new BitField(); } checkIndexBounds(parameterIndex); ParameterInterface param = command.getParameters().get(--parameterIndex); if (!param.isValueSet()) { param.setValue(ValueNull.INSTANCE, false); } outParameters.set(parameterIndex); } catch (Exception e) { throw logAndConvert(e); } }
/** * INTERNAL */ public void setQueryTimeout(int seconds) throws SQLException { try { debugCodeCall("setQueryTimeout", seconds); checkClosed(); setQueryTimeout = prepareCommand("SET QUERY_TIMEOUT ?", setQueryTimeout); setQueryTimeout.getParameters().get(0). setValue(ValueInt.get(seconds * 1000), false); setQueryTimeout.executeUpdate(); queryTimeoutCache = seconds; } catch (Exception e) { throw logAndConvert(e); } }
/** * INTERNAL */ public void setQueryTimeout(int seconds) throws SQLException { try { debugCodeCall("setQueryTimeout", seconds); checkClosed(); setQueryTimeout = prepareCommand("SET QUERY_TIMEOUT ?", setQueryTimeout); setQueryTimeout.getParameters().get(0). setValue(ValueInt.get(seconds * 1000), false); setQueryTimeout.executeUpdate(); queryTimeoutCache = seconds; } catch (Exception e) { throw logAndConvert(e); } }
/** * INTERNAL */ public void setQueryTimeout(int seconds) throws SQLException { try { commit(); setQueryTimeout = prepareCommand("SET QUERY_TIMEOUT ?", setQueryTimeout); ((ParameterInterface) setQueryTimeout.getParameters().get(0)).setValue(ValueInt.get(seconds * 1000)); setQueryTimeout.executeUpdate(); } catch (Throwable e) { throw logAndConvert(e); } }