@@ -158,8 +158,9 @@ public void testPrepareAndExecute() {
158158 statement .execute ("USE " + DATABASE_NAME );
159159 // Prepare a statement
160160 statement .execute ("PREPARE stmt1 FROM SELECT * FROM test_table WHERE id = ?" );
161- // Execute with parameter
162- tableResultSetEqualTest ("EXECUTE stmt1 USING 2" , expectedHeader , retArray , DATABASE_NAME );
161+ // Execute with parameter using write connection directly
162+ executePreparedStatementAndVerify (
163+ connection , statement , "EXECUTE stmt1 USING 2" , expectedHeader , retArray );
163164 // Deallocate
164165 statement .execute ("DEALLOCATE PREPARE stmt1" );
165166 } catch (SQLException e ) {
@@ -177,9 +178,11 @@ public void testPrepareAndExecuteMultipleTimes() {
177178 statement .execute ("USE " + DATABASE_NAME );
178179 // Prepare a statement
179180 statement .execute ("PREPARE stmt2 FROM SELECT * FROM test_table WHERE id = ?" );
180- // Execute multiple times with different parameters
181- tableResultSetEqualTest ("EXECUTE stmt2 USING 1" , expectedHeader , retArray1 , DATABASE_NAME );
182- tableResultSetEqualTest ("EXECUTE stmt2 USING 3" , expectedHeader , retArray2 , DATABASE_NAME );
181+ // Execute multiple times with different parameters using write connection directly
182+ executePreparedStatementAndVerify (
183+ connection , statement , "EXECUTE stmt2 USING 1" , expectedHeader , retArray1 );
184+ executePreparedStatementAndVerify (
185+ connection , statement , "EXECUTE stmt2 USING 3" , expectedHeader , retArray2 );
183186 // Deallocate
184187 statement .execute ("DEALLOCATE PREPARE stmt2" );
185188 } catch (SQLException e ) {
@@ -196,9 +199,9 @@ public void testPrepareWithMultipleParameters() {
196199 statement .execute ("USE " + DATABASE_NAME );
197200 // Prepare a statement with multiple parameters
198201 statement .execute ("PREPARE stmt3 FROM SELECT * FROM test_table WHERE id = ? AND value > ?" );
199- // Execute with multiple parameters
200- tableResultSetEqualTest (
201- "EXECUTE stmt3 USING 2, 150.0" , expectedHeader , retArray , DATABASE_NAME );
202+ // Execute with multiple parameters using write connection directly
203+ executePreparedStatementAndVerify (
204+ connection , statement , "EXECUTE stmt3 USING 2, 150.0" , expectedHeader , retArray );
202205 // Deallocate
203206 statement .execute ("DEALLOCATE PREPARE stmt3" );
204207 } catch (SQLException e ) {
@@ -306,10 +309,11 @@ public void testMultiplePreparedStatements() {
306309 // Prepare multiple statements
307310 statement .execute ("PREPARE stmt4 FROM SELECT * FROM test_table WHERE id = ?" );
308311 statement .execute ("PREPARE stmt5 FROM SELECT COUNT(*) FROM test_table WHERE value > ?" );
309- // Execute both statements
310- tableResultSetEqualTest ("EXECUTE stmt4 USING 1" , expectedHeader1 , retArray1 , DATABASE_NAME );
311- tableResultSetEqualTest (
312- "EXECUTE stmt5 USING 200.0" , expectedHeader2 , retArray2 , DATABASE_NAME );
312+ // Execute both statements using write connection directly
313+ executePreparedStatementAndVerify (
314+ connection , statement , "EXECUTE stmt4 USING 1" , expectedHeader1 , retArray1 );
315+ executePreparedStatementAndVerify (
316+ connection , statement , "EXECUTE stmt5 USING 200.0" , expectedHeader2 , retArray2 );
313317 // Deallocate both
314318 statement .execute ("DEALLOCATE PREPARE stmt4" );
315319 statement .execute ("DEALLOCATE PREPARE stmt5" );
@@ -350,8 +354,9 @@ public void testPrepareAndExecuteWithAggregation() {
350354 // Prepare a statement with aggregation
351355 statement .execute (
352356 "PREPARE stmt7 FROM SELECT AVG(value) FROM test_table WHERE id >= ? AND id <= ?" );
353- // Execute with parameters
354- tableResultSetEqualTest ("EXECUTE stmt7 USING 2, 4" , expectedHeader , retArray , DATABASE_NAME );
357+ // Execute with parameters using write connection directly
358+ executePreparedStatementAndVerify (
359+ connection , statement , "EXECUTE stmt7 USING 2, 4" , expectedHeader , retArray );
355360 // Deallocate
356361 statement .execute ("DEALLOCATE PREPARE stmt7" );
357362 } catch (SQLException e ) {
@@ -368,9 +373,9 @@ public void testPrepareAndExecuteWithStringParameter() {
368373 statement .execute ("USE " + DATABASE_NAME );
369374 // Prepare a statement with string parameter
370375 statement .execute ("PREPARE stmt8 FROM SELECT * FROM test_table WHERE name = ?" );
371- // Execute with string parameter
372- tableResultSetEqualTest (
373- "EXECUTE stmt8 USING 'Charlie'" , expectedHeader , retArray , DATABASE_NAME );
376+ // Execute with string parameter using write connection directly
377+ executePreparedStatementAndVerify (
378+ connection , statement , "EXECUTE stmt8 USING 'Charlie'" , expectedHeader , retArray );
374379 // Deallocate
375380 statement .execute ("DEALLOCATE PREPARE stmt8" );
376381 } catch (SQLException e ) {
0 commit comments