'How to error handling in batch save R2DBC

There is issue with my DB save and I want to get the exact error when batch save. Please support find the exact error.

Sample code

List<ProductsDisplayInfo> productsDisplayInfos = product.getListProduct();

ConnectionFactory connectionFactory = ConnectionFactories.get("r2dbc:mysql://root:@127.0.0.1:3306/test??options=DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");

Mono.from(connectionFactory.create())
                    .map(Connection::createBatch)
                    .map(batch -> {
                        productsDisplayInfos.forEach(p -> {
                            batch.add("INSERT INTO product_catalog(\"id\",\"cat_id\",\"sub_cat_id\") VALUES ('" + p.getProductCatalogueId() + "','" + p.getProductCategoryId() + "','" + p
                                    .getProductSubCategoryId() + "') RETURNING id, name, article_number");
                        });
                        return batch.execute();
                    });

Please note that for save, i get List and need to save one by one



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source