@@ -81,7 +81,7 @@ public class CallableStatementTest extends AbstractTest {
81
81
82
82
/**
83
83
* Setup before test
84
- *
84
+ *
85
85
* @throws SQLException
86
86
*/
87
87
@ BeforeAll
@@ -201,7 +201,7 @@ public void testCallableStatementSpPrepare() throws SQLException {
201
201
202
202
/**
203
203
* Tests CallableStatement.getString() with uniqueidentifier parameter
204
- *
204
+ *
205
205
* @throws SQLException
206
206
*/
207
207
@ Test
@@ -226,7 +226,7 @@ public void getStringGUIDTest() throws SQLException {
226
226
227
227
/**
228
228
* test for setNull(index, varchar) to behave as setNull(index, nvarchar) when SendStringParametersAsUnicode is true
229
- *
229
+ *
230
230
* @throws SQLException
231
231
*/
232
232
@ Test
@@ -302,7 +302,7 @@ public void testGetObjectAsLocalDateTime() throws SQLException {
302
302
303
303
/**
304
304
* Tests getObject(n, java.time.OffsetDateTime.class) and getObject(n, java.time.OffsetTime.class).
305
- *
305
+ *
306
306
* @throws SQLException
307
307
*/
308
308
@ Test
@@ -332,7 +332,7 @@ public void testGetObjectAsOffsetDateTime() throws SQLException {
332
332
333
333
/**
334
334
* recognize parameter names with and without leading '@'
335
- *
335
+ *
336
336
* @throws SQLException
337
337
*/
338
338
@ Test
@@ -1067,9 +1067,92 @@ public void testRegisteringOutputByIndexandAcquiringOutputParamByName() throws S
1067
1067
}
1068
1068
}
1069
1069
1070
+ @ Test
1071
+ public void testExecuteSystemStoredProcedureNamedParametersAndIndexedParameterNoResultset () throws SQLException {
1072
+ String call0 = "EXEC sp_getapplock @Resource=?, @LockTimeout='0', @LockMode='Exclusive', @LockOwner='Session'" ;
1073
+ String call1 = "\r EXEC\r \r sp_getapplock @Resource=?, @LockTimeout='0', @LockMode='Exclusive', @LockOwner='Session'" ;
1074
+ String call2 = " EXEC sp_getapplock @Resource=?, @LockTimeout='0', @LockMode='Exclusive', @LockOwner='Session'" ;
1075
+ String call3 = "\t EXEC\t \t \t sp_getapplock @Resource=?, @LockTimeout='0', @LockMode='Exclusive', @LockOwner='Session'" ;
1076
+
1077
+ try (CallableStatement cstmt0 = connection .prepareCall (call0 );
1078
+ CallableStatement cstmt1 = connection .prepareCall (call1 );
1079
+ CallableStatement cstmt2 = connection .prepareCall (call2 );
1080
+ CallableStatement cstmt3 = connection .prepareCall (call3 );) {
1081
+ cstmt0 .setString (1 , "Resource-" + UUID .randomUUID ());
1082
+ cstmt0 .execute ();
1083
+
1084
+ cstmt1 .setString (1 , "Resource-" + UUID .randomUUID ());
1085
+ cstmt1 .execute ();
1086
+
1087
+ cstmt2 .setString (1 , "Resource-" + UUID .randomUUID ());
1088
+ cstmt2 .execute ();
1089
+
1090
+ cstmt3 .setString (1 , "Resource-" + UUID .randomUUID ());
1091
+ cstmt3 .execute ();
1092
+ }
1093
+ }
1094
+
1095
+ @ Test
1096
+ public void testExecSystemStoredProcedureNamedParametersAndIndexedParameterResultSet () throws SQLException {
1097
+ String call = "exec sp_sproc_columns_100 ?, @ODBCVer=3, @fUsePattern=0" ;
1098
+
1099
+ try (CallableStatement cstmt = connection .prepareCall (call )) {
1100
+ cstmt .setString (1 , "sp_getapplock" );
1101
+
1102
+ try (ResultSet rs = cstmt .executeQuery ()) {
1103
+ while (rs .next ()) {
1104
+ assertTrue (TestResource .getResource ("R_resultSetEmpty" ), !rs .getString (4 ).isEmpty ());
1105
+ }
1106
+ }
1107
+ }
1108
+ }
1109
+
1110
+ @ Test
1111
+ public void testExecSystemStoredProcedureNoIndexedParametersResultSet () throws SQLException {
1112
+ String call = "execute sp_sproc_columns_100 sp_getapplock, @ODBCVer=3, @fUsePattern=0" ;
1113
+
1114
+ try (CallableStatement cstmt = connection .prepareCall (call ); ResultSet rs = cstmt .executeQuery ()) {
1115
+ while (rs .next ()) {
1116
+ assertTrue (TestResource .getResource ("R_resultSetEmpty" ), !rs .getString (4 ).isEmpty ());
1117
+ }
1118
+ }
1119
+ }
1120
+
1121
+ @ Test
1122
+ public void testExecDocumentedSystemStoredProceduresIndexedParameters () throws SQLException {
1123
+ String serverName ;
1124
+ String testTableName = "testTable" ;
1125
+ Integer integer = new Integer (1 );
1126
+
1127
+ try (Statement stmt = connection .createStatement (); ResultSet rs = stmt .executeQuery ("SELECT @@SERVERNAME" )) {
1128
+ rs .next ();
1129
+ serverName = rs .getString (1 );
1130
+ }
1131
+
1132
+ String [] sprocs = {"EXEC sp_column_privileges ?" , "exec sp_catalogs ?" , "execute sp_column_privileges ?" ,
1133
+ "EXEC sp_column_privileges_ex ?" , "EXECUTE sp_columns ?" , "execute sp_datatype_info ?" ,
1134
+ "EXEC sp_sproc_columns ?" , "EXECUTE sp_server_info ?" , "exec sp_special_columns ?" ,
1135
+ "execute sp_statistics ?" , "EXEC sp_table_privileges ?" , "exec sp_tables ?" };
1136
+
1137
+ Object [] params = {testTableName , serverName , testTableName , serverName , testTableName , integer ,
1138
+ "sp_column_privileges" , integer , testTableName , testTableName , testTableName , testTableName };
1139
+
1140
+ int paramIndex = 0 ;
1141
+
1142
+ for (String sproc : sprocs ) {
1143
+ try (CallableStatement cstmt = connection .prepareCall (sproc )) {
1144
+ cstmt .setObject (1 , params [paramIndex ]);
1145
+ cstmt .execute ();
1146
+ paramIndex ++;
1147
+ } catch (Exception e ) {
1148
+ fail ("Failed executing '" + sproc + "' with indexed parameter '" + params [paramIndex ]);
1149
+ }
1150
+ }
1151
+ }
1152
+
1070
1153
/**
1071
1154
* Cleanup after test
1072
- *
1155
+ *
1073
1156
* @throws SQLException
1074
1157
*/
1075
1158
@ AfterAll
0 commit comments