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

Calling stored procedure directly #547

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7e70acb
read all responses before proceed
xiangyushawn Aug 9, 2017
30822e9
use a new method to determind if there are pending responses
xiangyushawn Aug 9, 2017
2c41c21
use raiserror instead of throw
xiangyushawn Aug 9, 2017
edd32b4
check if reach the end of the current packet
xiangyushawn Aug 9, 2017
f7d87f0
fix another failure for batching: if error happens, driver re-tries a…
xiangyushawn Aug 10, 2017
ed54cf2
add tests to validate how many times the column is updated by SP
xiangyushawn Aug 10, 2017
ef5c9b7
throw exception also fixes batch issue
xiangyushawn Aug 15, 2017
1e9b7a5
refactor code and use existing method
xiangyushawn Aug 18, 2017
53be4ab
refactor code
xiangyushawn Sep 13, 2017
edb19d2
Merge branch 'redundant-String-toString' of https://github.com/JamieM…
AfsanehR-zz Sep 29, 2017
afab91e
Merge branch 'cleanupTables' of https://github.com/v-afrafi/mssql-jdb…
AfsanehR-zz Oct 2, 2017
34d7b55
Merge branch 'dev' of https://github.com/Microsoft/mssql-jdbc into dev
AfsanehR-zz Oct 3, 2017
a159921
Merge branch 'dev' of https://github.com/Microsoft/mssql-jdbc into dev
AfsanehR-zz Oct 3, 2017
de21e71
Merge branch 'replace-bare-literals' of https://github.com/JamieMagee…
AfsanehR-zz Oct 6, 2017
845493a
Merge branch 'allow-at-sign-prefixed-param-names' of https://github.c…
AfsanehR-zz Oct 6, 2017
65aca83
Merge branch 'dev' of https://github.com/Microsoft/mssql-jdbc into dev
AfsanehR-zz Oct 6, 2017
8a217f6
Merge branch 'allow-at-sign-prefixed-param-names' of https://github.c…
AfsanehR-zz Oct 6, 2017
ad53d7a
Merge branch 'SQLServerDataTableImprovement-497' of https://github.co…
AfsanehR-zz Oct 6, 2017
385296f
Merge branch 'process-all-responses-before-proceed' of https://github…
AfsanehR-zz Oct 25, 2017
4223ccc
Merge branch 'dev' of https://github.com/Microsoft/mssql-jdbc into dev
AfsanehR-zz Oct 25, 2017
35e7195
Merge branch 'dev' of https://github.com/Microsoft/mssql-jdbc into dev
AfsanehR-zz Oct 31, 2017
de742d0
first commits of calling stored procedure directly
AfsanehR-zz Oct 31, 2017
9e28925
first commit of executing stored procedure directly
AfsanehR-zz Oct 31, 2017
e366910
cleaning up code
AfsanehR-zz Oct 31, 2017
d39f431
fixed an issue with not resetting TVPType check
AfsanehR-zz Oct 31, 2017
f02476f
resetting the access to returnValueAccessed
AfsanehR-zz Oct 31, 2017
a694b7f
remove the dependecy on expectedValueReturn and use inoutParams inste…
AfsanehR-zz Nov 1, 2017
9bc7257
cleaned up AE test and removed a wrong assertion
AfsanehR-zz Nov 1, 2017
b04eb93
make ae tests failures more clear in asserts
AfsanehR-zz Nov 1, 2017
7cbc486
fixed the failure for AE tests. Writing datetime as datetime if jdbct…
AfsanehR-zz Nov 6, 2017
839fc82
remove unused code
AfsanehR-zz Nov 8, 2017
263702d
fix the logging of calling procedure
AfsanehR-zz Nov 10, 2017
f8409ca
check for valid stored procedure calls like "exec proc 1, ?" where we…
AfsanehR-zz Nov 16, 2017
3f76e02
remove the metadata lookup for named parameters
AfsanehR-zz Nov 23, 2017
4439983
resolve conflicts with dev branch
AfsanehR-zz Nov 23, 2017
fb2c765
Merge branch 'dev' of https://github.com/Microsoft/mssql-jdbc into st…
AfsanehR-zz Nov 23, 2017
8b8a26a
added a fix for mix of setting input and output params
AfsanehR-zz Nov 24, 2017
5a757d9
added enum to make getterSetter Methods more clear plus other review …
AfsanehR-zz Nov 28, 2017
63f47d8
Merge branch 'dev' into storedProcedure
cheenamalhotra Feb 23, 2018
196671f
Merge branch 'dev' into storedProcedure
cheenamalhotra Jun 19, 2018
c9609e5
Merge branch 'dev' into storedProcedure
cheenamalhotra Feb 4, 2019
d92c133
Changes as per PR for storedProcedure calls
Feb 4, 2019
634f7cc
Fixes for breaking tests.
Feb 5, 2019
c198d11
Merge branch 'ms-dev' into af-storedProcedure
Feb 5, 2019
bdf49a1
Merge branch 'storedProcedure' into af-storedProcedure
Feb 5, 2019
8c68b58
Fix Statement Test
Feb 5, 2019
1a0373f
Code formatting
Feb 5, 2019
c9ad021
Merge branch 'dev' into storedProcedure
cheenamalhotra Mar 18, 2019
8442168
Merge branch 'dev' into storedProcedure
cheenamalhotra May 19, 2019
324d2b0
Merge branch 'dev' into storedProcedure
cheenamalhotra Jun 5, 2019
ac53c28
Fix conflict issues
cheenamalhotra Jun 6, 2019
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
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6385,7 +6385,7 @@ private boolean nextPacket() throws SQLServerException {
payloadOffset = 0;
return true;
}

/**
* Reads the next packet of the TDS channel.
*
Expand Down
112 changes: 94 additions & 18 deletions src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ final CryptoMetadata getCryptoMetadata() {
private boolean shouldHonorAEForParameter = false;
private boolean userProvidesPrecision = false;
private boolean userProvidesScale = false;
private boolean isReturnValue = false;

// The parameter type definition
private String typeDefinition = null;
Expand All @@ -65,14 +66,77 @@ final CryptoMetadata getCryptoMetadata() {
shouldHonorAEForParameter = honorAE;
}

// Flag set to true if this is a registered OUTPUT parameter.
/**
* Returns true if this is a registered OUTPUT parameter.
*
* @return true/false
*/
boolean isOutput() {
return null != registeredOutDTV;
}

// Since a parameter can have only one type definition for both sending its value to the server (IN)
// and getting its value from the server (OUT), we use the JDBC type of the IN parameter value if there
// is one; otherwise we use the registered OUT param JDBC type.
/**
* Returns true/false if the parameter is of return type
*
* @return isReturnValue
*/
boolean isReturnValue() {
return isReturnValue;
}

/**
* Sets the parameter to be of return type
*
* @param isReturnValue
*/
void setReturnValue(boolean isReturnValue) {
this.isReturnValue = isReturnValue;
}

/**
* Sets the name of the parameter
*
* @param name
*/
void setName(String name) {
this.name = name;
}

/**
* Retrieve the name of the parameter
*
* @return
*/
String getName() {
return this.name;
}

/**
* Returns the `registeredOutDTV` instance of the parameter
*
* @return registeredOutDTV
*/
DTV getRegisteredOutDTV() {
return this.registeredOutDTV;
}

/**
* Returns the `inputDTV` instance of the parameter
*
* @return inputDTV
*/
DTV getInputDTV() {
return this.inputDTV;
}

/**
* Since a parameter can have only one type definition for both sending its value to the server (IN) and getting its
* value from the server (OUT), we use the JDBC type of the IN parameter value if there is one; otherwise we use the
* registered OUT param JDBC type.
*
* @throws SQLServerException
* if an error occurs
**/
JDBCType getJdbcType() throws SQLServerException {
return (null != inputDTV) ? inputDTV.getJdbcType() : JDBCType.UNKNOWN;
}
Expand All @@ -96,20 +160,29 @@ private static JDBCType getSSPAUJDBCType(JDBCType jdbcType) {
}
}

// For parameters whose underlying type is not represented by a JDBC type
// the transport type reflects how the value is sent to the
// server (e.g. JDBCType.CHAR for GUID parameters).
/**
* For parameters whose underlying type is not represented by a JDBC type the transport type reflects how the value
* is sent to the server (e.g. JDBCType.CHAR for GUID parameters).
*
* @param jdbcType
* JDBCType of the parameter
* @param con
* Connection reference to work with
* @throws SQLServerException
* if an error occurs
*/
void registerForOutput(JDBCType jdbcType, SQLServerConnection con) throws SQLServerException {
// DateTimeOffset is not supported with SQL Server versions earlier than Katmai
if (JDBCType.DATETIMEOFFSET == jdbcType && !con.isKatmaiOrLater()) {
throw new SQLServerException(SQLServerException.getErrString("R_notSupported"),
SQLState.DATA_EXCEPTION_NOT_SPECIFIC, DriverError.NOT_SET, null);
}

// sendStringParametersAsUnicode
// If set to true, this connection property tells the driver to send textual parameters
// to the server as Unicode rather than MBCS. This is accomplished here by re-tagging
// the value with the appropriate corresponding Unicode type.
/*
* Check for sendStringParametersAsUnicode: If set to true, this connection property tells the driver to send
* textual parameters to the server as Unicode rather than MBCS. This is accomplished here by re-tagging the
* value with the appropriate corresponding Unicode type.
*/
if (con.sendStringParametersAsUnicode()) {

if (shouldHonorAEForParameter) {
Expand All @@ -130,9 +203,10 @@ void registerForOutput(JDBCType jdbcType, SQLServerConnection con) throws SQLSer

int scale = 0;

// Scale requested for a DECIMAL and NUMERIC OUT parameter. If the OUT parameter
// is also non-null IN parameter, the scale will be the larger of this value and
// the value of the IN parameter's scale.
/**
* Scale requested for a DECIMAL and NUMERIC OUT parameter. If the OUT parameter is also non-null IN parameter, the
* scale will be the larger of this value and the value of the IN parameter's scale.
**/
private int outScale = 4;

int getOutScale() {
Expand Down Expand Up @@ -246,7 +320,7 @@ void setFromReturnStatus(int returnStatus, SQLServerConnection con) throws SQLSe
if (null == getterDTV)
getterDTV = new DTV();

getterDTV.setValue(null, JDBCType.INTEGER, returnStatus, JavaType.INTEGER, null, null, null, con,
getterDTV.setValue(null, this.getJdbcType(), returnStatus, JavaType.INTEGER, null, null, null, con,
getForceEncryption());
}

Expand Down Expand Up @@ -390,10 +464,12 @@ boolean isValueGotten() {

Object getValue(JDBCType jdbcType, InputStreamGetterArgs getterArgs, Calendar cal,
TDSReader tdsReader) throws SQLServerException {
if (null == getterDTV)
if (null == getterDTV) {
getterDTV = new DTV();

deriveTypeInfo(tdsReader);
}
if (null != tdsReader) {
deriveTypeInfo(tdsReader);
}
// If the parameter is not encrypted or column encryption is turned off (either at connection or
// statement level), cryptoMeta would be null.
return getterDTV.getValue(jdbcType, outScale, getterArgs, cal, typeInfo, cryptoMeta, tdsReader);
Expand Down
Loading