📄 callablestatement.java
字号:
} /** * @see java.sql.CallableStatement#getInt(java.lang.String) */ public synchronized int getInt(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= int retValue = rs.getInt(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getLong(int) */ public synchronized long getLong(int parameterIndex) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); long retValue = rs .getLong(mapOutputParameterIndexToRsIndex(parameterIndex)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getLong(java.lang.String) */ public synchronized long getLong(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= long retValue = rs.getLong(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } protected int getNamedParamIndex(String paramName, boolean forOut) throws SQLException { if (this.connection.getNoAccessToProcedureBodies()) { throw SQLError.createSQLException("No access to parameters by name when connection has been configured not to access procedure bodies", SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } if ((paramName == null) || (paramName.length() == 0)) { throw SQLError.createSQLException(Messages.getString("CallableStatement.2"), //$NON-NLS-1$ SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } if (this.paramInfo == null) { throw SQLError.createSQLException( Messages.getString("CallableStatement.3") + paramName + Messages.getString("CallableStatement.4"), //$NON-NLS-1$ //$NON-NLS-2$ SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } CallableStatementParam namedParamInfo = this.paramInfo .getParameter(paramName); if (forOut && !namedParamInfo.isOut) { throw SQLError.createSQLException( Messages.getString("CallableStatement.5") + paramName //$NON-NLS-1$ + Messages.getString("CallableStatement.6"), //$NON-NLS-1$ SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } if (this.placeholderToParameterIndexMap == null) { return namedParamInfo.index + 1; // JDBC indices are 1-based } for (int i = 0; i < this.placeholderToParameterIndexMap.length; i++) { if (this.placeholderToParameterIndexMap[i] == namedParamInfo.index) { return i + 1; } } throw SQLError.createSQLException("Can't find local placeholder mapping for parameter named \"" + paramName + "\".", SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } /** * @see java.sql.CallableStatement#getObject(int) */ public synchronized Object getObject(int parameterIndex) throws SQLException { CallableStatementParam paramDescriptor = checkIsOutputParam(parameterIndex); ResultSetInternalMethods rs = getOutputParameters(parameterIndex); Object retVal = rs.getObjectStoredProc( mapOutputParameterIndexToRsIndex(parameterIndex), paramDescriptor.desiredJdbcType); this.outputParamWasNull = rs.wasNull(); return retVal; } /** * @see java.sql.CallableStatement#getObject(int, java.util.Map) */ public synchronized Object getObject(int parameterIndex, Map map) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); Object retVal = rs.getObject( mapOutputParameterIndexToRsIndex(parameterIndex), map); this.outputParamWasNull = rs.wasNull(); return retVal; } /** * @see java.sql.CallableStatement#getObject(java.lang.String) */ public synchronized Object getObject(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= Object retValue = rs.getObject(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getObject(java.lang.String, * java.util.Map) */ public synchronized Object getObject(String parameterName, Map map) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= Object retValue = rs.getObject(fixParameterName(parameterName), map); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * Returns the ResultSet that holds the output parameters, or throws an * appropriate exception if none exist, or they weren't returned. * * @return the ResultSet that holds the output parameters * * @throws SQLException * if no output parameters were defined, or if no output * parameters were returned. */ protected ResultSetInternalMethods getOutputParameters(int paramIndex) throws SQLException { this.outputParamWasNull = false; if (paramIndex == 1 && this.callingStoredFunction && this.returnValueParam != null) { return this.functionReturnValueResults; } if (this.outputParameterResults == null) { if (this.paramInfo.numberOfParameters() == 0) { throw SQLError.createSQLException(Messages .getString("CallableStatement.7"), //$NON-NLS-1$ SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } throw SQLError.createSQLException(Messages.getString("CallableStatement.8"), //$NON-NLS-1$ SQLError.SQL_STATE_GENERAL_ERROR); } return this.outputParameterResults; } public synchronized ParameterMetaData getParameterMetaData() throws SQLException { if (this.placeholderToParameterIndexMap == null) { return (CallableStatementParamInfoJDBC3) this.paramInfo; } else { return new CallableStatementParamInfoJDBC3(this.paramInfo); } } /** * @see java.sql.CallableStatement#getRef(int) */ public synchronized Ref getRef(int parameterIndex) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); Ref retValue = rs .getRef(mapOutputParameterIndexToRsIndex(parameterIndex)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getRef(java.lang.String) */ public synchronized Ref getRef(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= Ref retValue = rs.getRef(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getShort(int) */ public synchronized short getShort(int parameterIndex) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); short retValue = rs .getShort(mapOutputParameterIndexToRsIndex(parameterIndex)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getShort(java.lang.String) */ public synchronized short getShort(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= short retValue = rs.getShort(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getString(int) */ public synchronized String getString(int parameterIndex) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); String retValue = rs .getString(mapOutputParameterIndexToRsIndex(parameterIndex)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getString(java.lang.String) */ public synchronized String getString(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= String retValue = rs.getString(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getTime(int) */ public synchronized Time getTime(int parameterIndex) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); Time retValue = rs .getTime(mapOutputParameterIndexToRsIndex(parameterIndex)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getTime(int, java.util.Calendar) */ public synchronized Time getTime(int parameterIndex, Calendar cal) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); Time retValue = rs.getTime( mapOutputParameterIndexToRsIndex(parameterIndex), cal); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getTime(java.lang.String) */ public synchronized Time getTime(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= Time retValue = rs.getTime(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getTime(java.lang.String, * java.util.Calendar) */ public synchronized Time getTime(String parameterName, Calendar cal) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= Time retValue = rs.getTime(fixParameterName(parameterName), cal); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getTimestamp(int) */ public synchronized Timestamp getTimestamp(int parameterIndex) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); Timestamp retValue = rs .getTimestamp(mapOutputParameterIndexToRsIndex(parameterIndex)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getTimestamp(int, java.util.Calendar) */ public synchronized Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); Timestamp retValue = rs.getTimestamp( mapOutputParameterIndexToRsIndex(parameterIndex), cal); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getTimestamp(java.lang.String) */ public synchronized Timestamp getTimestamp(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= Timestamp retValue = rs.getTimestamp(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getTimestamp(java.lang.String, * java.util.Calendar) */ public synchronized Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= Timestamp retValue = rs.getTimestamp(fixParameterName(parameterName), cal); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getURL(int) */ public synchronized URL getURL(int parameterIndex) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(parameterIndex); URL retValue = rs .getURL(mapOutputParameterIndexToRsIndex(parameterIndex)); this.outputParamWasNull = rs.wasNull(); return retValue; } /** * @see java.sql.CallableStatement#getURL(java.lang.String) */ public synchronized URL getURL(String parameterName) throws SQLException { ResultSetInternalMethods rs = getOutputParameters(0); // definitely not going to be // from ?= URL retValue = rs.getURL(fixParameterName(parameterName)); this.outputParamWasNull = rs.wasNull(); return retValue; } protected int mapOutputParameterIndexToRsIndex(int paramIndex) throws SQLException { if (this.returnValueParam != null && paramIndex == 1) { return 1; } checkParameterIndexBounds(paramIndex); int localParamIndex = paramIndex - 1; if (this.placeholderToParameterIndexMap != null) { localParamIndex = this.placeholderToParameterIndexMap[localParamIndex]; } int rsIndex = this.parameterIndexToRsIndex[localParamIndex]; if (rsIndex == NOT_OUTPUT_PARAMETER_INDICATOR) { throw SQLError.createSQLException( Messages.getString("CallableStatement.21") + paramIndex //$NON-NLS-1$ + Messages.getString("CallableStatement.22"), //$NON-NLS-1$ SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } return rsIndex + 1; } /** * @see java.sql.CallableStatement#registerOutParameter(int, int) */ public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException { CallableStatementParam paramDescriptor = checkIsOutputParam(parameterIndex);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -