@@ -139,87 +139,119 @@ protected void checkOpen() throws SQLException {
139139 }
140140 }
141141
142- /**
143- * Execute the SQL batch on a MS server.
144- * @param size the total size of the batch.
145- * @param executeSize the maximum number of statements to send in one request.
146- * @param counts the returned update counts.
147- * @return Chained exceptions linked to a <code>SQLException</code>.
148- * @throws SQLException
149- */
150- @ Override
151- protected SQLException executeMSBatch (int size , int executeSize , ArrayList counts )
152- throws SQLException {
153- if (parameters .length == 0 ) {
154- // No parameters so we can execute as a simple batch
155- return super .executeMSBatch (size , executeSize , counts );
156- }
157- SQLException sqlEx = null ;
158- for (int i = 0 ; i < size ;) {
159- Object value = batchValues .get (i );
160- ++i ;
161- // Execute batch now if max size reached or end of batch
162- boolean executeNow = (i % executeSize == 0 ) || i == size ;
163-
164- tds .startBatch ();
165- tds .executeSQL (sql , procName , (ParamInfo []) value , false , 0 , -1 , -1 , executeNow );
166-
167- // If the batch has been sent, process the results
168- if (executeNow ) {
169- sqlEx = tds .getBatchCounts (counts , sqlEx );
170-
171- // If a serious error then we stop execution now as count
172- // is too small.
173- if (sqlEx != null && counts .size () != i ) {
174- break ;
175- }
176- }
177- }
178- return sqlEx ;
179- }
180-
181- /**
182- * Execute the SQL batch on a Sybase server.
183- * <p/>
184- * For the rare case of CallableStatement batches each statement is executed individually. This ensures that
185- * problems with the server reading into the middle of a statement are avoided. See bug report [1374518] for more
186- * details.
187- *
188- * @param size the total size of the batch
189- * @param executeSize the maximum number of statements to send in one request (ignored for this version of the
190- * method as only one statement will be sent at a time)
191- * @param counts the returned update counts
192- * @return chained exceptions linked to a <code>SQLException</code>
193- * @throws SQLException if a serious error occurs during execution
194- */
195- @ Override
196- protected SQLException executeSybaseBatch (int size , int executeSize , ArrayList counts )
197- throws SQLException
198- {
199- if (parameters .length == 0 ) {
200- // No parameters so we can execute as a simple batch
201- return super .executeSybaseBatch (size , executeSize , counts );
202- }
203-
204- SQLException sqlEx = null ;
205-
206- for (int i = 0 ; i < size ;) {
207- Object value = batchValues .get (i );
208- ++i ;
209- tds .executeSQL (sql , procName , (ParamInfo []) value , false , 0 , -1 , -1 , true );
210-
211- // If the batch has been sent, process the results
212- sqlEx = tds .getBatchCounts (counts , sqlEx );
142+ /**
143+ * Execute the SQL batch on a MS server.
144+ *
145+ * @param size
146+ * total size of the batch
147+ *
148+ * @param executeSize
149+ * maximum number of statements to send in one request
150+ *
151+ * @param counts
152+ * the returned update counts
153+ *
154+ * @return
155+ * chained exceptions linked to a <code>SQLException</code>
156+ *
157+ * @throws SQLException
158+ */
159+ @ Override
160+ protected SQLException executeMSBatch ( int size , int executeSize , ArrayList counts )
161+ throws SQLException
162+ {
163+ if ( parameters .length == 0 )
164+ {
165+ // No parameters so we can execute as a simple batch
166+ return super .executeMSBatch ( size , executeSize , counts );
167+ }
168+
169+ SQLException sqlEx = null ;
170+ for ( int i = 0 ; i < size ; )
171+ {
172+ Object value = batchValues .get ( i );
173+ ++ i ;
174+
175+ // Execute batch now if max size reached or end of batch
176+ boolean executeNow = (i % executeSize == 0 ) || i == size ;
177+
178+ tds .startBatch ();
179+
180+ // provide statement's ROWCOUNT and TEXTSIZE (see bug #726)
181+ tds .executeSQL ( sql , procName , (ParamInfo []) value , false , 0 , maxRows , maxFieldSize , executeNow );
182+
183+ // If the batch has been sent, process the results
184+ if ( executeNow )
185+ {
186+ sqlEx = tds .getBatchCounts ( counts , sqlEx );
213187
214188 // If a serious error then we stop execution now as count
215189 // is too small.
216- if (sqlEx != null && counts .size () != i ) {
217- break ;
190+ if ( sqlEx != null && counts .size () != i )
191+ {
192+ break ;
218193 }
219- }
220- return sqlEx ;
221- }
222-
194+ }
195+ }
196+ return sqlEx ;
197+ }
198+
199+ /**
200+ * <p> Execute the SQL batch on a Sybase server. </p>
201+ *
202+ * <p> For the rare case of CallableStatement batches each statement is
203+ * executed individually. This ensures that problems with the server reading
204+ * into the middle of a statement are avoided. See bug report [1374518] for
205+ * more details. </p>
206+ *
207+ * @param size
208+ * total size of the batch
209+ *
210+ * @param executeSize
211+ * maximum number of statements to send in one request (ignored for this
212+ * version of the method as only one statement will be sent at a time)
213+ *
214+ * @param counts
215+ * returned update counts
216+ *
217+ * @return
218+ * chained exceptions linked to a <code>SQLException</code>
219+ *
220+ * @throws SQLException
221+ * if a serious error occurs during execution
222+ */
223+ @ Override
224+ protected SQLException executeSybaseBatch ( int size , int executeSize , ArrayList counts )
225+ throws SQLException
226+ {
227+ if ( parameters .length == 0 )
228+ {
229+ // no parameters so we can execute as a simple batch
230+ return super .executeSybaseBatch ( size , executeSize , counts );
231+ }
232+
233+ SQLException sqlEx = null ;
234+
235+ for ( int i = 0 ; i < size ; )
236+ {
237+ Object value = batchValues .get ( i );
238+ ++ i ;
239+
240+ // provide statement's ROWCOUNT and TEXTSIZE (see bug #726)
241+ tds .executeSQL ( sql , procName , (ParamInfo []) value , false , 0 , maxRows , maxFieldSize , true );
242+
243+ // If the batch has been sent, process the results
244+ sqlEx = tds .getBatchCounts ( counts , sqlEx );
245+
246+ // If a serious error then we stop execution now as count is too small.
247+ if ( sqlEx != null && counts .size () != i )
248+ {
249+ break ;
250+ }
251+ }
252+
253+ return sqlEx ;
254+ }
223255
224256// ---------- java.sql.CallableStatement methods follow ----------
225257
0 commit comments