From 23a46b4be35277e06ec89f48730eeb694e686be8 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Thu, 18 Jun 2026 15:40:06 +0000
Subject: [PATCH] add fdx-commons and fdx-consultation

---
 fdx-commons/fdxcommons-tools/src/main/java/com/megatim/fdxcommons/tools/database/contrat/DefaultPreparedStatementProcessor.java |   64 ++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/fdx-commons/fdxcommons-tools/src/main/java/com/megatim/fdxcommons/tools/database/contrat/DefaultPreparedStatementProcessor.java b/fdx-commons/fdxcommons-tools/src/main/java/com/megatim/fdxcommons/tools/database/contrat/DefaultPreparedStatementProcessor.java
new file mode 100644
index 0000000..68250b7
--- /dev/null
+++ b/fdx-commons/fdxcommons-tools/src/main/java/com/megatim/fdxcommons/tools/database/contrat/DefaultPreparedStatementProcessor.java
@@ -0,0 +1,64 @@
+package com.megatim.fdxcommons.tools.database.contrat;
+
+import com.megatim.fdxcommons.tools.database.queries.metadata.QueryParam;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.naming.NamingException;
+
+/**
+ *
+ * @author Gabuntu
+ */
+public class DefaultPreparedStatementProcessor implements PreparedStatementProcessor {
+
+    private final AtomicInteger lastIndex;
+
+    public DefaultPreparedStatementProcessor() {
+        lastIndex = new AtomicInteger(0);
+    }
+
+    public DefaultPreparedStatementProcessor(int startIndex) {
+        lastIndex = new AtomicInteger(startIndex);
+    }
+
+    @Override
+    public void process(PreparedStatement statement, List<QueryParam> queryParameters) throws NamingException, SQLException {
+        processStatement(statement, queryParameters);
+    }
+
+    @Override
+    public int lastProcessedIndex() {
+        return lastIndex.get();
+    }
+
+    private void processStatement(PreparedStatement preparedStatement, List<QueryParam> params) throws SQLException {
+
+        int statementIndex = 1;
+
+        for (QueryParam parameter : params) {
+
+            Object value = parameter.getParamValue();
+            if (value instanceof String) {
+                preparedStatement.setString(statementIndex, value.toString());
+            } else if (value instanceof Integer) {
+                preparedStatement.setInt(statementIndex, (Integer) value);
+            } else if (value instanceof Long) {
+                preparedStatement.setLong(statementIndex, (Long) value);
+            } else if (value instanceof Double) {
+                preparedStatement.setDouble(statementIndex, (Double) value);
+            } else if (value instanceof LocalDateTime) {
+                preparedStatement.setTimestamp(statementIndex, Timestamp.valueOf((LocalDateTime) value));
+            } else {
+                preparedStatement.setObject(statementIndex, value);
+            }
+
+            statementIndex++;
+        }
+
+    }
+
+}

--
Gitblit v1.10.0