| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | <groupId>com.megatim.queryadhoc</groupId> |
| | | <artifactId>query-adhoc</artifactId> |
| | | <version>1.0</version> |
| | | <packaging>jar</packaging> |
| | | <properties> |
| | | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| | | <maven.compiler.source>1.8</maven.compiler.source> |
| | | <maven.compiler.target>1.8</maven.compiler.target> |
| | | <exec.mainClass>com.megatim.queryadhoc.App</exec.mainClass> |
| | | </properties> |
| | | |
| | | <repositories> |
| | | <repository> |
| | | <id>oracle-maven-repo</id> |
| | | <url>https://maven.oracle.com</url> |
| | | </repository> |
| | | </repositories> |
| | | |
| | | <build> |
| | | <plugins> |
| | | |
| | | <plugin> |
| | | <artifactId>maven-assembly-plugin</artifactId> |
| | | <configuration> |
| | | <archive> |
| | | <manifest> |
| | | <mainClass>com.megatim.queryadhoc.App</mainClass> |
| | | </manifest> |
| | | </archive> |
| | | <descriptorRefs> |
| | | <descriptorRef>jar-with-dependencies</descriptorRef> |
| | | </descriptorRefs> |
| | | </configuration> |
| | | <executions> |
| | | <execution> |
| | | <id>make-assembly</id> <!-- this is used for inheritance merges --> |
| | | <phase>package</phase> <!-- bind to the packaging phase --> |
| | | <goals> |
| | | <goal>single</goal> |
| | | </goals> |
| | | </execution> |
| | | </executions> |
| | | </plugin> |
| | | |
| | | </plugins> |
| | | </build> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.oracle.database.jdbc</groupId> |
| | | <artifactId>ojdbc8</artifactId> |
| | | <version>19.8.0.0</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.postgresql</groupId> |
| | | <artifactId>postgresql</artifactId> |
| | | <version>42.6.0</version> <!-- Use the latest version --> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.microsoft.sqlserver</groupId> |
| | | <artifactId>mssql-jdbc</artifactId> |
| | | <version>12.2.0.jre8</version> <!-- Use the appropriate version for your JDK --> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>mysql</groupId> |
| | | <artifactId>mysql-connector-java</artifactId> |
| | | <version>8.0.33</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.tika</groupId> |
| | | <artifactId>tika-parser-text-module</artifactId> |
| | | <version>2.9.0</version> |
| | | <exclusions> |
| | | <exclusion> |
| | | <groupId>org.apache.xmlbeans</groupId> |
| | | <artifactId>xmlbeans</artifactId> |
| | | </exclusion> |
| | | <exclusion> |
| | | <groupId>xerces</groupId> |
| | | <artifactId>xercesImpl</artifactId> |
| | | </exclusion> |
| | | </exclusions> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-validator</groupId> |
| | | <artifactId>commons-validator</artifactId> |
| | | <version>1.6</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>commons-io</groupId> |
| | | <artifactId>commons-io</artifactId> |
| | | <version>2.11.0</version> |
| | | </dependency> |
| | | </dependencies> |
| | | </project> |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc; |
| | | |
| | | import com.megatim.queryadhoc.enums.SgbdType; |
| | | import com.megatim.queryadhoc.enums.TypeDonnee; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.IllegalFormatDateException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.query.insert.impl.PostgresInsertQuery; |
| | | import com.megatim.queryadhoc.query.select.impl.PostgresSelectQuery; |
| | | import com.megatim.queryadhoc.table.DataBaseTable; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class App { |
| | | |
| | | private static final String TABLE_NAME = "users"; |
| | | private static final String DATABASE_NAME = "test_query"; |
| | | private static final String OUTPUT_DIR = "C:\\Users\\ASUS\\Documents\\DATAS\\Export"; |
| | | |
| | | public static void main(String[] args) { |
| | | // tableExists(); |
| | | // isDatabaseAvailable(); |
| | | // insert(); |
| | | select(); |
| | | } |
| | | |
| | | private static ConnectionParameter mySqlConnectionParameters() { |
| | | return new ConnectionParameter(3306, DATABASE_NAME, "mela", "127.0.0.1", "mela"); |
| | | } |
| | | |
| | | private static ConnectionParameter postgresConnectionParameters() { |
| | | return new ConnectionParameter(5432, DATABASE_NAME, "postgres", "127.0.0.1", "mela"); |
| | | } |
| | | |
| | | private static ConnectionParameter sqlServerConnectionParameters() { |
| | | return new ConnectionParameter(1433, DATABASE_NAME, "sa", "192.168.1.210", "Mgt@9090"); |
| | | } |
| | | |
| | | private static void isDatabaseAvailable() { |
| | | try { |
| | | boolean bool = new DataBaseTable(SgbdType.POSTGRESQL, postgresConnectionParameters()) |
| | | .isDatabaseAvailable(); |
| | | System.out.println("Result : " + bool); |
| | | } catch (NotSupportedDataBaseException | ConnectionParameterException ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | private static void tableExists() { |
| | | try { |
| | | boolean bool = new DataBaseTable(SgbdType.POSTGRESQL, postgresConnectionParameters()) |
| | | .tableExists("users1"); |
| | | System.out.println("Result : " + bool); |
| | | } catch (NotSupportedDataBaseException | ConnectionParameterException | ConnectionException ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | private static void select() { |
| | | try { |
| | | // List<Map<String, Object>> data = new DataBaseTable() |
| | | // .select(SgbdType.POSTGRESQL, postgresConnectionParameters()) |
| | | // .execute(TABLE_NAME, Arrays.asList("userName", "dateaction")); |
| | | // |
| | | // data.stream().forEach(l -> { |
| | | // l.forEach((k, v) -> { |
| | | // System.out.println(k + ", " + v); |
| | | // }); |
| | | // }); |
| | | new DataBaseTable(SgbdType.POSTGRESQL, postgresConnectionParameters()) |
| | | .select() |
| | | .execute(TABLE_NAME, columns(), OUTPUT_DIR, TABLE_NAME, false); |
| | | } catch (NotSupportedDataBaseException ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
| | | } catch (Exception ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
| | | } |
| | | } |
| | | |
| | | private static void insert() { |
| | | try { |
| | | File dataFile = new File("C:\\Users\\ASUS\\Documents\\DATAS\\Export\\USERS20250129102052.txt"); |
| | | new DataBaseTable(SgbdType.POSTGRESQL, postgresConnectionParameters()) |
| | | .insert() |
| | | .execute(TABLE_NAME, columns(), dataFile); |
| | | } catch (NotSupportedDataBaseException ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
| | | } catch (Exception ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
| | | } |
| | | } |
| | | |
| | | private static void postgresSelectQuery() { |
| | | try { |
| | | // List<Map<String, Object>> data = new PostgresSelectQuery(connectionParameters()).execute("ref000018_caaadm", Arrays.asList()); |
| | | //System.out.println("***************** size " + data.size()); |
| | | // System.out.println("" + data.get(0)); |
| | | new PostgresSelectQuery(postgresConnectionParameters()).execute("users", columns(), TABLE_NAME, OUTPUT_DIR, true); |
| | | |
| | | } catch (Exception ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
| | | } |
| | | } |
| | | |
| | | private static void postgresInsertQuery() { |
| | | File dataFile = new File("C:\\Users\\ASUS\\Documents\\DATAS\\Export\\USERS20250127160445.txt"); |
| | | try { |
| | | new PostgresInsertQuery(postgresConnectionParameters()).execute(TABLE_NAME, columns(), data()); |
| | | } catch (Exception ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
| | | } |
| | | } |
| | | |
| | | private static List<DbColumnDescription> columns() { |
| | | try { |
| | | List<DbColumnDescription> cols = new ArrayList<>(); |
| | | // cols.add(new DbColumnDescription("code_adnt", TypeDonnee.ALPHANUMERIQUE, 10, 1)); |
| | | // cols.add(new DbColumnDescription("valeur", TypeDonnee.ALPHANUMERIQUE, 20, 2)); |
| | | // cols.add(new DbColumnDescription("code_val", TypeDonnee.ALPHANUMERIQUE, 30, 3)); |
| | | // cols.add(new DbColumnDescription("qua_ti_col", TypeDonnee.ALPHANUMERIQUE, 30, 4)); |
| | | // cols.add(new DbColumnDescription("te_cpt_cons", TypeDonnee.ALPHANUMERIQUE, 50, 5)); |
| | | |
| | | cols.add(new DbColumnDescription("username", TypeDonnee.ALPHANUMERIQUE, 4, 1, null, null, 0)); |
| | | cols.add(new DbColumnDescription("montant", TypeDonnee.NUMERIQUE, 10, 2, null, null, 0)); |
| | | |
| | | DbColumnDescription desc = new DbColumnDescription("dateaction", TypeDonnee.DATE, 10, 3, "yyyyMMdd", "-", 0); |
| | | cols.add(desc); |
| | | |
| | | return cols; |
| | | } catch (IllegalFormatDateException ex) { |
| | | Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private static List<Map<String, Object>> data() { |
| | | List<Map<String, Object>> data = new ArrayList<>(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | |
| | | map.put("username", "Samory"); |
| | | map.put("montant", "000025"); |
| | | map.put("dateaction", "2025-02-06"); |
| | | data.add(map); |
| | | |
| | | return data; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.connection.abtracts; |
| | | |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.factory.DbConnectionFactory; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.validators.ConnectionParameterValidator; |
| | | import java.sql.Connection; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public abstract class DataBaseConnection { |
| | | |
| | | protected final ConnectionParameter connectionParameter; |
| | | protected Connection connection; |
| | | |
| | | public DataBaseConnection(ConnectionParameter connectionParameter) { |
| | | this.connectionParameter = connectionParameter; |
| | | } |
| | | |
| | | protected void checkConnectionParameter(ConnectionParameter connectionParameter) throws ConnectionParameterException { |
| | | new ConnectionParameterValidator().checkConnectionParameter(connectionParameter); |
| | | } |
| | | |
| | | public ConnectionParameter getConnectionParameter() { |
| | | return connectionParameter; |
| | | } |
| | | |
| | | public void closeConnection() throws ConnectionException { |
| | | DbConnectionFactory.closeConnection(connection); |
| | | } |
| | | |
| | | public abstract Connection getConnection() throws ConnectionParameterException, NotSupportedDataBaseException, ConnectionException; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.connection.impl; |
| | | |
| | | import com.megatim.queryadhoc.enums.SgbdType; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.factory.DbConnectionFactory; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.connection.abtracts.DataBaseConnection; |
| | | import java.sql.Connection; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class MySqlDbConnection extends DataBaseConnection { |
| | | |
| | | public MySqlDbConnection(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | public Connection getConnection() throws ConnectionParameterException, NotSupportedDataBaseException, ConnectionException { |
| | | if (connection == null) { |
| | | checkConnectionParameter(connectionParameter); |
| | | connection = DbConnectionFactory.createConnection(SgbdType.MYSQL, connectionParameter); |
| | | } |
| | | |
| | | return connection; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.connection.impl; |
| | | |
| | | import com.megatim.queryadhoc.enums.SgbdType; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.factory.DbConnectionFactory; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.connection.abtracts.DataBaseConnection; |
| | | import java.sql.Connection; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class OracleDbConnection extends DataBaseConnection { |
| | | |
| | | public OracleDbConnection(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | public Connection getConnection() throws ConnectionParameterException, NotSupportedDataBaseException, ConnectionException { |
| | | if (connection == null) { |
| | | checkConnectionParameter(connectionParameter); |
| | | connection = DbConnectionFactory.createConnection(SgbdType.ORACLE, connectionParameter); |
| | | } |
| | | return connection; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.connection.impl; |
| | | |
| | | import com.megatim.queryadhoc.enums.SgbdType; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.factory.DbConnectionFactory; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.connection.abtracts.DataBaseConnection; |
| | | import java.sql.Connection; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class PostgresDbConnection extends DataBaseConnection { |
| | | |
| | | public PostgresDbConnection(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | public Connection getConnection() throws ConnectionParameterException, NotSupportedDataBaseException, ConnectionException { |
| | | if (connection == null) { |
| | | checkConnectionParameter(connectionParameter); |
| | | connection = DbConnectionFactory.createConnection(SgbdType.POSTGRESQL, connectionParameter); |
| | | } |
| | | return connection; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.connection.impl; |
| | | |
| | | import com.megatim.queryadhoc.enums.SgbdType; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.factory.DbConnectionFactory; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.connection.abtracts.DataBaseConnection; |
| | | import java.sql.Connection; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class SqlServerDbConnection extends DataBaseConnection { |
| | | |
| | | public SqlServerDbConnection(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | public Connection getConnection() throws ConnectionParameterException, NotSupportedDataBaseException, ConnectionException { |
| | | if (connection == null) { |
| | | checkConnectionParameter(connectionParameter); |
| | | connection = DbConnectionFactory.createConnection(SgbdType.SQLSERVER, connectionParameter); |
| | | } |
| | | return connection; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.contrat; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public interface DataColumn { |
| | | |
| | | String column(); |
| | | |
| | | Object value() throws Exception; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.contrat; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public interface DataRow { |
| | | |
| | | List<DataColumn> columns() throws Exception; |
| | | } |
| New file |
| | |
| | | package com.megatim.queryadhoc.contrat; |
| | | |
| | | import com.megatim.queryadhoc.model.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++; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.contrat; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public interface InsertMetaData { |
| | | String tableName(); |
| | | |
| | | List<DataRow> rows() throws Exception; |
| | | |
| | | // List<String> columnNames() throws Exception; |
| | | } |
| New file |
| | |
| | | package com.megatim.queryadhoc.contrat; |
| | | |
| | | import com.megatim.queryadhoc.model.QueryParam; |
| | | import java.sql.PreparedStatement; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * |
| | | * @author Gabuntu |
| | | */ |
| | | public interface PreparedStatementProcessor { |
| | | |
| | | void process(PreparedStatement statement, List<QueryParam> queryParameters) throws Exception; |
| | | |
| | | int lastProcessedIndex(); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.enums; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public enum SgbdType { |
| | | ORACLE, POSTGRESQL, SQLSERVER, MYSQL; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Enum.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.enums; |
| | | |
| | | /** |
| | | * |
| | | * @author STEPHANIE |
| | | */ |
| | | public enum TypeDonnee { |
| | | ALPHANUMERIQUE("ALPHANUMERIQUE"), |
| | | NUMERIQUE("NUMERIQUE"), |
| | | DECIMAL("DECIMAL"), |
| | | DATE("DATE"); |
| | | |
| | | private final String value; |
| | | |
| | | private TypeDonnee(String value) { |
| | | this.value = value; |
| | | } |
| | | |
| | | public String getValue() { |
| | | return value; |
| | | } |
| | | |
| | | public static TypeDonnee fromValeur(String value) { |
| | | if (value != null) { |
| | | if (value.equalsIgnoreCase(TypeDonnee.ALPHANUMERIQUE.getValue())) { |
| | | return TypeDonnee.ALPHANUMERIQUE; |
| | | |
| | | } else if (value.equalsIgnoreCase(TypeDonnee.NUMERIQUE.getValue())) { |
| | | return TypeDonnee.NUMERIQUE; |
| | | |
| | | } else if (value.equalsIgnoreCase(TypeDonnee.DATE.getValue())) { |
| | | return TypeDonnee.DATE; |
| | | |
| | | } else if (value.equalsIgnoreCase(TypeDonnee.DECIMAL.getValue())) { |
| | | return TypeDonnee.DECIMAL; |
| | | |
| | | } else { |
| | | return null; |
| | | } |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return value; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | /** |
| | | * |
| | | * @author Gabuntu |
| | | */ |
| | | public class BadColumnTypeException extends Exception { |
| | | public BadColumnTypeException(String message) { |
| | | super(message); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | /** |
| | | * |
| | | * @author Gabuntu |
| | | */ |
| | | public class BadDataValueException extends Exception { |
| | | |
| | | public BadDataValueException(String message) { |
| | | super(message); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class ColumnNotFoundException extends Exception { |
| | | |
| | | public ColumnNotFoundException(String columnName, String tableName) { |
| | | super("La colonne '" + columnName + "' est introuvable dans la table '" + tableName + "' "); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | import com.megatim.queryadhoc.enums.SgbdType; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class ConnectionException extends Exception { |
| | | |
| | | public ConnectionException(SgbdType sgbdType, String databaseName) { |
| | | super("La connexion à la base de données '" + databaseName + "' de '" + sgbdType + "' n'a pas pu être créee"); |
| | | } |
| | | |
| | | public ConnectionException() { |
| | | super("Impossible de fermer la connexion"); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class ConnectionParameterException extends Exception { |
| | | public ConnectionParameterException(String message) { |
| | | super(message); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class IllegalFormatDateException extends Exception { |
| | | |
| | | public IllegalFormatDateException() { |
| | | super("Le format de la date ne peut être nul"); |
| | | } |
| | | |
| | | public IllegalFormatDateException(String formatDate) { |
| | | super("Le format de date ci après n'est pas supoorté : '" + formatDate + "'"); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | /** |
| | | * |
| | | * @author Gabuntu |
| | | */ |
| | | public class LocalDateTimeValueParseError extends Exception { |
| | | |
| | | public LocalDateTimeValueParseError(String message) { |
| | | super(message); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class NotSupportedDataBaseException extends Exception { |
| | | |
| | | public NotSupportedDataBaseException(String sgbdName) { |
| | | super("Le SGBD suivant '" + sgbdName + "' n'est pas supporté"); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.exceptions; |
| | | |
| | | import com.megatim.queryadhoc.enums.TypeDonnee; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class NotSupportedTypeDonneeException extends Exception { |
| | | |
| | | public NotSupportedTypeDonneeException(TypeDonnee typeDonnee) { |
| | | super("Le type de donnee suivant est inconnu " + typeDonnee); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.factory; |
| | | |
| | | import com.megatim.queryadhoc.enums.SgbdType; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import java.sql.Connection; |
| | | import java.sql.DriverManager; |
| | | import java.sql.SQLException; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class DbConnectionFactory { |
| | | |
| | | private DbConnectionFactory() { |
| | | } |
| | | |
| | | public static Connection createConnection(SgbdType sgbdType, ConnectionParameter connectionParameter) throws NotSupportedDataBaseException, ConnectionParameterException, ConnectionException { |
| | | |
| | | if (sgbdType == null) { |
| | | throw new IllegalArgumentException("Le SGBD ne peut être nul"); |
| | | } |
| | | |
| | | switch (sgbdType) { |
| | | case ORACLE: |
| | | return createOracleConnection(connectionParameter); |
| | | case MYSQL: |
| | | return createMySqlConnection(connectionParameter); |
| | | case SQLSERVER: |
| | | return createSqlServerConnection(connectionParameter); |
| | | case POSTGRESQL: |
| | | return createPostgresConnection(connectionParameter); |
| | | default: |
| | | throw new NotSupportedDataBaseException(sgbdType.name()); |
| | | } |
| | | } |
| | | |
| | | public static void closeConnection(Connection connection) throws ConnectionException { |
| | | try { |
| | | if (connection != null) { |
| | | connection.close(); |
| | | } |
| | | } catch (SQLException ex) { |
| | | Logger.getLogger(DbConnectionFactory.class.getName()).log(Level.SEVERE, ex.getMessage(), ex); |
| | | throw new ConnectionException(); |
| | | } |
| | | } |
| | | |
| | | private static Connection createOracleConnection(ConnectionParameter connectionParameter) throws ConnectionException { |
| | | try { |
| | | Class.forName("oracle.jdbc.OracleDriver"); |
| | | String url = "jdbc:oracle:thin:@//" + connectionParameter.getIpAddress() + ":" + connectionParameter.getPort() + "/" + connectionParameter.getDatabaseName(); |
| | | |
| | | Connection connection = connection(url, connectionParameter.getUserName(), connectionParameter.getPassword()); |
| | | |
| | | // Check if the connection is not successful |
| | | if (connection == null) { |
| | | throw new ConnectionException(SgbdType.POSTGRESQL, connectionParameter.getDatabaseName()); |
| | | } |
| | | return connection; |
| | | } catch (SQLException | ClassNotFoundException ex) { |
| | | throw new ConnectionException(SgbdType.ORACLE, connectionParameter.getDatabaseName()); |
| | | } |
| | | } |
| | | |
| | | private static Connection createSqlServerConnection(ConnectionParameter connectionParameter) throws ConnectionException { |
| | | try { |
| | | Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); |
| | | String url = "jdbc:sqlserver://" + connectionParameter.getIpAddress() + ":" + connectionParameter.getPort() + ";databaseName=" + connectionParameter.getDatabaseName() |
| | | + ";encrypt=false;trustServerCertificate=false;"; |
| | | |
| | | Connection connection = connection(url, connectionParameter.getUserName(), connectionParameter.getPassword()); |
| | | |
| | | // Check if the connection is not successful |
| | | if (connection == null) { |
| | | throw new ConnectionException(SgbdType.POSTGRESQL, connectionParameter.getDatabaseName()); |
| | | } |
| | | return connection; |
| | | } catch (SQLException | ClassNotFoundException ex) { |
| | | throw new ConnectionException(SgbdType.SQLSERVER, connectionParameter.getDatabaseName()); |
| | | } |
| | | } |
| | | |
| | | private static Connection createMySqlConnection(ConnectionParameter connectionParameter) throws ConnectionException { |
| | | |
| | | try { |
| | | Class.forName("com.mysql.cj.jdbc.Driver"); |
| | | String url = "jdbc:mysql://" + connectionParameter.getIpAddress() + ":" + connectionParameter.getPort() + "/" + connectionParameter.getDatabaseName() + "?useSSL=false"; |
| | | |
| | | Connection connection = connection(url, connectionParameter.getUserName(), connectionParameter.getPassword()); |
| | | |
| | | // Check if the connection is not successful |
| | | if (connection == null) { |
| | | throw new ConnectionException(SgbdType.POSTGRESQL, connectionParameter.getDatabaseName()); |
| | | } |
| | | return connection; |
| | | } catch (SQLException | ClassNotFoundException ex) { |
| | | throw new ConnectionException(SgbdType.MYSQL, connectionParameter.getDatabaseName()); |
| | | } |
| | | } |
| | | |
| | | private static Connection createPostgresConnection(ConnectionParameter connectionParameter) throws ConnectionException { |
| | | try { |
| | | Class.forName("org.postgresql.Driver"); |
| | | String url = "jdbc:postgresql://" + connectionParameter.getIpAddress() + ":" + connectionParameter.getPort() + "/" + connectionParameter.getDatabaseName(); |
| | | |
| | | Connection connection = connection(url, connectionParameter.getUserName(), connectionParameter.getPassword()); |
| | | |
| | | // Check if the connection is not successful |
| | | if (connection == null) { |
| | | throw new ConnectionException(SgbdType.POSTGRESQL, connectionParameter.getDatabaseName()); |
| | | } |
| | | return connection; |
| | | } catch (SQLException | ClassNotFoundException ex) { |
| | | throw new ConnectionException(SgbdType.POSTGRESQL, connectionParameter.getDatabaseName()); |
| | | } |
| | | } |
| | | |
| | | private static Connection connection(String url, String userName, String password) throws ConnectionException, SQLException { |
| | | // Create the connection |
| | | return DriverManager.getConnection(url, userName, password); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.model; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class ConnectionParameter { |
| | | |
| | | private final int port; |
| | | |
| | | private final String databaseName; |
| | | |
| | | private final String userName; |
| | | |
| | | private final String ipAddress; |
| | | |
| | | private final String password; |
| | | |
| | | public ConnectionParameter(int port, String databaseName, String userName, String ipAddress, String password) { |
| | | this.port = port; |
| | | this.databaseName = databaseName; |
| | | this.userName = userName; |
| | | this.ipAddress = ipAddress; |
| | | this.password = password; |
| | | } |
| | | |
| | | public int getPort() { |
| | | return port; |
| | | } |
| | | |
| | | public String getDatabaseName() { |
| | | return databaseName; |
| | | } |
| | | |
| | | public String getUserName() { |
| | | return userName; |
| | | } |
| | | |
| | | public String getIpAddress() { |
| | | return ipAddress; |
| | | } |
| | | |
| | | public String getPassword() { |
| | | return password; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.model; |
| | | |
| | | import com.megatim.queryadhoc.enums.TypeDonnee; |
| | | import com.megatim.queryadhoc.exceptions.IllegalFormatDateException; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class DbColumnDescription { |
| | | |
| | | private final String name; |
| | | |
| | | private final TypeDonnee typeDonnee; |
| | | |
| | | private final int taille; |
| | | |
| | | private final int taillePartieDecimale; |
| | | |
| | | private final String formatDate; |
| | | |
| | | private final int position; |
| | | |
| | | public DbColumnDescription(String name, TypeDonnee typeDonnee, int taille, int position, String formatDate, String separateurDate, int taillePartieDecimale) throws IllegalFormatDateException { |
| | | this.name = name; |
| | | this.typeDonnee = typeDonnee; |
| | | this.taille = taille; |
| | | this.position = position; |
| | | this.taillePartieDecimale = taillePartieDecimale; |
| | | this.formatDate = finalFormatDate(typeDonnee, formatDate, separateurDate); |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public TypeDonnee getTypeDonnee() { |
| | | return typeDonnee; |
| | | } |
| | | |
| | | public int getTaille() { |
| | | return taille; |
| | | } |
| | | |
| | | public int getTaillePartieDecimale() { |
| | | return taillePartieDecimale; |
| | | } |
| | | |
| | | public String getFormatDate() { |
| | | return formatDate; |
| | | } |
| | | |
| | | public int getPosition() { |
| | | return position; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "DbColumnDescription{" + "name=" + name + ", position=" + position + '}'; |
| | | } |
| | | |
| | | private String finalFormatDate(TypeDonnee typeDonnee, String formatDate, String separateurDate) throws IllegalFormatDateException { |
| | | if (typeDonnee != TypeDonnee.DATE || formatDate == null || formatDate.isEmpty()) { |
| | | return null; |
| | | } |
| | | final String yearPattern = "yyyy"; |
| | | final String monthPattern = "MM"; |
| | | final String dayPattern = "dd"; |
| | | |
| | | if (formatDate.length() == 4 && formatDate.equals(yearPattern)) { |
| | | return formatDate; |
| | | |
| | | } else if (formatDate.length() == 6 && formatDate.contains(yearPattern) && formatDate.contains(monthPattern)) { |
| | | if (formatDate.startsWith(yearPattern)) { |
| | | return yearPattern + separateurDate + monthPattern; |
| | | } else { |
| | | return monthPattern + separateurDate + yearPattern; |
| | | } |
| | | } else if (formatDate.length() == 7 && formatDate.contains(yearPattern) && formatDate.contains(monthPattern)) { |
| | | return formatDate; |
| | | |
| | | } else if (formatDate.length() == 8 && formatDate.contains(yearPattern) && formatDate.contains(monthPattern) && formatDate.contains(dayPattern)) { |
| | | |
| | | if (formatDate.startsWith(yearPattern)) { |
| | | |
| | | if (formatDate.endsWith(dayPattern)) { |
| | | return yearPattern + separateurDate + monthPattern + separateurDate + dayPattern; |
| | | |
| | | } else { |
| | | return yearPattern + separateurDate + dayPattern + separateurDate + monthPattern; |
| | | } |
| | | } else if (formatDate.startsWith(monthPattern)) { |
| | | |
| | | if (formatDate.endsWith(dayPattern)) { |
| | | return monthPattern + separateurDate + yearPattern + separateurDate + dayPattern; |
| | | |
| | | } else { |
| | | return monthPattern + separateurDate + dayPattern + separateurDate + yearPattern; |
| | | } |
| | | } else if (formatDate.startsWith(dayPattern)) { |
| | | |
| | | if (formatDate.endsWith(yearPattern)) { |
| | | return dayPattern + separateurDate + monthPattern + separateurDate + yearPattern; |
| | | |
| | | } else { |
| | | return dayPattern + separateurDate + yearPattern + separateurDate + monthPattern; |
| | | } |
| | | } else { |
| | | throw new IllegalFormatDateException(formatDate); |
| | | } |
| | | } else if (formatDate.length() == 10 && formatDate.contains(yearPattern) && formatDate.contains(monthPattern) && formatDate.contains(dayPattern)) { |
| | | return formatDate; |
| | | } else { |
| | | throw new IllegalFormatDateException(formatDate); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | package com.megatim.queryadhoc.model; |
| | | |
| | | /** |
| | | * |
| | | * @author Gabuntu |
| | | */ |
| | | public class QueryParam { |
| | | |
| | | private final String nomColonne; |
| | | private final Object paramValue; |
| | | |
| | | public QueryParam(String nomColonne, Object paramValue) { |
| | | this.nomColonne = nomColonne; |
| | | this.paramValue = paramValue; |
| | | } |
| | | |
| | | public String getNomColonne() { |
| | | return nomColonne; |
| | | } |
| | | |
| | | public Object getParamValue() { |
| | | return paramValue; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.queries; |
| | | |
| | | import com.megatim.queryadhoc.contrat.DataColumn; |
| | | import com.megatim.queryadhoc.contrat.DataRow; |
| | | import com.megatim.queryadhoc.model.QueryParam; |
| | | import com.megatim.queryadhoc.contrat.DefaultPreparedStatementProcessor; |
| | | import com.megatim.queryadhoc.contrat.PreparedStatementProcessor; |
| | | import java.sql.Connection; |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class CommonInsertQuery { |
| | | |
| | | private final String tableName; |
| | | protected final Connection connection; |
| | | private final List<String> columnNames; |
| | | private final List<DataRow> rows; |
| | | private final int BATCH_SIZE = 1000; |
| | | |
| | | public CommonInsertQuery(String tableName, final Connection connection, List<String> columnNames, List<DataRow> rows) { |
| | | this.tableName = tableName; |
| | | this.connection = connection; |
| | | this.columnNames = columnNames; |
| | | this.rows = rows; |
| | | } |
| | | |
| | | public void execute() throws Exception { |
| | | |
| | | try ( PreparedStatement statement = connection.prepareStatement(insertQueryString());) { |
| | | |
| | | executeInBatch(statement, rows); |
| | | statement.executeBatch(); |
| | | } |
| | | } |
| | | |
| | | private String insertQueryString() { |
| | | |
| | | StringBuilder query = new StringBuilder("INSERT INTO " + tableName + "("); |
| | | |
| | | columnNames.forEach(column -> query.append(column).append(",")); |
| | | |
| | | query.replace(query.length() - 1, query.length(), ") VALUES("); |
| | | |
| | | columnNames.forEach(s -> query.append("?,")); |
| | | |
| | | query.replace(query.length() - 1, query.length(), ")"); |
| | | |
| | | return query.toString(); |
| | | } |
| | | |
| | | private void executeInBatch(PreparedStatement preparedStatement, List<DataRow> rows) throws SQLException, Exception { |
| | | |
| | | int index = 0; |
| | | int count = 0; |
| | | |
| | | for (DataRow row : rows) { |
| | | |
| | | List<QueryParam> queryParameters = new ArrayList<>(); |
| | | |
| | | for (DataColumn dataColumn : row.columns()) { |
| | | queryParameters.add(new QueryParam(dataColumn.column(), dataColumn.value())); |
| | | } |
| | | |
| | | PreparedStatementProcessor statementProcessor = new DefaultPreparedStatementProcessor(index); |
| | | statementProcessor.process(preparedStatement, queryParameters); |
| | | index = statementProcessor.lastProcessedIndex(); |
| | | |
| | | preparedStatement.addBatch(); |
| | | |
| | | if (++count % BATCH_SIZE == 0) { |
| | | preparedStatement.executeBatch(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.queries; |
| | | |
| | | import java.sql.Connection; |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.ResultSet; |
| | | import java.sql.ResultSetMetaData; |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class CommonSelectQuery { |
| | | |
| | | private final String tableName; |
| | | private final Connection connection; |
| | | private final List<String> selectColumns; |
| | | private final int limit; |
| | | private final int offset; |
| | | |
| | | public CommonSelectQuery(Connection connection, String tableName, List<String> selectColumns, int limit, int offset) { |
| | | this.tableName = tableName; |
| | | this.connection = connection; |
| | | this.selectColumns = selectColumns; |
| | | this.limit = limit; |
| | | this.offset = offset; |
| | | } |
| | | |
| | | public CommonSelectQuery(Connection connection, String tableName, List<String> selectColumns) { |
| | | this(connection, tableName, selectColumns, -1, -1); |
| | | } |
| | | |
| | | public CommonSelectQuery(String tableName, Connection connection, List<String> selectColumns, int limit, int offset, boolean withCustomColumns) { |
| | | this.tableName = tableName; |
| | | this.connection = connection; |
| | | this.selectColumns = selectColumns; |
| | | this.limit = limit; |
| | | this.offset = offset; |
| | | } |
| | | |
| | | public List<Map<String, Object>> execute() throws SQLException { |
| | | List<Map<String, Object>> allData = new ArrayList<>(); |
| | | |
| | | try ( PreparedStatement statement = connection.prepareStatement(selectQuery())) { |
| | | ResultSet resultSet = statement.executeQuery(); |
| | | ResultSetMetaData metaData = resultSet.getMetaData(); |
| | | int columnCount = metaData.getColumnCount(); |
| | | |
| | | while (resultSet.next()) { |
| | | Map<String, Object> dataMap = new HashMap<>(); |
| | | |
| | | for (int i = 1; i <= columnCount; i++) { |
| | | String name = metaData.getColumnName(i).trim(); |
| | | Object value = resultSet.getObject(i); |
| | | dataMap.put(name, cleanData(value)); |
| | | } |
| | | |
| | | allData.add(dataMap); |
| | | } |
| | | } |
| | | return allData; |
| | | } |
| | | |
| | | public String selectQuery() { |
| | | |
| | | StringBuilder query = new StringBuilder("SELECT "); |
| | | |
| | | if (selectColumns.isEmpty()) { |
| | | |
| | | query.append(" * "); |
| | | |
| | | } else { |
| | | |
| | | selectColumns.forEach(c -> query.append(c.toLowerCase()).append(",")); |
| | | query.replace(query.length() - 1, query.length(), ""); //retirer la sernière virgule |
| | | |
| | | } |
| | | |
| | | query |
| | | .append(" FROM ") |
| | | .append(tableName); |
| | | |
| | | if (limit > 0 && offset >= 0) { |
| | | |
| | | query |
| | | .append(" LIMIT ") |
| | | .append(limit) |
| | | .append(" OFFSET ") |
| | | .append(offset); |
| | | } |
| | | |
| | | return query.toString(); |
| | | } |
| | | |
| | | private Object cleanData(Object data) { |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | |
| | | if (data instanceof String) { |
| | | String dataString = ((String) data).trim(); |
| | | return dataString.replaceAll("(?U)\\s+", " "); |
| | | } else { |
| | | return data; |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.queries.metadata; |
| | | |
| | | import com.megatim.queryadhoc.contrat.DataColumn; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class DefaultDataColumn implements DataColumn { |
| | | |
| | | private final String column; |
| | | private final Object value; |
| | | |
| | | public DefaultDataColumn(String column, Object value) { |
| | | this.column = column; |
| | | this.value = value; |
| | | } |
| | | |
| | | @Override |
| | | public String column() { |
| | | return column; |
| | | } |
| | | |
| | | @Override |
| | | public Object value() throws Exception { |
| | | return value; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.queries.metadata; |
| | | |
| | | import com.megatim.queryadhoc.contrat.DataColumn; |
| | | import com.megatim.queryadhoc.contrat.DataRow; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class DefaultDataRow implements DataRow { |
| | | |
| | | private final Map<String, Object> entity; |
| | | |
| | | public DefaultDataRow(Map<String, Object> entity) { |
| | | this.entity = entity; |
| | | } |
| | | |
| | | @Override |
| | | public List<DataColumn> columns() { |
| | | return entity |
| | | .entrySet() |
| | | .stream() |
| | | .map(e -> new DefaultDataColumn(e.getKey(), e.getValue())) |
| | | .sorted((c1, c2) -> c1.column().compareTo(c2.column())) //On se rassure de classer le résultat |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.queries.metadata; |
| | | |
| | | import com.megatim.queryadhoc.contrat.DataRow; |
| | | import com.megatim.queryadhoc.contrat.InsertMetaData; |
| | | import com.megatim.queryadhoc.exceptions.BadDataValueException; |
| | | import com.megatim.queryadhoc.exceptions.ColumnNotFoundException; |
| | | import com.megatim.queryadhoc.exceptions.LocalDateTimeValueParseError; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class InsertData implements InsertMetaData { |
| | | |
| | | private final ParsedData parsedData; |
| | | private final String tableName; |
| | | |
| | | public InsertData(String tableName, ParsedData parsedData) { |
| | | this.tableName = tableName; |
| | | this.parsedData = parsedData; |
| | | } |
| | | |
| | | @Override |
| | | public String tableName() { |
| | | return tableName; |
| | | } |
| | | |
| | | @Override |
| | | public List<DataRow> rows() throws BadDataValueException, LocalDateTimeValueParseError, ColumnNotFoundException { |
| | | List<DataRow> rows = new ArrayList<>(); |
| | | for (Map<String, Object> entity : parsedData.data()) { |
| | | rows.add(new DefaultDataRow(entity)); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.queries.metadata; |
| | | |
| | | import com.megatim.queryadhoc.exceptions.LocalDateTimeValueParseError; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeParseException; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class LocalDateTimeValue { |
| | | |
| | | private final String format; |
| | | private final Object value; |
| | | |
| | | public LocalDateTimeValue(String format, Object value) { |
| | | this.format = format; |
| | | this.value = value; |
| | | } |
| | | |
| | | public LocalDateTime value() throws LocalDateTimeValueParseError { |
| | | final String stringValue = value.toString().trim(); |
| | | |
| | | try { |
| | | |
| | | if (format.length() == 4 && format.equals("yyyy") && stringValue.matches("\\d{4}")) { |
| | | return LocalDateTime.of(Integer.parseInt(stringValue), 1, 1, 0, 0, 0); |
| | | |
| | | } else if ((format.length() == 6 && stringValue.length() == 6) || (format.length() == 7) && stringValue.length() == 7) { |
| | | |
| | | int monthIndex = index(format, "MM"); |
| | | int yearIndex = index(format, "yyyy"); |
| | | |
| | | return date(yearIndex, monthIndex, stringValue); |
| | | |
| | | } else if ((format.length() == 8 && stringValue.length() == 8) |
| | | || (format.length() == 10 && stringValue.length() == 10)) { |
| | | |
| | | int dayIndex = index(format, "dd"); |
| | | int monthIndex = index(format, "MM"); |
| | | int yearIndex = index(format, "yyyy"); |
| | | |
| | | return date(yearIndex, monthIndex, dayIndex, stringValue); |
| | | } |
| | | |
| | | } catch (DateTimeParseException e) { |
| | | throw new LocalDateTimeValueParseError("Impossible de parser la valeur " + value + " au format " + format); |
| | | } |
| | | |
| | | throw new LocalDateTimeValueParseError("Impossible de parser la valeur " + value + " au format " + format); |
| | | } |
| | | |
| | | private int index(String format, String subSequence) { |
| | | return format.indexOf(subSequence); |
| | | } |
| | | private LocalDateTime date(int yearIndex, int monthIndex, int dayIndex, String stringValue) throws LocalDateTimeValueParseError { |
| | | |
| | | if (yearIndex >= 0 && monthIndex >= 0 && dayIndex >= 0) { |
| | | int annee = Integer.parseInt(stringValue.substring(yearIndex, yearIndex + 4)); |
| | | int mois = Integer.parseInt(stringValue.substring(monthIndex, monthIndex + 2)); |
| | | int jour = Integer.parseInt(stringValue.substring(dayIndex, dayIndex + 2)); |
| | | |
| | | if (mois >= 1 && mois <= 12 && jour >= 1 && jour <= 31) { |
| | | if ((mois == 1 || mois == 3 || mois == 5 || mois == 7 || mois == 8 || mois == 10 || mois == 12) && jour <= 31//Les mois ayant 31 jours |
| | | || ((mois == 4 || mois == 6 || mois == 9 || mois == 11) && jour <= 30)//les ayant 30 jours |
| | | || (mois == 2 && (annee % 4 == 0 && jour <= 29 || jour <= 28))) { //Le mois de février |
| | | |
| | | return LocalDateTime.of(annee, mois, jour, 0, 0, 0, 0); |
| | | } |
| | | } |
| | | } |
| | | throw new LocalDateTimeValueParseError("Impossible de parser la valeur " + stringValue + " au format " + format); |
| | | } |
| | | |
| | | private LocalDateTime date(int yearIndex, int monthIdex, String stringValue) throws LocalDateTimeValueParseError { |
| | | |
| | | if (yearIndex >= 0 && monthIdex >= 0) { |
| | | int annee = Integer.parseInt(stringValue.substring(yearIndex, yearIndex + 4)); |
| | | int mois = Integer.parseInt(stringValue.substring(monthIdex, monthIdex + 2)); |
| | | int jour = 1; |
| | | |
| | | if (mois >= 1 && mois <= 12) { |
| | | return LocalDateTime.of(annee, mois, jour, 0, 0, 0, 0); |
| | | } |
| | | } |
| | | throw new LocalDateTimeValueParseError("Impossible de parser la valeur " + stringValue + " au format " + format); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.queries.metadata; |
| | | |
| | | import com.megatim.queryadhoc.exceptions.BadDataValueException; |
| | | import com.megatim.queryadhoc.exceptions.ColumnNotFoundException; |
| | | import com.megatim.queryadhoc.exceptions.LocalDateTimeValueParseError; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class ParsedData { |
| | | |
| | | private final List<Map<String, Object>> sourceData; |
| | | private final List<DbColumnDescription> columnsDescription; |
| | | private final String tableName; |
| | | private final List<Map<String, Object>> cachedData = new ArrayList<>(); |
| | | |
| | | public ParsedData(List<Map<String, Object>> sourceData, List<DbColumnDescription> columnsDescription, String tableName) { |
| | | this.sourceData = sourceData; |
| | | this.tableName = tableName; |
| | | this.columnsDescription = columnsDescription; |
| | | } |
| | | |
| | | public List<Map<String, Object>> data() throws BadDataValueException, LocalDateTimeValueParseError, ColumnNotFoundException { |
| | | if (cachedData.isEmpty()) { |
| | | for (Map<String, Object> data : sourceData) { |
| | | cachedData.add(new ParsedDataRow(data, columnsDescription, tableName).dataRow()); |
| | | } |
| | | } |
| | | return cachedData; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.queries.metadata; |
| | | |
| | | import com.megatim.queryadhoc.enums.TypeDonnee; |
| | | import com.megatim.queryadhoc.exceptions.BadDataValueException; |
| | | import com.megatim.queryadhoc.exceptions.ColumnNotFoundException; |
| | | import com.megatim.queryadhoc.exceptions.LocalDateTimeValueParseError; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import org.apache.commons.validator.GenericValidator; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class ParsedDataRow { |
| | | |
| | | private final Map<String, Object> data; |
| | | private final String tableName; |
| | | private final Map<String, DbColumnDescription> columnNameToDbColumnDescription; |
| | | private final Map<String, Object> row = new HashMap<>(); |
| | | |
| | | public ParsedDataRow(Map<String, Object> data, List<DbColumnDescription> columnsDescription, String tableName) { |
| | | this.data = data; |
| | | this.tableName = tableName; |
| | | this.columnNameToDbColumnDescription |
| | | = columnsDescription |
| | | .stream() |
| | | .collect(Collectors.toMap(c -> c.getName().trim().toLowerCase(), c -> c)); |
| | | } |
| | | |
| | | public Map<String, Object> dataRow() throws ColumnNotFoundException, BadDataValueException, LocalDateTimeValueParseError { |
| | | |
| | | if (row.isEmpty()) { |
| | | |
| | | for (Map.Entry<String, Object> entry : data.entrySet()) { |
| | | |
| | | String key = entry.getKey(); |
| | | Object value = entry.getValue(); |
| | | |
| | | DbColumnDescription columnDesc = columnNameToDbColumnDescription.get(key.trim()); |
| | | if (columnDesc == null) { |
| | | throw new ColumnNotFoundException(key, tableName); |
| | | } |
| | | |
| | | row.put(key.trim(), parse(columnDesc, value)); |
| | | } |
| | | |
| | | } |
| | | |
| | | return row; |
| | | } |
| | | |
| | | private Object parse(DbColumnDescription columnDesc, Object value) throws BadDataValueException, LocalDateTimeValueParseError { |
| | | |
| | | TypeDonnee columnType = columnDesc.getTypeDonnee(); |
| | | |
| | | if (columnType.equals(TypeDonnee.ALPHANUMERIQUE) && (value == null |
| | | || (value instanceof String && lengthLowerOrEquals((String) value, columnDesc.getTaille())))) { |
| | | |
| | | return value != null ? value.toString().replaceAll("\\s+", " ").trim() : value; |
| | | |
| | | } else if (columnType.equals(TypeDonnee.NUMERIQUE)) { |
| | | |
| | | if (value == null) { |
| | | return 0L; |
| | | } |
| | | |
| | | String stringValue = value.toString(); |
| | | if (lengthLowerOrEquals(stringValue, columnDesc.getTaille()) && GenericValidator.isLong(stringValue)) { |
| | | return Long.valueOf(stringValue); |
| | | } |
| | | |
| | | } else if (columnType.equals(TypeDonnee.DECIMAL)) { |
| | | |
| | | if (value == null) { |
| | | return 0.0; |
| | | } |
| | | |
| | | String stringValue = value.toString(); |
| | | if (lengthLowerOrEquals(stringValue, columnDesc.getTaille()) && GenericValidator.isDouble(stringValue)) { |
| | | return Double.valueOf(stringValue); |
| | | } |
| | | |
| | | } else if (columnType.equals(TypeDonnee.DATE)) { |
| | | |
| | | if (value == null) { |
| | | return null; |
| | | } |
| | | String stringValue = value.toString().trim(); |
| | | |
| | | if (stringValue.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | if (lengthEquals(stringValue, columnDesc.getTaille()) && GenericValidator.isDate(stringValue, columnDesc.getFormatDate(), true)) { |
| | | return new LocalDateTimeValue(columnDesc.getFormatDate(), value).value(); |
| | | } |
| | | } |
| | | |
| | | throw new BadDataValueException("La valeur " + value + " ne correspond pas au format attendu pour la colonne " + columnDesc.getName()); |
| | | } |
| | | |
| | | private boolean lengthEquals(String value, int columnMaxLength) { |
| | | return value.trim().length() == columnMaxLength; |
| | | } |
| | | |
| | | private boolean lengthLowerOrEquals(String value, int columnMaxLength) { |
| | | return value.trim().length() <= columnMaxLength; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.abstracts; |
| | | |
| | | import com.megatim.queryadhoc.connection.abtracts.DataBaseConnection; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import java.sql.Connection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public abstract class DatabaseInsertQuery { |
| | | |
| | | protected final ConnectionParameter connectionParameter; |
| | | |
| | | public DatabaseInsertQuery(ConnectionParameter connectionParameter) { |
| | | this.connectionParameter = connectionParameter; |
| | | } |
| | | |
| | | public ConnectionParameter getConnectionParameter() { |
| | | return connectionParameter; |
| | | } |
| | | |
| | | protected void execute(DataBaseConnection dbConnection, String tableName, List<Map<String, Object>> data, List<DbColumnDescription> columnsDescription) throws NotSupportedDataBaseException, ConnectionParameterException, ConnectionException, Exception { |
| | | insert(dbConnection.getConnection(), tableName, data, columnsDescription); |
| | | dbConnection.closeConnection(); |
| | | |
| | | } |
| | | |
| | | protected abstract void insert(Connection connection, String tableName, List<Map<String, Object>> data, List<DbColumnDescription> columnsDescription) throws Exception; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.abstracts; |
| | | |
| | | import com.megatim.queryadhoc.connection.abtracts.DataBaseConnection; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.utils.DataFormatter; |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.nio.file.StandardOpenOption; |
| | | import java.sql.Connection; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public abstract class DatabaseSelectQuery { |
| | | |
| | | protected final ConnectionParameter connectionParameter; |
| | | |
| | | public DatabaseSelectQuery(ConnectionParameter connectionParameter) { |
| | | this.connectionParameter = connectionParameter; |
| | | } |
| | | |
| | | public ConnectionParameter getConnectionParameter() { |
| | | return connectionParameter; |
| | | } |
| | | |
| | | protected List<Map<String, Object>> execute(DataBaseConnection dbConnection, String tableName, List<String> columnsToSelect) throws Exception { |
| | | List<Map<String, Object>> data = select(tableName, dbConnection.getConnection(), columnsToSelect); |
| | | dbConnection.closeConnection(); |
| | | |
| | | return data; |
| | | } |
| | | |
| | | protected File writeToFile(List<Map<String, Object>> data, List<DbColumnDescription> columnsDescription, String outputDir, String codeTypeFichier, String tableName, boolean shouldTruncate) throws Exception { |
| | | Collections.sort(columnsDescription, (DbColumnDescription c1, DbColumnDescription c2) -> Integer.valueOf(c1.getPosition()).compareTo(c2.getPosition())); |
| | | Path path = constructFileName(codeTypeFichier, outputDir); |
| | | |
| | | try ( BufferedWriter bufferWriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8, StandardOpenOption.APPEND, StandardOpenOption.CREATE, StandardOpenOption.SYNC)) { |
| | | |
| | | for (Map<String, Object> map : data) { |
| | | String line = DataFormatter.formatDatum(map, columnsDescription, tableName, shouldTruncate); |
| | | bufferWriter.write(line + System.lineSeparator()); |
| | | } |
| | | } |
| | | return path.toFile(); |
| | | } |
| | | |
| | | private Path constructFileName(String codeTypeFichier, String exportDirectory) { |
| | | LocalDateTime date = LocalDateTime.now(); |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); |
| | | Path path = Paths.get(exportDirectory, codeTypeFichier.toUpperCase() + date.format(formatter) + ".txt"); |
| | | |
| | | return path; |
| | | } |
| | | |
| | | protected abstract List<Map<String, Object>> select(String tableName, Connection connection, List<String> columnsToSelect) throws Exception; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.ifaces; |
| | | |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import java.io.File; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public interface InsertQuery { |
| | | |
| | | void execute(String tableName, List<DbColumnDescription> columnsDescription, List<Map<String, Object>> data) throws Exception; |
| | | |
| | | void execute(String tableName, List<DbColumnDescription> columnsDescription, File file) throws Exception; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.ifaces; |
| | | |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import java.io.File; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public interface SelectQuery { |
| | | |
| | | List<Map<String, Object>> execute(String tableName, List<String> columnsToSelect) throws Exception; |
| | | |
| | | File execute(String tableName, List<DbColumnDescription> columnsDescription, String outputDir, String codeTypeFichier, boolean shouldTruncate) throws Exception; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.insert.impl; |
| | | |
| | | import com.megatim.queryadhoc.connection.impl.MySqlDbConnection; |
| | | import com.megatim.queryadhoc.contrat.InsertMetaData; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.queries.CommonInsertQuery; |
| | | import com.megatim.queryadhoc.queries.metadata.InsertData; |
| | | import com.megatim.queryadhoc.queries.metadata.ParsedData; |
| | | import com.megatim.queryadhoc.query.abstracts.DatabaseInsertQuery; |
| | | import com.megatim.queryadhoc.query.ifaces.InsertQuery; |
| | | import com.megatim.queryadhoc.utils.FileDataReader; |
| | | import java.io.File; |
| | | import java.sql.Connection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class MySqlInsertQuery extends DatabaseInsertQuery implements InsertQuery { |
| | | |
| | | public MySqlInsertQuery(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | protected void insert(Connection connection, String tableName, List<Map<String, Object>> data, List<DbColumnDescription> columnsDescription) throws Exception { |
| | | Collections.sort(columnsDescription, (DbColumnDescription c1, DbColumnDescription c2) -> c1.getName().compareTo(c2.getName())); |
| | | |
| | | ParsedData parsedData = new ParsedData(data, columnsDescription, tableName); |
| | | InsertMetaData insertMetaData = new InsertData(tableName, parsedData); |
| | | |
| | | List<String> columns = columnsDescription.stream().map(c -> c.getName()).collect(Collectors.toList()); |
| | | |
| | | new CommonInsertQuery(tableName, connection, columns, insertMetaData.rows()).execute(); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(String tableName, List<DbColumnDescription> columnsDescription, List<Map<String, Object>> data) throws Exception { |
| | | execute(new MySqlDbConnection(connectionParameter), tableName, data, columnsDescription); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(String tableName, List<DbColumnDescription> columnsDescription, File dataFile) throws Exception { |
| | | List<Map<String, Object>> data = FileDataReader.readFile(columnsDescription, dataFile); |
| | | execute(tableName, columnsDescription, data); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.insert.impl; |
| | | |
| | | import com.megatim.queryadhoc.connection.impl.OracleDbConnection; |
| | | import com.megatim.queryadhoc.contrat.InsertMetaData; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.queries.CommonInsertQuery; |
| | | import com.megatim.queryadhoc.queries.metadata.InsertData; |
| | | import com.megatim.queryadhoc.queries.metadata.ParsedData; |
| | | import com.megatim.queryadhoc.query.abstracts.DatabaseInsertQuery; |
| | | import com.megatim.queryadhoc.query.ifaces.InsertQuery; |
| | | import com.megatim.queryadhoc.utils.FileDataReader; |
| | | import java.io.File; |
| | | import java.sql.Connection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class OracleInsertQuery extends DatabaseInsertQuery implements InsertQuery { |
| | | |
| | | public OracleInsertQuery(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | protected void insert(Connection connection, String tableName, List<Map<String, Object>> data, List<DbColumnDescription> columnsDescription) throws Exception { |
| | | Collections.sort(columnsDescription, (DbColumnDescription c1, DbColumnDescription c2) -> c1.getName().compareTo(c2.getName())); |
| | | |
| | | ParsedData parsedData = new ParsedData(data, columnsDescription, tableName); |
| | | InsertMetaData insertMetaData = new InsertData(tableName, parsedData); |
| | | |
| | | List<String> columns = columnsDescription.stream().map(c -> c.getName()).collect(Collectors.toList()); |
| | | |
| | | new CommonInsertQuery(tableName, connection, columns, insertMetaData.rows()).execute(); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(String tableName, List<DbColumnDescription> columnsDescription, List<Map<String, Object>> data) throws Exception { |
| | | execute(new OracleDbConnection(connectionParameter), tableName, data, columnsDescription); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(String tableName, List<DbColumnDescription> columnsDescription, File dataFile) throws Exception { |
| | | List<Map<String, Object>> data = FileDataReader.readFile(columnsDescription, dataFile); |
| | | execute(tableName, columnsDescription, data); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.insert.impl; |
| | | |
| | | import com.megatim.queryadhoc.connection.impl.PostgresDbConnection; |
| | | import com.megatim.queryadhoc.contrat.InsertMetaData; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.queries.CommonInsertQuery; |
| | | import com.megatim.queryadhoc.queries.metadata.InsertData; |
| | | import com.megatim.queryadhoc.queries.metadata.ParsedData; |
| | | import com.megatim.queryadhoc.query.abstracts.DatabaseInsertQuery; |
| | | import com.megatim.queryadhoc.query.ifaces.InsertQuery; |
| | | import com.megatim.queryadhoc.utils.FileDataReader; |
| | | import java.io.File; |
| | | import java.sql.Connection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class PostgresInsertQuery extends DatabaseInsertQuery implements InsertQuery { |
| | | |
| | | public PostgresInsertQuery(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | protected void insert(Connection connection, String tableName, List<Map<String, Object>> data, List<DbColumnDescription> columnsDescription) throws Exception { |
| | | Collections.sort(columnsDescription, (DbColumnDescription c1, DbColumnDescription c2) -> c1.getName().compareTo(c2.getName())); |
| | | |
| | | ParsedData parsedData = new ParsedData(data, columnsDescription, tableName); |
| | | InsertMetaData insertMetaData = new InsertData(tableName, parsedData); |
| | | |
| | | List<String> columns = columnsDescription.stream().map(c -> c.getName()).collect(Collectors.toList()); |
| | | |
| | | new CommonInsertQuery(tableName, connection, columns, insertMetaData.rows()).execute(); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(String tableName, List<DbColumnDescription> columnsDescription, List<Map<String, Object>> data) throws Exception { |
| | | execute(new PostgresDbConnection(connectionParameter), tableName, data, columnsDescription); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(String tableName, List<DbColumnDescription> columnsDescription, File dataFile) throws Exception { |
| | | List<Map<String, Object>> data = FileDataReader.readFile(columnsDescription, dataFile); |
| | | execute(tableName, columnsDescription, data); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.insert.impl; |
| | | |
| | | import com.megatim.queryadhoc.connection.impl.SqlServerDbConnection; |
| | | import com.megatim.queryadhoc.contrat.InsertMetaData; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.queries.CommonInsertQuery; |
| | | import com.megatim.queryadhoc.queries.metadata.InsertData; |
| | | import com.megatim.queryadhoc.queries.metadata.ParsedData; |
| | | import com.megatim.queryadhoc.query.abstracts.DatabaseInsertQuery; |
| | | import com.megatim.queryadhoc.query.ifaces.InsertQuery; |
| | | import com.megatim.queryadhoc.utils.FileDataReader; |
| | | import java.io.File; |
| | | import java.sql.Connection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class SqlServerInsertQuery extends DatabaseInsertQuery implements InsertQuery { |
| | | |
| | | public SqlServerInsertQuery(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | protected void insert(Connection connection, String tableName, List<Map<String, Object>> data, List<DbColumnDescription> columnsDescription) throws Exception { |
| | | Collections.sort(columnsDescription, (DbColumnDescription c1, DbColumnDescription c2) -> c1.getName().compareTo(c2.getName())); |
| | | |
| | | ParsedData parsedData = new ParsedData(data, columnsDescription, tableName); |
| | | InsertMetaData insertMetaData = new InsertData(tableName, parsedData); |
| | | |
| | | List<String> columns = columnsDescription.stream().map(c -> c.getName()).collect(Collectors.toList()); |
| | | |
| | | new CommonInsertQuery(tableName, connection, columns, insertMetaData.rows()).execute(); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(String tableName, List<DbColumnDescription> columnsDescription, List<Map<String, Object>> data) throws Exception { |
| | | execute(new SqlServerDbConnection(connectionParameter), tableName, data, columnsDescription); |
| | | } |
| | | |
| | | @Override |
| | | public void execute(String tableName, List<DbColumnDescription> columnsDescription, File dataFile) throws Exception { |
| | | List<Map<String, Object>> data = FileDataReader.readFile(columnsDescription, dataFile); |
| | | execute(tableName, columnsDescription, data); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.select.impl; |
| | | |
| | | import com.megatim.queryadhoc.connection.impl.MySqlDbConnection; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.query.abstracts.DatabaseSelectQuery; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.queries.CommonSelectQuery; |
| | | import java.io.File; |
| | | import java.sql.Connection; |
| | | import java.sql.SQLException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import com.megatim.queryadhoc.query.ifaces.SelectQuery; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class MySqlSelectQuery extends DatabaseSelectQuery implements SelectQuery { |
| | | |
| | | public MySqlSelectQuery(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> execute(String tableName, List<String> columnsToSelect) throws Exception { |
| | | return execute(new MySqlDbConnection(connectionParameter), tableName, columnsToSelect); |
| | | } |
| | | |
| | | @Override |
| | | protected List<Map<String, Object>> select(String tableName, Connection connection, List<String> columnsToSelect) throws SQLException { |
| | | return new CommonSelectQuery(connection, tableName, columnsToSelect).execute(); |
| | | } |
| | | |
| | | @Override |
| | | public File execute(String tableName, List<DbColumnDescription> columnsDescription, String outputDir, String codeTypeFichier, boolean shouldTruncate) throws Exception { |
| | | List<String> columnsToSelect = columnsDescription.stream().map(c -> c.getName()).collect(Collectors.toList()); |
| | | List<Map<String, Object>> data = execute(tableName, columnsToSelect); |
| | | |
| | | return writeToFile(data, columnsDescription, outputDir, codeTypeFichier, tableName, shouldTruncate); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.select.impl; |
| | | |
| | | import com.megatim.queryadhoc.connection.impl.OracleDbConnection; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.query.abstracts.DatabaseSelectQuery; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.queries.CommonSelectQuery; |
| | | import java.util.List; |
| | | import java.io.File; |
| | | import java.sql.Connection; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import com.megatim.queryadhoc.query.ifaces.SelectQuery; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class OracleSelectQuery extends DatabaseSelectQuery implements SelectQuery { |
| | | |
| | | public OracleSelectQuery(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> execute(String tableName, List<String> columnsToSelect) throws Exception { |
| | | return execute(new OracleDbConnection(connectionParameter), tableName, columnsToSelect); |
| | | } |
| | | |
| | | @Override |
| | | protected List<Map<String, Object>> select(String tableName, Connection connection, List<String> columnsToSelect) throws Exception { |
| | | return new CommonSelectQuery(connection, tableName, columnsToSelect).execute(); |
| | | } |
| | | |
| | | @Override |
| | | public File execute(String tableName, List<DbColumnDescription> columnsDescription, String outputDir, String codeTypeFichier, boolean shouldTruncate) throws Exception { |
| | | List<String> columnsToSelect = columnsDescription.stream().map(c -> c.getName()).collect(Collectors.toList()); |
| | | List<Map<String, Object>> data = execute(tableName, columnsToSelect); |
| | | |
| | | return writeToFile(data, columnsDescription, outputDir, codeTypeFichier, tableName, shouldTruncate); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.select.impl; |
| | | |
| | | import com.megatim.queryadhoc.connection.impl.PostgresDbConnection; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.query.abstracts.DatabaseSelectQuery; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.queries.CommonSelectQuery; |
| | | import java.io.File; |
| | | import java.sql.Connection; |
| | | import java.sql.SQLException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import com.megatim.queryadhoc.query.ifaces.SelectQuery; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class PostgresSelectQuery extends DatabaseSelectQuery implements SelectQuery { |
| | | |
| | | public PostgresSelectQuery(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> execute(String tableName, List<String> columnsToSelect) throws Exception { |
| | | return execute(new PostgresDbConnection(connectionParameter), tableName, columnsToSelect); |
| | | } |
| | | |
| | | @Override |
| | | protected List<Map<String, Object>> select(String tableName, Connection connection, List<String> columnsToSelect) throws SQLException { |
| | | return new CommonSelectQuery(connection, tableName, columnsToSelect).execute(); |
| | | } |
| | | |
| | | @Override |
| | | public File execute(String tableName, List<DbColumnDescription> columnsDescription, String outputDir, String codeTypeFichier, boolean shouldTruncate) throws Exception { |
| | | List<String> columnsToSelect = columnsDescription.stream().map(c -> c.getName()).collect(Collectors.toList()); |
| | | List<Map<String, Object>> data = execute(tableName, columnsToSelect); |
| | | |
| | | return writeToFile(data, columnsDescription, outputDir, codeTypeFichier, tableName, shouldTruncate); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.query.select.impl; |
| | | |
| | | import com.megatim.queryadhoc.connection.impl.SqlServerDbConnection; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.query.abstracts.DatabaseSelectQuery; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import com.megatim.queryadhoc.queries.CommonSelectQuery; |
| | | import java.io.File; |
| | | import java.sql.Connection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import com.megatim.queryadhoc.query.ifaces.SelectQuery; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class SqlServerSelectQuery extends DatabaseSelectQuery implements SelectQuery { |
| | | |
| | | public SqlServerSelectQuery(ConnectionParameter connectionParameter) { |
| | | super(connectionParameter); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> execute(String tableName, List<String> columnsToSelect) throws Exception { |
| | | return execute(new SqlServerDbConnection(connectionParameter), tableName, columnsToSelect); |
| | | } |
| | | |
| | | @Override |
| | | protected List<Map<String, Object>> select(String tableName, Connection connection, List<String> columnsToSelect) throws Exception { |
| | | return new CommonSelectQuery(connection, tableName, columnsToSelect).execute(); |
| | | } |
| | | |
| | | @Override |
| | | public File execute(String tableName, List<DbColumnDescription> columnsDescription, String outputDir, String codeTypeFichier, boolean shouldTruncate) throws Exception { |
| | | List<String> columnsToSelect = columnsDescription.stream().map(c -> c.getName()).collect(Collectors.toList()); |
| | | List<Map<String, Object>> data = execute(tableName, columnsToSelect); |
| | | |
| | | return writeToFile(data, columnsDescription, outputDir, codeTypeFichier, tableName, shouldTruncate); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.table; |
| | | |
| | | import com.megatim.queryadhoc.connection.abtracts.DataBaseConnection; |
| | | import com.megatim.queryadhoc.connection.impl.MySqlDbConnection; |
| | | import com.megatim.queryadhoc.connection.impl.OracleDbConnection; |
| | | import com.megatim.queryadhoc.connection.impl.PostgresDbConnection; |
| | | import com.megatim.queryadhoc.connection.impl.SqlServerDbConnection; |
| | | import com.megatim.queryadhoc.enums.SgbdType; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionException; |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedDataBaseException; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import com.megatim.queryadhoc.query.ifaces.InsertQuery; |
| | | import com.megatim.queryadhoc.query.ifaces.SelectQuery; |
| | | import com.megatim.queryadhoc.query.insert.impl.MySqlInsertQuery; |
| | | import com.megatim.queryadhoc.query.insert.impl.OracleInsertQuery; |
| | | import com.megatim.queryadhoc.query.insert.impl.PostgresInsertQuery; |
| | | import com.megatim.queryadhoc.query.insert.impl.SqlServerInsertQuery; |
| | | import com.megatim.queryadhoc.query.select.impl.MySqlSelectQuery; |
| | | import com.megatim.queryadhoc.query.select.impl.OracleSelectQuery; |
| | | import com.megatim.queryadhoc.query.select.impl.PostgresSelectQuery; |
| | | import com.megatim.queryadhoc.query.select.impl.SqlServerSelectQuery; |
| | | import java.sql.Connection; |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.SQLException; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class DataBaseTable { |
| | | |
| | | private final SgbdType sgbdType; |
| | | private final ConnectionParameter connectionParameter; |
| | | |
| | | public DataBaseTable(SgbdType sgbdType, ConnectionParameter connectionParameter) { |
| | | this.sgbdType = sgbdType; |
| | | this.connectionParameter = connectionParameter; |
| | | } |
| | | |
| | | public SelectQuery select() throws NotSupportedDataBaseException { |
| | | if (sgbdType == null) { |
| | | throw new NotSupportedDataBaseException(null); |
| | | } |
| | | switch (sgbdType) { |
| | | case ORACLE: |
| | | return new OracleSelectQuery(connectionParameter); |
| | | case POSTGRESQL: |
| | | return new PostgresSelectQuery(connectionParameter); |
| | | case MYSQL: |
| | | return new MySqlSelectQuery(connectionParameter); |
| | | case SQLSERVER: |
| | | return new SqlServerSelectQuery(connectionParameter); |
| | | default: |
| | | throw new NotSupportedDataBaseException(sgbdType.name()); |
| | | } |
| | | } |
| | | |
| | | public InsertQuery insert() throws NotSupportedDataBaseException { |
| | | if (sgbdType == null) { |
| | | throw new NotSupportedDataBaseException(null); |
| | | } |
| | | switch (sgbdType) { |
| | | case ORACLE: |
| | | return new OracleInsertQuery(connectionParameter); |
| | | case POSTGRESQL: |
| | | return new PostgresInsertQuery(connectionParameter); |
| | | case MYSQL: |
| | | return new MySqlInsertQuery(connectionParameter); |
| | | case SQLSERVER: |
| | | return new SqlServerInsertQuery(connectionParameter); |
| | | default: |
| | | throw new NotSupportedDataBaseException(sgbdType.name()); |
| | | } |
| | | } |
| | | |
| | | public boolean isDatabaseAvailable() throws NotSupportedDataBaseException, ConnectionParameterException { |
| | | if (sgbdType == null) { |
| | | throw new NotSupportedDataBaseException(null); |
| | | } |
| | | try { |
| | | switch (sgbdType) { |
| | | case ORACLE: |
| | | return isDatabaseAvailable(new OracleDbConnection(connectionParameter)); |
| | | case POSTGRESQL: |
| | | return isDatabaseAvailable(new PostgresDbConnection(connectionParameter)); |
| | | case MYSQL: |
| | | return isDatabaseAvailable(new MySqlDbConnection(connectionParameter)); |
| | | case SQLSERVER: |
| | | return isDatabaseAvailable(new SqlServerDbConnection(connectionParameter)); |
| | | default: |
| | | throw new NotSupportedDataBaseException(sgbdType.name()); |
| | | } |
| | | } catch (ConnectionException ex) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public boolean tableExists(String tableName) throws NotSupportedDataBaseException, ConnectionParameterException, ConnectionException { |
| | | if (sgbdType == null) { |
| | | throw new NotSupportedDataBaseException(null); |
| | | } |
| | | try { |
| | | switch (sgbdType) { |
| | | case ORACLE: |
| | | return tableExists(new OracleDbConnection(connectionParameter), tableName); |
| | | case POSTGRESQL: |
| | | return tableExists(new PostgresDbConnection(connectionParameter), tableName); |
| | | case MYSQL: |
| | | return tableExists(new MySqlDbConnection(connectionParameter), tableName); |
| | | case SQLSERVER: |
| | | return tableExists(new SqlServerDbConnection(connectionParameter), tableName); |
| | | default: |
| | | throw new NotSupportedDataBaseException(sgbdType.name()); |
| | | } |
| | | } catch (SQLException ex) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private boolean isDatabaseAvailable(DataBaseConnection dbConnection) throws ConnectionException, ConnectionParameterException, NotSupportedDataBaseException { |
| | | |
| | | if (dbConnection != null) { |
| | | dbConnection.getConnection(); |
| | | dbConnection.closeConnection(); |
| | | return true; |
| | | } else { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private boolean tableExists(DataBaseConnection dbConnection, String tableName) throws ConnectionParameterException, NotSupportedDataBaseException, ConnectionException, SQLException { |
| | | String query = "SELECT * FROM " + tableName; |
| | | |
| | | try ( Connection connection = dbConnection.getConnection(); PreparedStatement stmt = connection.prepareStatement(query)) { |
| | | stmt.executeQuery(); |
| | | dbConnection.closeConnection(); |
| | | return true; |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.utils; |
| | | |
| | | import java.io.BufferedInputStream; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.nio.charset.Charset; |
| | | import java.nio.charset.UnsupportedCharsetException; |
| | | import org.apache.tika.parser.txt.CharsetDetector; |
| | | import org.apache.tika.parser.txt.CharsetMatch; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class CommonUtilities { |
| | | |
| | | private CommonUtilities() { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Méthode qui récupère l'encodage d'un fichier |
| | | * |
| | | * @param file : Fichier dont on veut connaître l'encodage |
| | | * @return : retourne l'encodage le plus probable |
| | | * @throws FileNotFoundException |
| | | * @throws IOException |
| | | */ |
| | | public static Charset getCharset(File file) throws FileNotFoundException, IOException { |
| | | try ( InputStream stream = new FileInputStream(file); InputStream input = new BufferedInputStream(stream);) { |
| | | CharsetDetector charsetDetector = new CharsetDetector(); |
| | | |
| | | charsetDetector.setText(input); |
| | | |
| | | CharsetMatch charsetMatch = charsetDetector.detect(); |
| | | String charsetName = charsetMatch != null ? charsetMatch.getName() : ""; |
| | | |
| | | return Charset.forName(charsetName); |
| | | |
| | | } catch (UnsupportedCharsetException ex) { |
| | | return Charset.forName("Cp850"); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.utils; |
| | | |
| | | import com.megatim.queryadhoc.enums.TypeDonnee; |
| | | import static com.megatim.queryadhoc.enums.TypeDonnee.ALPHANUMERIQUE; |
| | | import static com.megatim.queryadhoc.enums.TypeDonnee.DATE; |
| | | import static com.megatim.queryadhoc.enums.TypeDonnee.DECIMAL; |
| | | import static com.megatim.queryadhoc.enums.TypeDonnee.NUMERIQUE; |
| | | import com.megatim.queryadhoc.exceptions.ColumnNotFoundException; |
| | | import com.megatim.queryadhoc.exceptions.IllegalFormatDateException; |
| | | import com.megatim.queryadhoc.exceptions.NotSupportedTypeDonneeException; |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import java.sql.Timestamp; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class DataFormatter { |
| | | |
| | | private DataFormatter() { |
| | | |
| | | } |
| | | |
| | | public static String formatDatum(Map<String, Object> datumMap, List<DbColumnDescription> columnsDescription, String tableName, boolean shouldTruncate) throws ColumnNotFoundException, NotSupportedTypeDonneeException, IllegalFormatDateException { |
| | | StringBuilder line = new StringBuilder(); |
| | | |
| | | for (DbColumnDescription dbCol : columnsDescription) { |
| | | if (!datumMap.containsKey(dbCol.getName().toLowerCase())) { |
| | | throw new ColumnNotFoundException(dbCol.getName(), tableName); |
| | | } |
| | | Object datum = datumMap.get(dbCol.getName().toLowerCase()); |
| | | line.append(normalizeValue(datum, dbCol, shouldTruncate)); |
| | | } |
| | | return line.toString(); |
| | | } |
| | | |
| | | private static String normalizeValue(Object value, DbColumnDescription columnDesc, boolean shouldTruncate) throws NotSupportedTypeDonneeException, IllegalFormatDateException { |
| | | if (columnDesc.getTypeDonnee() == null) { |
| | | throw new NotSupportedTypeDonneeException(null); |
| | | } |
| | | String stringValue = value != null ? value.toString() : ""; |
| | | |
| | | if (columnDesc.getTypeDonnee().equals(TypeDonnee.DATE)) { |
| | | if (stringValue.isEmpty()) { |
| | | stringValue = generateUnknown(columnDesc.getTaille(), " "); |
| | | } else { |
| | | Timestamp timestamp = null; |
| | | if (value instanceof Timestamp) { |
| | | timestamp = (Timestamp) value; |
| | | } else { |
| | | timestamp = new Timestamp((long) value); |
| | | } |
| | | stringValue = formatDateToString(timestamp, columnDesc); |
| | | } |
| | | } |
| | | if (stringValue.length() < columnDesc.getTaille()) { |
| | | stringValue = formatData(columnDesc.getTypeDonnee(), stringValue, columnDesc.getTaille()); |
| | | } else if (shouldTruncate && (columnDesc.getTypeDonnee().equals(TypeDonnee.ALPHANUMERIQUE) || columnDesc.getTypeDonnee().equals(TypeDonnee.DATE)) |
| | | && stringValue.length() > columnDesc.getTaille()) { |
| | | stringValue = stringValue.substring(0, columnDesc.getTaille()); |
| | | } |
| | | return stringValue; |
| | | } |
| | | |
| | | private static String generateUnknown(int nbOfCharacter, String character) { |
| | | StringBuilder str = new StringBuilder(""); |
| | | |
| | | for (int i = 0; i < nbOfCharacter; i++) { |
| | | str.append(character); |
| | | } |
| | | return str.toString(); |
| | | } |
| | | |
| | | private static String formatData(TypeDonnee typeDonnee, String data, int columnSize) { |
| | | |
| | | if (typeDonnee != null) { |
| | | |
| | | switch (typeDonnee) { |
| | | |
| | | case NUMERIQUE: |
| | | |
| | | case DECIMAL: |
| | | return generateUnknown(columnSize - data.length(), "0") + data; |
| | | |
| | | case ALPHANUMERIQUE: |
| | | |
| | | case DATE: |
| | | |
| | | default: |
| | | return data + generateUnknown(columnSize - data.length(), " "); |
| | | } |
| | | } else { |
| | | throw new IllegalArgumentException(); |
| | | } |
| | | } |
| | | |
| | | private static String formatDateToString(Object obj, DbColumnDescription columnDesc) throws IllegalFormatDateException { |
| | | if (obj == null) { |
| | | return generateUnknown(columnDesc.getTaille(), " "); |
| | | } |
| | | Timestamp data = (Timestamp) obj; |
| | | LocalDateTime localDateTime = data.toLocalDateTime(); |
| | | |
| | | if (columnDesc.getFormatDate() == null) { |
| | | throw new IllegalFormatDateException(); |
| | | } |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern(columnDesc.getFormatDate()); |
| | | |
| | | if (formatter == null) { |
| | | return localDateTime.toString().substring(0, columnDesc.getTaille()); |
| | | } else { |
| | | return localDateTime.format(formatter); |
| | | } |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.utils; |
| | | |
| | | import com.megatim.queryadhoc.model.DbColumnDescription; |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.nio.charset.Charset; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class FileDataReader { |
| | | |
| | | private FileDataReader() { |
| | | |
| | | } |
| | | |
| | | public static List<Map<String, Object>> readFile(List<DbColumnDescription> columnsDescription, File dataFile) throws Exception { |
| | | List<Map<String, Object>> data = new ArrayList<>(); |
| | | |
| | | //Ranger les olonnes par ordre croissant de position |
| | | Collections.sort(columnsDescription, (DbColumnDescription c1, DbColumnDescription c2) -> Integer.valueOf(c1.getPosition()).compareTo(c2.getPosition())); |
| | | |
| | | //On détermine l'encodage du fichier |
| | | Charset charset = CommonUtilities.getCharset(dataFile); |
| | | |
| | | try ( FileInputStream fis = new FileInputStream(dataFile); InputStreamReader isr = new InputStreamReader(fis, charset); BufferedReader reader = new BufferedReader(isr)) { |
| | | String line; |
| | | |
| | | while ((line = reader.readLine()) != null) { |
| | | LinkedHashMap<String, Object> dataLine = getLine(line, columnsDescription); |
| | | data.add(dataLine); |
| | | } |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | |
| | | private static LinkedHashMap<String, Object> getLine(final String line, final List<DbColumnDescription> columnsDescription) { |
| | | LinkedHashMap<String, Object> dataLine = new LinkedHashMap<>(); |
| | | int index = 0; |
| | | |
| | | for (DbColumnDescription c : columnsDescription) { |
| | | |
| | | //traitement des colonnes du type fichier |
| | | String data = line.substring(index, index + c.getTaille()); |
| | | dataLine.put(c.getName(), data); |
| | | |
| | | index += c.getTaille(); |
| | | } |
| | | |
| | | return dataLine; |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license |
| | | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template |
| | | */ |
| | | package com.megatim.queryadhoc.validators; |
| | | |
| | | import com.megatim.queryadhoc.exceptions.ConnectionParameterException; |
| | | import com.megatim.queryadhoc.model.ConnectionParameter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * |
| | | * @author ASUS |
| | | */ |
| | | public class ConnectionParameterValidator { |
| | | |
| | | public void checkConnectionParameter(ConnectionParameter connectionParameter) throws ConnectionParameterException { |
| | | |
| | | List<String> errors = Arrays.asList(checkPort(connectionParameter.getPort()), |
| | | checkDataBaseName(connectionParameter.getDatabaseName()), |
| | | checkUserName(connectionParameter.getUserName()), |
| | | checkIpAddress(connectionParameter.getIpAddress())); |
| | | String message = errors.stream().filter(e -> !e.isEmpty()).collect(Collectors.joining("\n")); |
| | | |
| | | if (!message.isEmpty()) { |
| | | throw new ConnectionParameterException(message); |
| | | } |
| | | } |
| | | |
| | | private String checkPort(int port) { |
| | | if (port < 0 && port > 65535) { |
| | | return "La valeur du port est invalide"; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | private String checkDataBaseName(String dataBaseName) { |
| | | if (dataBaseName == null || dataBaseName.isEmpty()) { |
| | | return "Le nom de la base de données ne peut être vide ou nul"; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | private String checkUserName(String userName) { |
| | | if (userName == null || userName.isEmpty()) { |
| | | return "Le nom de l'utilisateur ne peut être vide ou nul"; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | private String checkIpAddress(String ipAddress) { |
| | | if (ipAddress == null || ipAddress.isEmpty()) { |
| | | return "Adresse IP Invalide"; |
| | | } |
| | | String[] tab = ipAddress.split("\\."); |
| | | |
| | | if (tab.length != 4 || !checkIpAdressPart(tab)) { |
| | | return "Adresse IP Invalide"; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | private boolean checkIpAdressPart(String[] tab) { |
| | | try { |
| | | int part1 = Integer.parseInt(tab[0]); |
| | | int part2 = Integer.parseInt(tab[1]); |
| | | int part3 = Integer.parseInt(tab[2]); |
| | | int part4 = Integer.parseInt(tab[3]); |
| | | return !(part1 < 0 || part1 > 255 |
| | | || part2 < 0 || part2 > 255 |
| | | || part3 < 0 || part3 > 255 |
| | | || part4 < 0 || part4 > 255); |
| | | } catch (Exception ex) { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | #Generated by Maven |
| | | #Thu May 15 17:03:16 WAT 2025 |
| | | version=1.0 |
| | | groupId=com.megatim.queryadhoc |
| | | artifactId=query-adhoc |
| New file |
| | |
| | | com\megatim\queryadhoc\factory\DbConnectionFactory.class |
| | | com\megatim\queryadhoc\contrat\PreparedStatementProcessor.class |
| | | com\megatim\queryadhoc\table\DataBaseTable$1.class |
| | | com\megatim\queryadhoc\utils\CommonUtilities.class |
| | | com\megatim\queryadhoc\queries\metadata\ParsedData.class |
| | | com\megatim\queryadhoc\contrat\DataColumn.class |
| | | com\megatim\queryadhoc\queries\metadata\DefaultDataColumn.class |
| | | com\megatim\queryadhoc\exceptions\ConnectionParameterException.class |
| | | com\megatim\queryadhoc\contrat\DefaultPreparedStatementProcessor.class |
| | | com\megatim\queryadhoc\contrat\DataRow.class |
| | | com\megatim\queryadhoc\query\select\impl\SqlServerSelectQuery.class |
| | | com\megatim\queryadhoc\queries\metadata\InsertData.class |
| | | com\megatim\queryadhoc\query\insert\impl\MySqlInsertQuery.class |
| | | com\megatim\queryadhoc\connection\abtracts\DataBaseConnection.class |
| | | com\megatim\queryadhoc\queries\CommonInsertQuery.class |
| | | com\megatim\queryadhoc\utils\DataFormatter$1.class |
| | | com\megatim\queryadhoc\utils\DataFormatter.class |
| | | com\megatim\queryadhoc\utils\FileDataReader.class |
| | | com\megatim\queryadhoc\contrat\InsertMetaData.class |
| | | com\megatim\queryadhoc\query\insert\impl\PostgresInsertQuery.class |
| | | com\megatim\queryadhoc\table\DataBaseTable.class |
| | | com\megatim\queryadhoc\exceptions\ColumnNotFoundException.class |
| | | com\megatim\queryadhoc\exceptions\LocalDateTimeValueParseError.class |
| | | com\megatim\queryadhoc\queries\metadata\DefaultDataRow.class |
| | | com\megatim\queryadhoc\connection\impl\OracleDbConnection.class |
| | | com\megatim\queryadhoc\model\DbColumnDescription.class |
| | | com\megatim\queryadhoc\validators\ConnectionParameterValidator.class |
| | | com\megatim\queryadhoc\query\ifaces\SelectQuery.class |
| | | com\megatim\queryadhoc\query\abstracts\DatabaseSelectQuery.class |
| | | com\megatim\queryadhoc\App.class |
| | | com\megatim\queryadhoc\query\insert\impl\OracleInsertQuery.class |
| | | com\megatim\queryadhoc\query\abstracts\DatabaseInsertQuery.class |
| | | com\megatim\queryadhoc\query\select\impl\PostgresSelectQuery.class |
| | | com\megatim\queryadhoc\exceptions\NotSupportedDataBaseException.class |
| | | com\megatim\queryadhoc\connection\impl\MySqlDbConnection.class |
| | | com\megatim\queryadhoc\enums\SgbdType.class |
| | | com\megatim\queryadhoc\model\ConnectionParameter.class |
| | | com\megatim\queryadhoc\factory\DbConnectionFactory$1.class |
| | | com\megatim\queryadhoc\exceptions\ConnectionException.class |
| | | com\megatim\queryadhoc\exceptions\BadColumnTypeException.class |
| | | com\megatim\queryadhoc\enums\TypeDonnee.class |
| | | com\megatim\queryadhoc\query\insert\impl\SqlServerInsertQuery.class |
| | | com\megatim\queryadhoc\queries\CommonSelectQuery.class |
| | | com\megatim\queryadhoc\query\ifaces\InsertQuery.class |
| | | com\megatim\queryadhoc\exceptions\NotSupportedTypeDonneeException.class |
| | | com\megatim\queryadhoc\exceptions\IllegalFormatDateException.class |
| | | com\megatim\queryadhoc\query\select\impl\MySqlSelectQuery.class |
| | | com\megatim\queryadhoc\query\select\impl\OracleSelectQuery.class |
| | | com\megatim\queryadhoc\connection\impl\SqlServerDbConnection.class |
| | | com\megatim\queryadhoc\queries\metadata\ParsedDataRow.class |
| | | com\megatim\queryadhoc\exceptions\BadDataValueException.class |
| | | com\megatim\queryadhoc\connection\impl\PostgresDbConnection.class |
| | | com\megatim\queryadhoc\queries\metadata\LocalDateTimeValue.class |
| | | com\megatim\queryadhoc\model\QueryParam.class |
| New file |
| | |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\queries\CommonSelectQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\queries\CommonInsertQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\contrat\InsertMetaData.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\ConnectionParameterException.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\ConnectionException.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\insert\impl\SqlServerInsertQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\NotSupportedDataBaseException.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\queries\metadata\DefaultDataColumn.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\enums\SgbdType.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\contrat\DataRow.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\queries\metadata\InsertData.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\select\impl\SqlServerSelectQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\contrat\DefaultPreparedStatementProcessor.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\select\impl\PostgresSelectQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\model\DbColumnDescription.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\queries\metadata\ParsedData.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\IllegalFormatDateException.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\abstracts\DatabaseInsertQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\abstracts\DatabaseSelectQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\insert\impl\MySqlInsertQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\BadDataValueException.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\queries\metadata\LocalDateTimeValue.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\ifaces\SelectQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\ifaces\InsertQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\enums\TypeDonnee.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\utils\CommonUtilities.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\utils\DataFormatter.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\select\impl\MySqlSelectQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\model\QueryParam.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\contrat\PreparedStatementProcessor.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\connection\impl\PostgresDbConnection.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\utils\FileDataReader.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\insert\impl\PostgresInsertQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\validators\ConnectionParameterValidator.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\insert\impl\OracleInsertQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\LocalDateTimeValueParseError.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\query\select\impl\OracleSelectQuery.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\queries\metadata\ParsedDataRow.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\connection\abtracts\DataBaseConnection.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\connection\impl\OracleDbConnection.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\factory\DbConnectionFactory.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\connection\impl\MySqlDbConnection.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\contrat\DataColumn.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\NotSupportedTypeDonneeException.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\connection\impl\SqlServerDbConnection.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\BadColumnTypeException.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\table\DataBaseTable.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\App.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\exceptions\ColumnNotFoundException.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\model\ConnectionParameter.java |
| | | C:\Users\ASUS\Documents\NetBeansProjects\mgt-data-base-query-module\query-adhoc\src\main\java\com\megatim\queryadhoc\queries\metadata\DefaultDataRow.java |