Skip to content

Commit

Permalink
Revert "Execute cstmt directly - Additional testing and changes (#2284)"
Browse files Browse the repository at this point in the history
This reverts commit 92cfe0d.
  • Loading branch information
tkyc committed Aug 13, 2024
1 parent 376fc49 commit 96d7409
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,6 @@ public class SQLServerCallableStatement extends SQLServerPreparedStatement imple

@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 @@ -177,6 +157,11 @@ private void registerOutputParameter(int index, int sqlType) throws SQLServerExc
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 @@ -497,7 +482,6 @@ 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 @@ -516,7 +500,6 @@ 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 All @@ -543,7 +526,6 @@ 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 @@ -566,7 +548,6 @@ 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 @@ -595,7 +576,6 @@ 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 @@ -614,7 +594,6 @@ 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 @@ -635,7 +614,6 @@ 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 @@ -654,7 +632,6 @@ 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 @@ -673,7 +650,6 @@ 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 @@ -694,7 +670,6 @@ 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 @@ -713,7 +688,6 @@ 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 @@ -733,7 +707,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 @@ -752,7 +726,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 @@ -764,7 +738,6 @@ 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 @@ -879,7 +852,6 @@ public <T> T getObject(String parameterName, Class<T> type) throws SQLException

@Override
public short getShort(int index) throws SQLServerException {

loggerExternal.entering(getClassNameLogging(), "getShort", index);
checkClosed();
Short value = (Short) getValue(index, JDBCType.SMALLINT);
Expand All @@ -898,7 +870,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 @@ -917,7 +889,6 @@ 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 @@ -938,7 +909,6 @@ 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 @@ -958,7 +928,6 @@ 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 @@ -978,7 +947,6 @@ public Timestamp getTimestamp(String name, Calendar cal) throws SQLServerExcepti
}

LocalDateTime getLocalDateTime(int columnIndex) throws SQLServerException {
setByIndex();
loggerExternal.entering(getClassNameLogging(), "getLocalDateTime", columnIndex);
checkClosed();
LocalDateTime value = (LocalDateTime) getValue(columnIndex, JDBCType.LOCALDATETIME);
Expand All @@ -988,7 +956,6 @@ 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 @@ -1008,7 +975,6 @@ 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 @@ -1029,7 +995,6 @@ public Timestamp getDateTime(String name, Calendar cal) throws SQLServerExceptio

@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 @@ -1049,7 +1014,6 @@ 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 @@ -1070,7 +1034,6 @@ public Timestamp getSmallDateTime(String name, Calendar cal) throws SQLServerExc

@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 @@ -1115,7 +1078,6 @@ 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 @@ -1134,7 +1096,6 @@ 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 @@ -1153,7 +1114,6 @@ 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 @@ -1172,7 +1132,6 @@ 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 @@ -1191,7 +1150,6 @@ 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 @@ -1210,7 +1168,6 @@ 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 @@ -1229,7 +1186,6 @@ 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 @@ -1248,7 +1204,6 @@ 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 @@ -1279,7 +1234,6 @@ 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 @@ -1298,7 +1252,6 @@ 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 @@ -2287,7 +2240,6 @@ 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 @@ -2346,7 +2298,7 @@ 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, precision});
new Object[] {parameterName, sqlType, scale});
checkClosed();
registerOutParameter(findColumn(parameterName), sqlType, precision, scale);
loggerExternal.exiting(getClassNameLogging(), "registerOutParameter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1133,14 +1133,6 @@ void checkClosed() throws SQLServerException {
}
}

void setByIndex() throws SQLServerException {
isSetByIndex = true;
if (!connection.getUseFlexibleCallableStatements() && isSetByName && isSetByIndex) {
SQLServerException.makeFromDriverError(connection, this,
SQLServerException.getErrString("R_noNamedAndIndexedParameters"), null, false);
}
}

/* ---------------- JDBC API methods ------------------ */

@Override
Expand Down
5 changes: 0 additions & 5 deletions src/test/java/com/microsoft/sqlserver/jdbc/TestResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,11 @@ protected Object[][] getContents() {
{"R_sharedTimerStopOnNoRef", "SharedTimer should be stopped after all references are removed."},
{"R_sessionKilled", "Cannot continue the execution because the session is in the kill state"},
{"R_failedFedauth", "Failed to acquire fedauth token: "},
<<<<<<< HEAD
{"R_noLoginModulesConfiguredForJdbcDriver",
"javax.security.auth.login.LoginException (No LoginModules configured for SQLJDBCDriver)"},
{"R_unexpectedThreadCount", "Thread count is higher than expected."},
{"R_expectedClassDoesNotMatchActualClass",
"Expected column class {0} does not match actual column class {1} for column {2}."},
{"R_loginFailedMI", "Login failed for user '<token-identified principal>'"},
{"R_MInotAvailable", "Managed Identity authentication is not available"},};
=======
{"R_noLoginModulesConfiguredForJdbcDriver", "javax.security.auth.login.LoginException (No LoginModules configured for SQLJDBCDriver)"},
{"R_unexpectedThreadCount", "Thread count is higher than expected."}};
>>>>>>> parent of 11680a61 (Execute Stored Procedures Directly (#2154))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.microsoft.sqlserver.jdbc.callablestatement;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
Expand All @@ -22,6 +23,7 @@
import java.util.UUID;

import com.microsoft.sqlserver.testframework.PrepUtil;
import org.junit.Assert;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
Expand Down

0 comments on commit 96d7409

Please sign in to comment.