Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute cstmt directly - Additional testing and changes #2284

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ enum CallableStatementGetterSetterMethod {

@Override
public void registerOutParameter(int index, int sqlType) throws SQLServerException {
// Register output parameter by index
isSetByIndex = true;
if (!connection.getUseFlexibleCallableStatements() && isSetByName && isSetByIndex) {
SQLServerException.makeFromDriverError(connection, this,
SQLServerException.getErrString("R_noNamedAndIndexedParameters"), null, false);
}
registerOutputParameter(index, sqlType);
}

private void registerOutParameterByName(int index, int sqlType) throws SQLServerException {
// Register output parameter by name -- findColumn() sets the 'setByName' flag
registerOutputParameter(index, sqlType);
}

void registerOutParameterNonPLP(int index, int sqlType) throws SQLServerException {
registerOutParameter(index, sqlType);
inOutParam[index - 1].isNonPLP = true;
}

private void registerOutputParameter(int index, int sqlType) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "registerOutParameter", new Object[] {index, sqlType});
checkClosed();
Expand Down Expand Up @@ -171,11 +191,6 @@ public void registerOutParameter(int index, int sqlType) throws SQLServerExcepti
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}

void registerOutParameterNonPLP(int index, int sqlType) throws SQLServerException {
registerOutParameter(index, sqlType);
inOutParam[index - 1].isNonPLP = true;
}

/**
* Locate any output parameter values returned from the procedure call
*/
Expand Down Expand Up @@ -542,6 +557,7 @@ private Object getSQLXMLInternal(int parameterIndex) throws SQLServerException {

@Override
public int getInt(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getInt", index);
checkClosed();
Integer value = (Integer) getValue(index, JDBCType.INTEGER);
Expand All @@ -561,6 +577,7 @@ public int getInt(String parameterName) throws SQLServerException {

@Override
public String getString(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getString", index);
checkClosed();
String value = null;
Expand Down Expand Up @@ -588,6 +605,7 @@ public String getString(String parameterName) throws SQLServerException {

@Override
public final String getNString(int parameterIndex) throws SQLException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getNString", parameterIndex);
checkClosed();
String value = (String) getValue(parameterIndex, JDBCType.NCHAR);
Expand All @@ -611,6 +629,7 @@ public final String getNString(String parameterName) throws SQLException {
@Deprecated(since = "6.5.4")
@Override
public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getBigDecimal", new Object[] {parameterIndex, scale});
checkClosed();
Expand Down Expand Up @@ -640,6 +659,7 @@ public BigDecimal getBigDecimal(String parameterName, int scale) throws SQLServe

@Override
public boolean getBoolean(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getBoolean", index);
checkClosed();
Boolean value = (Boolean) getValue(index, JDBCType.BIT);
Expand All @@ -659,6 +679,7 @@ public boolean getBoolean(String parameterName) throws SQLServerException {

@Override
public byte getByte(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getByte", index);
checkClosed();
Short shortValue = (Short) getValue(index, JDBCType.TINYINT);
Expand All @@ -680,6 +701,7 @@ public byte getByte(String parameterName) throws SQLServerException {

@Override
public byte[] getBytes(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getBytes", index);
checkClosed();
byte[] value = (byte[]) getValue(index, JDBCType.BINARY);
Expand All @@ -699,6 +721,7 @@ public byte[] getBytes(String parameterName) throws SQLServerException {

@Override
public Date getDate(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getDate", index);
checkClosed();
java.sql.Date value = (java.sql.Date) getValue(index, JDBCType.DATE);
Expand All @@ -718,6 +741,7 @@ public Date getDate(String parameterName) throws SQLServerException {

@Override
public Date getDate(int index, Calendar cal) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getDate", new Object[] {index, cal});
checkClosed();
Expand All @@ -739,6 +763,7 @@ public Date getDate(String parameterName, Calendar cal) throws SQLServerExceptio

@Override
public double getDouble(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getDouble", index);
checkClosed();
Double value = (Double) getValue(index, JDBCType.DOUBLE);
Expand All @@ -758,6 +783,7 @@ public double getDouble(String parameterName) throws SQLServerException {

@Override
public float getFloat(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getFloat", index);
checkClosed();
Float value = (Float) getValue(index, JDBCType.REAL);
Expand All @@ -777,7 +803,7 @@ public float getFloat(String parameterName) throws SQLServerException {

@Override
public long getLong(int index) throws SQLServerException {

setByIndex();
loggerExternal.entering(getClassNameLogging(), "getLong", index);
checkClosed();
Long value = (Long) getValue(index, JDBCType.BIGINT);
Expand All @@ -797,7 +823,7 @@ public long getLong(String parameterName) throws SQLServerException {

@Override
public Object getObject(int index) throws SQLServerException {

setByIndex();
loggerExternal.entering(getClassNameLogging(), "getObject", index);
checkClosed();
Object value = getValue(index,
Expand All @@ -809,6 +835,7 @@ public Object getObject(int index) throws SQLServerException {

@Override
public <T> T getObject(int index, Class<T> type) throws SQLException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getObject", index);
checkClosed();
Object returnValue;
Expand Down Expand Up @@ -923,6 +950,7 @@ public <T> T getObject(String parameterName, Class<T> type) throws SQLException

@Override
public short getShort(int index) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getShort", index);
checkClosed();
Short value = (Short) getValue(index, JDBCType.SMALLINT);
Expand All @@ -942,7 +970,7 @@ public short getShort(String parameterName) throws SQLServerException {

@Override
public Time getTime(int index) throws SQLServerException {

setByIndex();
loggerExternal.entering(getClassNameLogging(), "getTime", index);
checkClosed();
java.sql.Time value = (java.sql.Time) getValue(index, JDBCType.TIME);
Expand All @@ -962,6 +990,7 @@ public Time getTime(String parameterName) throws SQLServerException {

@Override
public Time getTime(int index, Calendar cal) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getTime", new Object[] {index, cal});
checkClosed();
Expand All @@ -983,6 +1012,7 @@ public Time getTime(String parameterName, Calendar cal) throws SQLServerExceptio

@Override
public Timestamp getTimestamp(int index) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), GET_TIMESTAMP, index);
checkClosed();
Expand All @@ -1003,6 +1033,7 @@ public Timestamp getTimestamp(String parameterName) throws SQLServerException {

@Override
public Timestamp getTimestamp(int index, Calendar cal) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), GET_TIMESTAMP, new Object[] {index, cal});
checkClosed();
Expand All @@ -1024,6 +1055,7 @@ public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLServ
}

LocalDateTime getLocalDateTime(int columnIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getLocalDateTime", columnIndex);
checkClosed();
LocalDateTime value = (LocalDateTime) getValue(columnIndex, JDBCType.LOCALDATETIME);
Expand All @@ -1033,6 +1065,7 @@ LocalDateTime getLocalDateTime(int columnIndex) throws SQLServerException {

@Override
public Timestamp getDateTime(int index) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getDateTime", index);
checkClosed();
Expand All @@ -1053,6 +1086,7 @@ public Timestamp getDateTime(String parameterName) throws SQLServerException {

@Override
public Timestamp getDateTime(int index, Calendar cal) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getDateTime", new Object[] {index, cal});
checkClosed();
Expand All @@ -1075,6 +1109,7 @@ public Timestamp getDateTime(String parameterName, Calendar cal) throws SQLServe

@Override
public Timestamp getSmallDateTime(int index) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getSmallDateTime", index);
checkClosed();
Expand All @@ -1096,6 +1131,7 @@ public Timestamp getSmallDateTime(String parameterName) throws SQLServerExceptio

@Override
public Timestamp getSmallDateTime(int index, Calendar cal) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getSmallDateTime", new Object[] {index, cal});
checkClosed();
Expand All @@ -1118,6 +1154,7 @@ public Timestamp getSmallDateTime(String parameterName, Calendar cal) throws SQL

@Override
public microsoft.sql.DateTimeOffset getDateTimeOffset(int index) throws SQLServerException {
setByIndex();
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "getDateTimeOffset", index);
checkClosed();
Expand Down Expand Up @@ -1163,6 +1200,7 @@ public boolean wasNull() throws SQLServerException {

@Override
public final java.io.InputStream getAsciiStream(int parameterIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getAsciiStream", parameterIndex);
checkClosed();
InputStream value = (InputStream) getStream(parameterIndex, StreamType.ASCII);
Expand All @@ -1182,6 +1220,7 @@ public final java.io.InputStream getAsciiStream(String parameterName) throws SQL

@Override
public BigDecimal getBigDecimal(int parameterIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getBigDecimal", parameterIndex);
checkClosed();
BigDecimal value = (BigDecimal) getValue(parameterIndex, JDBCType.DECIMAL);
Expand All @@ -1201,6 +1240,7 @@ public BigDecimal getBigDecimal(String parameterName) throws SQLServerException

@Override
public BigDecimal getMoney(int parameterIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getMoney", parameterIndex);
checkClosed();
BigDecimal value = (BigDecimal) getValue(parameterIndex, JDBCType.MONEY);
Expand All @@ -1220,6 +1260,7 @@ public BigDecimal getMoney(String parameterName) throws SQLServerException {

@Override
public BigDecimal getSmallMoney(int parameterIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getSmallMoney", parameterIndex);
checkClosed();
BigDecimal value = (BigDecimal) getValue(parameterIndex, JDBCType.SMALLMONEY);
Expand All @@ -1239,6 +1280,7 @@ public BigDecimal getSmallMoney(String parameterName) throws SQLServerException

@Override
public final java.io.InputStream getBinaryStream(int parameterIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getBinaryStream", parameterIndex);
checkClosed();
InputStream value = (InputStream) getStream(parameterIndex, StreamType.BINARY);
Expand All @@ -1258,6 +1300,7 @@ public final java.io.InputStream getBinaryStream(String parameterName) throws SQ

@Override
public Blob getBlob(int parameterIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getBlob", parameterIndex);
checkClosed();
Blob value = (Blob) getValue(parameterIndex, JDBCType.BLOB);
Expand All @@ -1277,6 +1320,7 @@ public Blob getBlob(String parameterName) throws SQLServerException {

@Override
public final java.io.Reader getCharacterStream(int parameterIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getCharacterStream", parameterIndex);
checkClosed();
Reader reader = (Reader) getStream(parameterIndex, StreamType.CHARACTER);
Expand All @@ -1296,6 +1340,7 @@ public final java.io.Reader getCharacterStream(String parameterName) throws SQLE

@Override
public final java.io.Reader getNCharacterStream(int parameterIndex) throws SQLException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getNCharacterStream", parameterIndex);
checkClosed();
Reader reader = (Reader) getStream(parameterIndex, StreamType.NCHARACTER);
Expand Down Expand Up @@ -1327,6 +1372,7 @@ void closeActiveStream() throws SQLServerException {

@Override
public Clob getClob(int parameterIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getClob", parameterIndex);
checkClosed();
Clob clob = (Clob) getValue(parameterIndex, JDBCType.CLOB);
Expand All @@ -1346,6 +1392,7 @@ public Clob getClob(String parameterName) throws SQLServerException {

@Override
public NClob getNClob(int parameterIndex) throws SQLException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getNClob", parameterIndex);
checkClosed();
NClob nClob = (NClob) getValue(parameterIndex, JDBCType.NCLOB);
Expand Down Expand Up @@ -2455,6 +2502,7 @@ public final void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLEx

@Override
public final SQLXML getSQLXML(int parameterIndex) throws SQLException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getSQLXML", parameterIndex);
checkClosed();
SQLServerSQLXML value = (SQLServerSQLXML) getSQLXMLInternal(parameterIndex);
Expand Down Expand Up @@ -2495,8 +2543,11 @@ public void registerOutParameter(String parameterName, int sqlType, String typeN
loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
new Object[] {parameterName, sqlType, typeName});
checkClosed();
registerOutParameter(findColumn(parameterName, CallableStatementGetterSetterMethod.IS_SETTER_METHOD), sqlType,
typeName);

int index = findColumn(parameterName, CallableStatementGetterSetterMethod.IS_SETTER_METHOD);

registerOutParameterByName(index, sqlType);

loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}

Expand All @@ -2506,8 +2557,12 @@ public void registerOutParameter(String parameterName, int sqlType, int scale) t
loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
new Object[] {parameterName, sqlType, scale});
checkClosed();
registerOutParameter(findColumn(parameterName, CallableStatementGetterSetterMethod.IS_SETTER_METHOD), sqlType,
scale);

int index = findColumn(parameterName, CallableStatementGetterSetterMethod.IS_SETTER_METHOD);

registerOutParameterByName(index, sqlType);
inOutParam[index - 1].setOutScale(scale);

loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}

Expand All @@ -2516,10 +2571,15 @@ public void registerOutParameter(String parameterName, int sqlType, int precisio
int scale) throws SQLServerException {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
new Object[] {parameterName, sqlType, scale});
new Object[] {parameterName, sqlType, scale, precision});
checkClosed();
registerOutParameter(findColumn(parameterName, CallableStatementGetterSetterMethod.IS_SETTER_METHOD), sqlType,
precision, scale);

int index = findColumn(parameterName, CallableStatementGetterSetterMethod.IS_SETTER_METHOD);

registerOutParameterByName(index, sqlType);
inOutParam[index - 1].setValueLength(precision);
inOutParam[index - 1].setOutScale(scale);

loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}

Expand All @@ -2529,7 +2589,7 @@ public void registerOutParameter(String parameterName, int sqlType) throws SQLSe
loggerExternal.entering(getClassNameLogging(), "registerOutParameter",
new Object[] {parameterName, sqlType});
checkClosed();
registerOutParameter(findColumn(parameterName, CallableStatementGetterSetterMethod.IS_SETTER_METHOD), sqlType);
registerOutParameterByName(findColumn(parameterName, CallableStatementGetterSetterMethod.IS_SETTER_METHOD), sqlType);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
}

Expand Down
Loading
Loading