I'm trying to insert a value with out have batch execution will return the value that i mentions in query but it not works in the batch execution. It only return a integer array with status 1 or 0.My sample code are give below.
Connection connection = ConnectionManager.getInstance().getDBConnection();
String query = "insert into custom_attribute_mapping (product_id,attribute_id,attribute_values) values (49,22,'yyyyyyyyyyyyy') RETURNING attribute_mapping_id";
try (PreparedStatement prepStmt2 = connection
.prepareStatement(query )) {
int i =0;
ResultSet rs = prepStmt2.executeQuery();
while (rs.next()) {
System.out.println(rs.getInt(1));
}
} catch (Exception e) {
}
In the above code i got the value of the attribute_mapping_id. but in the below code the return type of the executeBatch is an integer array and it only have the insertion status.
Connection connection = ConnectionManager.getInstance().getDBConnection();
String query = "insert into custom_attribute_mapping (product_id,attribute_id,attribute_values) values (49,22,'yyyyyyyyyyyyy') RETURNING attribute_mapping_id";
try (PreparedStatement prepStmt2 = connection
.prepareStatement(query )) {
int i =0;
while(i<5){
i++;
prepStmt2.addBatch();
}
int[] rs = prepStmt2.executeBatch();
for(int r:rs){
System.out.println(r);
}
} catch (Exception e) {
}
can any one please help me.