Feedback
Did this article resolve your question/issue?

   

Article

PreparedStatement::executeBatch() returning unexpected value in the array

Information

 
TitlePreparedStatement::executeBatch() returning unexpected value in the array
URL NamePreparedStatement-executeBatch-returning-unexpected-value-in-the-array
Article Number000154229
EnvironmentProduct: Connect for JDBC Amazon Redshift driver
Version: 5.1
OS: Java
Database: Amazon Redshift
Application: All supported applications
Question/Problem Description
Connect for JDBC Amazon Redshift driver running PreparedStatement::executeBatch() returning unexpected value in the array
Steps to Reproduce
Clarifying Information
When executing batch insert of 25 rows, executeBatch() returns an array with 25 elements where the first element is 25 and the rest are 0. 
Expecting the result to be an array of 25 elements all containing 1.
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The driver is behaving as expected. 

The default for batchMechanism is multiRowInsert. While faster, this choice only returns a single row count. To get individual row counts, switch to batchMechanism=nativeBatch.

- Setting batchMechanism=multiRowInsert (Default) : Batch insert done (25): [25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
- Setting batchMechanism=nativeBatch : Batch insert done (25): [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

For additional information refer to the DataDirect driver documentation.
Workaround
Notes
References to other documentation:
DataDirect Driver Documentation, https://www.progress.com/documentation/datadirect-connectors
Last Modified Date2/19/2020 4:23 PM
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.