From 1b340d82dfbcc2675d34b180f9824dc1e5aded4b Mon Sep 17 00:00:00 2001 From: Sanjula Ganepola <32170854+SanjulaGanepola@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:39:44 -0400 Subject: [PATCH] Rename package, add Java docs (#29) * Fix naming to mapepire Signed-off-by: Sanjula Ganepola * rename to Mapepire SDK Signed-off-by: Sanjula Ganepola * remove unused imports Signed-off-by: Sanjula Ganepola * Add maven central badge Signed-off-by: Sanjula Ganepola * Add java docs for types Signed-off-by: Sanjula Ganepola * Add java docs for pool, query, and sqljob classes Signed-off-by: Sanjula Ganepola * add javadocs for all jdbc options Signed-off-by: Sanjula Ganepola * Fix checkstyle issues Signed-off-by: Sanjula Ganepola * rename package Signed-off-by: Sanjula Ganepola * update README Signed-off-by: Sanjula Ganepola * fix java doc error Signed-off-by: Sanjula Ganepola --------- Signed-off-by: Sanjula Ganepola --- README.md | 212 +++---- pom.xml | 4 +- .../java/io/github/mapepire_ibmi/Pool.java | 199 +++--- .../java/io/github/mapepire_ibmi/Query.java | 106 ++++ .../java/io/github/mapepire_ibmi/SqlJob.java | 339 +++++++--- .../java/io/github/mapepire_ibmi/Tls.java | 25 +- .../mapepire_ibmi/types/CLCommandResult.java | 29 + .../mapepire_ibmi/types/ColumnMetadata.java | 66 ++ .../mapepire_ibmi/types/ConnectionResult.java | 26 + .../mapepire_ibmi/types/DaemonServer.java | 84 +++ .../mapepire_ibmi/types/ExplainResults.java | 43 ++ .../mapepire_ibmi/types/ExplainType.java | 10 + .../types/GetTraceDataResult.java | 30 +- .../mapepire_ibmi/types/JDBCOptions.java | 483 +++++++++++--- .../mapepire_ibmi/types/JobLogEntry.java | 124 ++++ .../github/mapepire_ibmi/types/JobStatus.java | 41 ++ .../mapepire_ibmi/types/PoolAddOptions.java | 67 ++ .../mapepire_ibmi/types/PoolOptions.java | 123 ++++ .../mapepire_ibmi/types/QueryMetadata.java | 52 ++ .../mapepire_ibmi/types/QueryOptions.java | 52 ++ .../mapepire_ibmi/types/QueryResult.java | 85 +++ .../mapepire_ibmi/types/QueryState.java | 39 ++ .../mapepire_ibmi/types/ServerResponse.java | 80 +++ .../mapepire_ibmi/types/ServerTraceDest.java | 29 + .../mapepire_ibmi/types/ServerTraceLevel.java | 45 +- .../mapepire_ibmi/types/SetConfigResult.java | 43 ++ .../types/TransactionEndType.java | 10 + .../types/VersionCheckResult.java | 47 ++ .../types/jdbcOptions/Access.java | 33 + .../types/jdbcOptions/BidiStringType.java | 54 ++ .../types/jdbcOptions/BlockCriteria.java | 34 + .../types/jdbcOptions/BlockSize.java | 54 ++ .../ConcurrentAccessResolution.java | 34 + .../types/jdbcOptions/CursorSensitivity.java | 34 + .../types/jdbcOptions/DateFormat.java | 54 ++ .../types/jdbcOptions/DateSeparator.java | 42 ++ .../jdbcOptions/DecfloatRoundingMode.java | 50 ++ .../types/jdbcOptions/DecimalSeparator.java | 30 + .../types/jdbcOptions/Driver.java | 30 + .../types/jdbcOptions/Error.java | 25 - .../types/jdbcOptions/Errors.java | 52 ++ .../types/jdbcOptions/MaximumPrecision.java | 30 + .../types/jdbcOptions/MetadataSource.java | 30 + .../types/jdbcOptions/MinimumDivideScale.java | 62 ++ .../types/jdbcOptions/Naming.java | 29 + .../types/jdbcOptions/Option.java | 595 ++++++++++++++++++ .../types/jdbcOptions/PackageCcsid.java | 34 + .../types/jdbcOptions/PackageCriteria.java | 30 + .../types/jdbcOptions/PackageError.java | 34 + .../types/jdbcOptions/Property.java | 106 ---- .../types/jdbcOptions/QueryOptimizeGoal.java | 36 ++ .../jdbcOptions/QueryTimeoutMechanism.java | 32 + .../types/jdbcOptions/Remarks.java | 29 + .../types/jdbcOptions/ServerTrace.java | 50 ++ .../mapepire_ibmi/types/jdbcOptions/Sort.java | 33 + .../types/jdbcOptions/SortWeight.java | 30 + .../types/jdbcOptions/TimeFormat.java | 42 ++ .../types/jdbcOptions/TimeSeparator.java | 38 ++ .../types/jdbcOptions/ToolboxTrace.java | 75 +++ .../jdbcOptions/TransactionIsolation.java | 42 ++ .../types/jdbcOptions/TranslateHex.java | 27 + .../jdbcOptions/XALooselyCoupledSupport.java | 27 + .../io/github/mapepire_ibmi/MapepireTest.java | 4 +- .../io/github/mapepire_ibmi/PoolTest.java | 1 + .../io/github/mapepire_ibmi/SimpleTest.java | 6 +- 65 files changed, 3935 insertions(+), 506 deletions(-) create mode 100644 src/main/java/io/github/mapepire_ibmi/types/PoolAddOptions.java create mode 100644 src/main/java/io/github/mapepire_ibmi/types/PoolOptions.java delete mode 100644 src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Error.java create mode 100644 src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Errors.java create mode 100644 src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Option.java delete mode 100644 src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Property.java diff --git a/README.md b/README.md index 8934614..ebad2b0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Mapepire Java Client SDK -[![Maven Build](https://github.com/Mapepire-IBMi/mapepire-java/actions/workflows/build.yml/badge.svg)](https://github.com/Mapepire-IBMi/mapepire-java/actions/workflows/build.yml) [![License](https://img.shields.io/github/license/allenai/tango.svg?color=blue&cachedrop)](https://github.com/Mapepire-IBMi/mapepire-java/blob/main/LICENSE) +[![Maven Central](https://img.shields.io/maven-central/v/io.github.mapepire-ibmi/mapepire-sdk.svg?label=Maven%20Central&logo=apachemaven)](https://central.sonatype.com/artifact/io.github.mapepire-ibmi/mapepire-sdk/) +[![Maven Build](https://github.com/Mapepire-IBMi/mapepire-java/actions/workflows/build.yml/badge.svg)](https://github.com/Mapepire-IBMi/mapepire-java/actions/workflows/build.yml) +[![License](https://img.shields.io/github/license/allenai/tango.svg?color=blue&cachedrop)](https://github.com/Mapepire-IBMi/mapepire-java/blob/main/LICENSE) ## Overview @@ -14,13 +16,13 @@ Full Documentation: https://mapepire-ibmi.github.io * Java 8 or later -### Install with `maven` (Forthcoming) +### Install with `maven` ```xml io.github.mapepire-ibmi mapepire-sdk - 0.0.4 + 0.0.3 ``` @@ -30,128 +32,104 @@ In order for applications to use Db2 for i through this Java client SDK, the `ma ## Example Usage -The following Java program creates a `DaemonServer` object that will be used to connect with the Server Component. Then a single `SqlJob` is created to facilitate the connection from the client side. +The following Java program initializes a `DaemonServer` object that will be used to connect with the Server Component. A single `SqlJob` object is created to facilitate this connection from the client side. A `query` object is then initialized with a simple `SELECT` query which is finally executed with 3 rows being fetched and the results being printed. -```java +> [!NOTE] +> To run this Java program, replace the credentials which are passed into the `DaemonServer` object. +```java +package io.github.app; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +import io.github.mapepire_ibmi.Query; +import io.github.mapepire_ibmi.SqlJob; +import io.github.mapepire_ibmi.types.DaemonServer; +import io.github.mapepire_ibmi.types.QueryResult; + +public final class App { + public static void main(String[] args) throws Exception { + // Initialize credentials + DaemonServer creds = new DaemonServer("HOST", 8085, "USER", "PASSWORD", true, "CA"); + + // Establish connection + SqlJob job = new SqlJob(); + job.connect(creds).get(); + + // Initialize and execute query + Query query = job.query("SELECT * FROM SAMPLE.DEPARTMENT"); + QueryResult result = query.execute(3).get(); + + // Convert to JSON string and output + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.INDENT_OUTPUT); + String jsonString = mapper.writeValueAsString(result); + System.out.println(jsonString); + } +} ``` Output: ```json { - "id":"query3", - "has_results":true, - "update_count":-1, - "metadata":{ - "column_count":14, - "job":"330955/QUSER/QZDASOINIT", - "columns":[ - { - "name":"EMPNO", - "type":"CHAR", - "display_size":6, - "label":"EMPNO" - }, - { - "name":"FIRSTNME", - "type":"VARCHAR", - "display_size":12, - "label":"FIRSTNME" - }, - { - "name":"MIDINIT", - "type":"CHAR", - "display_size":1, - "label":"MIDINIT" - }, - { - "name":"LASTNAME", - "type":"VARCHAR", - "display_size":15, - "label":"LASTNAME" - }, - { - "name":"WORKDEPT", - "type":"CHAR", - "display_size":3, - "label":"WORKDEPT" - }, - { - "name":"PHONENO", - "type":"CHAR", - "display_size":4, - "label":"PHONENO" - }, - { - "name":"HIREDATE", - "type":"DATE", - "display_size":10, - "label":"HIREDATE" - }, - { - "name":"JOB", - "type":"CHAR", - "display_size":8, - "label":"JOB" - }, - { - "name":"EDLEVEL", - "type":"SMALLINT", - "display_size":6, - "label":"EDLEVEL" - }, - { - "name":"SEX", - "type":"CHAR", - "display_size":1, - "label":"SEX" - }, - { - "name":"BIRTHDATE", - "type":"DATE", - "display_size":10, - "label":"BIRTHDATE" - }, - { - "name":"SALARY", - "type":"DECIMAL", - "display_size":11, - "label":"SALARY" - }, - { - "name":"BONUS", - "type":"DECIMAL", - "display_size":11, - "label":"BONUS" - }, - { - "name":"COMM", - "type":"DECIMAL", - "display_size":11, - "label":"COMM" - } - ] + "id" : "query3", + "success" : true, + "error" : null, + "sql_rc" : 0, + "sql_state" : null, + "metadata" : { + "column_count" : 5, + "columns" : [ { + "display_size" : 3, + "label" : "DEPTNO", + "name" : "DEPTNO", + "type" : "CHAR" + }, { + "display_size" : 36, + "label" : "DEPTNAME", + "name" : "DEPTNAME", + "type" : "VARCHAR" + }, { + "display_size" : 6, + "label" : "MGRNO", + "name" : "MGRNO", + "type" : "CHAR" + }, { + "display_size" : 3, + "label" : "ADMRDEPT", + "name" : "ADMRDEPT", + "type" : "CHAR" + }, { + "display_size" : 16, + "label" : "LOCATION", + "name" : "LOCATION", + "type" : "CHAR" + } ], + "job" : "930740/QUSER/QZDASOINIT" }, - "data":[ - { - "EMPNO":"000010", - "FIRSTNME":"CHRISTINE", - "MIDINIT":"I", - "LASTNAME":"HAAS", - "WORKDEPT":"A00", - "PHONENO":"3978", - "HIREDATE":"01/01/65", - "JOB":"PRES", - "EDLEVEL":18, - "SEX":"F", - "BIRTHDATE":"None", - "SALARY":52750.0, - "BONUS":1000.0, - "COMM":4220.0 - } - ], - "is_done":false, - "success":true + "is_done" : false, + "has_results" : true, + "update_count" : -1, + "data" : [ { + "DEPTNO" : "A00", + "DEPTNAME" : "SPIFFY COMPUTER SERVICE DIV.", + "MGRNO" : "000010", + "ADMRDEPT" : "A00", + "LOCATION" : null + }, { + "DEPTNO" : "B01", + "DEPTNAME" : "PLANNING", + "MGRNO" : "000020", + "ADMRDEPT" : "A00", + "LOCATION" : null + }, { + "DEPTNO" : "C01", + "DEPTNAME" : "INFORMATION CENTER", + "MGRNO" : "000030", + "ADMRDEPT" : "A00", + "LOCATION" : null + } ] } ``` \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5bcf466..5ac1991 100644 --- a/pom.xml +++ b/pom.xml @@ -5,10 +5,10 @@ io.github.mapepire-ibmi mapepire-sdk - 0.0.2-SNAPSHOT + 0.0.3 jar - Mapepire Java + Mapepire SDK The Mapepire Java client SDK provides a new and convenient way to access Db2 on IBM i https://github.com/Mapepire-IBMi/mapepire-java diff --git a/src/main/java/io/github/mapepire_ibmi/Pool.java b/src/main/java/io/github/mapepire_ibmi/Pool.java index 34475b4..2ded1fe 100644 --- a/src/main/java/io/github/mapepire_ibmi/Pool.java +++ b/src/main/java/io/github/mapepire_ibmi/Pool.java @@ -8,94 +8,48 @@ import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import java.util.stream.IntStream; -import io.github.mapepire_ibmi.types.DaemonServer; -import io.github.mapepire_ibmi.types.JDBCOptions; import io.github.mapepire_ibmi.types.JobStatus; +import io.github.mapepire_ibmi.types.PoolAddOptions; +import io.github.mapepire_ibmi.types.PoolOptions; import io.github.mapepire_ibmi.types.QueryOptions; import io.github.mapepire_ibmi.types.QueryResult; -class PoolOptions { - private DaemonServer creds; - private JDBCOptions opts; - private int maxSize; - private int startingSize; - - PoolOptions(DaemonServer creds, JDBCOptions opts, int maxSize, int startingSize) { - this.creds = creds; - this.opts = opts; - this.maxSize = maxSize; - this.startingSize = startingSize; - } - - PoolOptions(DaemonServer creds, int maxSize, int startingSize) { - this.creds = creds; - this.opts = new JDBCOptions(); - this.maxSize = maxSize; - this.startingSize = startingSize; - } - - public DaemonServer getCreds() { - return creds; - } - - public JDBCOptions getOpts() { - return opts; - } - - public int getMaxSize() { - return maxSize; - } - - public int getStartingSize() { - return startingSize; - } -} - -class PoolAddOptions { - /** An existing job to add to the pool */ - private SqlJob existingJob; - - /** Don't add to the pool */ - private boolean poolIgnore; - - public PoolAddOptions() { - - } - - public PoolAddOptions(SqlJob existingJob, boolean poolIgnore) { - this.existingJob = existingJob; - this.poolIgnore = poolIgnore; - } - - public SqlJob getExistingJob() { - return existingJob; - } - - public void setExistingJob(SqlJob existingJob) { - this.existingJob = existingJob; - } - - public boolean isPoolIgnore() { - return poolIgnore; - } - - public void setPoolIgnore(boolean poolIgnore) { - this.poolIgnore = poolIgnore; - } -} - +/** + * Represents a connection pool for managing SQL jobs. + */ public class Pool { + /** + * A list of SqlJob instances managed by the pool. + */ private List jobs = Collections.synchronizedList(new LinkedList()); + + /** + * The options for configuring the connection pool. + */ private PoolOptions options; + + /** + * A list of invalid job states (ended or not started). + */ private List INVALID_STATES = new ArrayList( Arrays.asList(JobStatus.Ended, JobStatus.NotStarted)); + /** + * Construct a new Pool instance. + * + * @param options The options for configuring the connection pool. + */ Pool(PoolOptions options) { this.options = options; } + /** + * Initializes the pool by creating a number of SQL jobs defined by the starting + * size. + * + * @return A CompletableFuture that resolves when all jobs have been created. + */ public CompletableFuture init() { List> futures = new ArrayList<>(); for (int i = 0; i < options.getStartingSize(); i++) { @@ -105,6 +59,11 @@ public CompletableFuture init() { return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); } + /** + * Check if there is space available in the pool for more jobs. + * + * @return Whether there is space available. + */ public boolean hasSpace() { int activeJobCount = this.jobs.stream() .filter(j -> !INVALID_STATES.contains(j.getStatus())) @@ -113,6 +72,11 @@ public boolean hasSpace() { return activeJobCount < options.getMaxSize(); } + /** + * Get the count of active jobs that are either busy or ready. + * + * @return The number of active jobs. + */ public int getActiveJobCount() { return this.jobs.stream() .filter(j -> j.getStatus() == JobStatus.Busy || j.getStatus() == JobStatus.Ready) @@ -120,16 +84,29 @@ public int getActiveJobCount() { .size(); } + /** + * Clean up the pool by removing jobs that are in invalid states. + */ public void cleanup() { this.jobs.removeIf(j -> INVALID_STATES.contains(j.getStatus())); } + /** + * Add a new job to the pool. + * + * @return A CompletableFuture that resolves to the new job. + */ public CompletableFuture addJob() { PoolAddOptions options = new PoolAddOptions(); return this.addJob(options); } - // TODO: test cases with existingJob parameter + /** + * Add a new job to the pool. + * + * @param options Options for configuring an addition to the connection pool. + * @return A CompletableFuture that resolves to the new job. + */ public CompletableFuture addJob(PoolAddOptions options) { if (options.getExistingJob() != null) { cleanup(); @@ -138,7 +115,7 @@ public CompletableFuture addJob(PoolAddOptions options) { SqlJob newSqlJob = options.getExistingJob() != null ? options.getExistingJob() : new SqlJob(this.options.getOpts()); - if (options.isPoolIgnore() != true) { + if (options.getPoolIgnore() != true) { this.jobs.add(newSqlJob); } @@ -153,6 +130,11 @@ public CompletableFuture addJob(PoolAddOptions options) { return CompletableFuture.completedFuture(newSqlJob); } + /** + * Get a ready job from the pool. + * + * @return The first ready job found, or null if none are ready. + */ public SqlJob getReadyJob() { return this.jobs .stream() @@ -162,9 +144,11 @@ public SqlJob getReadyJob() { } /** - * Returns a job as fast as possible. It will either be a ready job - * or the job with the least requests on the queue. Will spawn new jobs - * if the pool is not full but all jobs are busy. + * Get a job as fast as possible. It will either be a ready job or the job with + * the least requests on the queue. It will spawn new jobs if the pool is not + * full but all jobs are busy. + * + * @return The retrieved job. */ public synchronized SqlJob getJob() { SqlJob job = this.getReadyJob(); @@ -189,14 +173,23 @@ public synchronized SqlJob getJob() { return job; } + /** + * Wait for a job to become available. It will return a ready job if one exists, + * otherwise, it may create a new job if the pool is not full. + * + * @return A CompletableFuture that resolves to a ready job. + */ public CompletableFuture waitForJob() { return this.waitForJob(false); } /** - * Returns a ready job if one is available, otherwise it will add a new job. - * If the pool is full, then it will find a job with the least requests on the - * queue. + * Wait for a job to become available. It will return a ready job if one exists, + * otherwise, it may create a new job if the pool is not full. + * + * @param useNewJob Whether a new job should be created even if the pool is + * full. + * @return A CompletableFuture that resolves to a ready job. */ public CompletableFuture waitForJob(boolean useNewJob) { SqlJob job = getReadyJob(); @@ -214,12 +207,15 @@ public CompletableFuture waitForJob(boolean useNewJob) { return CompletableFuture.completedFuture(job); } - // TODO: needs test cases /** - * Returns a job that is ready to be used. If no jobs are ready, it will - * create a new job and return that. Use `addJob` to add back to the pool. + * Pops a job from the pool if one is ready. If no jobs are ready, it will + * create a new job and return that. The returned job should be added back to + * the pool. + * + * @return A CompletableFuture that resolves to a ready job or a new job. */ - public CompletableFuture popJob() { //TODO: dead code: what to do with it? + public CompletableFuture popJob() { + // TODO: dead code: what to do with it? SqlJob readyJob = getReadyJob(); if (null != readyJob) { jobs.remove(readyJob); @@ -232,26 +228,59 @@ public CompletableFuture popJob() { //TODO: dead code: what to do with i } } + /** + * Create a Query object using a job from the pool. + * + * @param The type of data to be returned. + * @param sql The SQL query. + * @return A new Query instance. + */ public Query query(String sql) { QueryOptions options = new QueryOptions(); return this.query(sql, options); } + /** + * Create a Query object using a job from the pool. + * + * @param The type of data to be returned. + * @param sql The SQL query. + * @param opts The options for configuring the query. + * @return A new Query instance. + */ public Query query(String sql, QueryOptions opts) { SqlJob job = this.getJob(); return job.query(sql, opts); } + /** + * Execute a SQL command using a job from the pool. + * + * @param The type of data to be returned. + * @param sql The SQL command to execute. + * @return A CompletableFuture that resolves to the query result. + */ public CompletableFuture> execute(String sql) throws Exception { QueryOptions options = new QueryOptions(); return this.execute(sql, options); } + /** + * Execute a SQL command using a job from the pool. + * + * @param The type of data to be returned. + * @param sql The SQL command to execute. + * @param opts The options for configuring the query. + * @return A CompletableFuture that resolves to the query result. + */ public CompletableFuture> execute(String sql, QueryOptions opts) throws Exception { SqlJob job = this.getJob(); return job.execute(sql, opts); } + /** + * Close all jobs in the pool. + */ public void end() { this.jobs.forEach(j -> j.close()); } diff --git a/src/main/java/io/github/mapepire_ibmi/Query.java b/src/main/java/io/github/mapepire_ibmi/Query.java index 92c1d52..036a7b7 100644 --- a/src/main/java/io/github/mapepire_ibmi/Query.java +++ b/src/main/java/io/github/mapepire_ibmi/Query.java @@ -13,19 +13,71 @@ import io.github.mapepire_ibmi.types.QueryResult; import io.github.mapepire_ibmi.types.QueryState; +/** + * Represents a SQL query that can be executed and managed within a SQL job. + */ public class Query { + /** + * The SQL job that this query will be executed in. + */ private SqlJob job; + + /** + * A list of all global queries that are currently open. + */ private static List> globalQueryList = new ArrayList<>(); + + /** + * The correlation ID associated with the query. + */ private String correlationId; + + /** + * The SQL statement to be executed. + */ private String sql; + + /** + * Whether the query has been prepared. + */ private boolean isPrepared = false; + + /** + * The parameters to be used with the SQL query. + */ private List parameters; + + /** + * The number of rows to fetch in each execution. + */ private int rowsToFetch = 100; + + /** + * Whether the query is a CL command. + */ private boolean isCLCommand; + + /** + * The current state of the query execution. + */ private QueryState state = QueryState.NOT_YET_RUN; + + /** + * Whether the results should be terse. + */ private boolean isTerseResults; + + /** + * TODO: Remove + */ private static final ObjectMapper objectMapper = new ObjectMapper(); + /** + * Construct a new Query instance. + * @param job The SQL job that this query will be executed in. + * @param query The SQL statement to be executed. + * @param opts The options for configuring a query. + */ public Query(SqlJob job, String query, QueryOptions opts) { this.job = job; this.sql = query; @@ -39,6 +91,11 @@ public Query(SqlJob job, String query, QueryOptions opts) { Query.globalQueryList.add(this); } + /** + * Get a Query instance by its correlation ID. + * @param id The correlation ID of the query. + * @return The corresponding Query instance or null if not found. + */ public static Query byId(String id) { if (id == null || id == "") { return null; @@ -51,6 +108,19 @@ public static Query byId(String id) { } } + /** + * Get a list of open correlation IDs. + * @return A list of correlation IDs for open queries. + */ + public static List getOpenIds() { + return Query.getOpenIds(null); + } + + /** + * Get a list of open correlation IDs for the specified job. + * @param forJob The job to filter the queries by. + * @return A list of correlation IDs for open queries. + */ public static List getOpenIds(SqlJob forJob) { return Query.globalQueryList.stream() .filter(q -> q.job.equals(forJob) || forJob == null) @@ -60,6 +130,10 @@ public static List getOpenIds(SqlJob forJob) { .collect(Collectors.toList()); } + /** + * Clean up queries that are done or are in error state from the global query + * list. + */ public void cleanup() { List> futures = globalQueryList.stream() .filter(query -> query.getState() == QueryState.RUN_DONE || query.getState() == QueryState.ERROR) @@ -85,10 +159,21 @@ public void cleanup() { .collect(Collectors.toList()); } + /** + * Execute an SQL command and returns the result. + * @param The type of data to be returned. + * @return A CompletableFuture that resolves to the query result. + */ public CompletableFuture> execute() throws Exception { return this.execute(100); } + /** + * Execute an SQL command and returns the result. + * @param The type of data to be returned. + * @param rowsToFetch The number of rows to fetch. + * @return A CompletableFuture that resolves to the query result. + */ public CompletableFuture> execute(int rowsToFetch) throws Exception { switch (this.state) { case RUN_MORE_DATA_AVAILABLE: @@ -165,10 +250,19 @@ public CompletableFuture> execute(int rowsToFetch) throws Exc return CompletableFuture.completedFuture(queryResult); } + /** + * Fetch more rows from the currently running query. + * @return A CompletableFuture that resolves to the query result. + */ public CompletableFuture> fetchMore() throws Exception { return this.fetchMore(this.rowsToFetch); } + /** + * Fetch more rows from the currently running query. + * @param rowsToFetch The number of additional rows to fetch. + * @return A CompletableFuture that resolves to the query result. + */ public CompletableFuture> fetchMore(int rowsToFetch) throws Exception { switch (this.state) { case NOT_YET_RUN: @@ -220,6 +314,10 @@ public CompletableFuture> fetchMore(int rowsToFetch) throws Excep } } + /** + * Close the query. + * @return A CompletableFuture that resolves when the query is closed. + */ public CompletableFuture close() { if (correlationId != null && state != QueryState.RUN_DONE) { state = QueryState.RUN_DONE; @@ -242,10 +340,18 @@ public CompletableFuture close() { } } + /** + * Get the correlation ID of the query. + * @return The correlation ID of the query. + */ public String getId() { return this.correlationId; } + /** + * Get the current state of the query execution. + * @return The current state of the query execution. + */ public QueryState getState() { return this.state; } diff --git a/src/main/java/io/github/mapepire_ibmi/SqlJob.java b/src/main/java/io/github/mapepire_ibmi/SqlJob.java index a59c0f4..b99c5a5 100644 --- a/src/main/java/io/github/mapepire_ibmi/SqlJob.java +++ b/src/main/java/io/github/mapepire_ibmi/SqlJob.java @@ -22,7 +22,6 @@ import org.java_websocket.handshake.ServerHandshake; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.ObjectMapper; import io.github.mapepire_ibmi.types.ConnectionResult; import io.github.mapepire_ibmi.types.DaemonServer; @@ -39,81 +38,121 @@ import io.github.mapepire_ibmi.types.SetConfigResult; import io.github.mapepire_ibmi.types.TransactionEndType; import io.github.mapepire_ibmi.types.VersionCheckResult; -import io.github.mapepire_ibmi.types.jdbcOptions.Property; +import io.github.mapepire_ibmi.types.jdbcOptions.Option; import io.github.mapepire_ibmi.types.jdbcOptions.TransactionIsolation; -// class ReqRespFmt { -// String id; - -// public ReqRespFmt(String id) { -// this.id = id; -// } - -// String getId() { -// return this.id; -// } -// }; - -class NoAuthTrustManager implements X509TrustManager { - @Override - public void checkClientTrusted(final X509Certificate[] chain, final String authType) - throws CertificateException { - } - - @Override - public void checkServerTrusted(final X509Certificate[] chain, final String authType) - throws CertificateException { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; - } -} +import com.fasterxml.jackson.databind.ObjectMapper; +/** + * Represents a SQL job that manages connections and queries to a database. + */ public class SqlJob { - String transactionCountQuery = String.join("\n", Arrays.asList( + private String transactionCountQuery = String.join("\n", Arrays.asList( "select count(*) as thecount", " from qsys2.db_transaction_info", " where JOB_NAME = qsys2.job_name and", " (local_record_changes_pending = 'YES' or local_object_changes_pending = 'YES')")); + /** + * A counter to generate unique IDs for each SQLJob instance. + */ private static int uniqueIdCounter = 0; + + /** + * The socket used to communicate with the Mapepire Server component. + */ private WebSocketClient socket; - // private responseEmitter: EventEmitter = new EventEmitter(); + + /** + * The job status. + */ private JobStatus status = JobStatus.NotStarted; - private String traceFile; + + /** + * The destination for trace data. + */ + private String tracedest; + + /** + * Whether channel data is being traced. + */ private boolean isTracingChannelData = false; + + /** + * The unique job identifier for the connection. + * TODO: This is not being used. + */ private String id; - private JDBCOptions options = new JDBCOptions(); + + /** + * The JDBC options. + */ + private JDBCOptions options; + + /** + * A CompletableFuture to handle asynchronous opening of the socket connection. + */ + CompletableFuture openedConnectionFuture; + + /** + * A map to handle asynchronous socket communication when sending and recieving. + */ private final Map> responseMap = new HashMap<>(); + + /** + * TODO: Remove + */ private static final ObjectMapper objectMapper = new ObjectMapper(); - CompletableFuture openedConnectionFuture; - // currently unused but we will inevitably need a unique ID assigned to each - // instance since server job names can be reused in some circumstances + /** + * TODO: Currently unused but we will inevitably need a unique ID assigned to + * each instance since server job names can be reused in some circumstances + */ private String uniqueId = SqlJob.getNewUniqueId("sqljob"); - // TODO: + /** + * Construct a new SqlJob instance. + */ public SqlJob() { - + this.options = new JDBCOptions(); } - public SqlJob(JDBCOptions _options) { - this.options = _options; + /** + * Construct a new SqlJob instance. + * + * @param options The JDBC options. + */ + public SqlJob(JDBCOptions options) { + this.options = options; } + /** + * Get a new unique ID with "id" as the prefix. + * + * @return The unique ID. + */ public static String getNewUniqueId() { return SqlJob.getNewUniqueId("id"); } + /** + * Get a new unique ID with a custom prefix. + * + * @param prefix The custom prefix. + * @return The unique ID. + */ public static String getNewUniqueId(String prefix) { return prefix + (++uniqueIdCounter); } - // LOGGING -> https://gist.github.com/luketn/4e7595cf39dab63fbcfdb62930fe8f4d + /** + * Get a WebSocketClient instance which can be used to connect to the specified + * DB2 server. + * + * @param db2Server The server details for the connection. + * @return A CompletableFuture that resolves to the WebSocketClient instance. + */ private CompletableFuture getChannel(DaemonServer db2Server) { - // return CompletableFuture.supplyAsync(() -> { try { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, new TrustManager[] { new NoAuthTrustManager() }, new SecureRandom()); @@ -125,6 +164,8 @@ private CompletableFuture getChannel(DaemonServer db2Server) { String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes(StandardCharsets.UTF_8)); httpHeaders.put("Authorization", "Basic " + encodedAuth); + // TODO: Improve logging -> + // https://gist.github.com/luketn/4e7595cf39dab63fbcfdb62930fe8f4d WebSocketClient wsc = new WebSocketClient(uri, new Draft_6455(), httpHeaders, 5000) { @Override public void onOpen(ServerHandshake handshakedata) { @@ -135,7 +176,7 @@ public void onOpen(ServerHandshake handshakedata) { @Override public void onMessage(String message) { if (isTracingChannelData) { - System.out.println("\n<< "+message); + System.out.println("\n<< " + message); } try { @@ -178,12 +219,17 @@ public void onError(Exception ex) { e.printStackTrace(); return CompletableFuture.completedFuture(null); } - // }); } + /** + * Send a message to the connected database server. + * + * @param content The message content to send. + * @return A CompletableFuture that resolves to the server's response. + */ public CompletableFuture send(String content) { if (this.isTracingChannelData) { - System.out.println("\n>> "+content); + System.out.println("\n>> " + content); } try { @@ -192,8 +238,8 @@ public CompletableFuture send(String content) { CompletableFuture future = new CompletableFuture<>(); responseMap.put(id, future); - synchronized(this.socket) { - this.socket.send(content+"\n"); + synchronized (this.socket) { + this.socket.send(content + "\n"); } String message = future.get(); responseMap.remove(id); @@ -204,16 +250,31 @@ public CompletableFuture send(String content) { } } + /** + * Get the current status of the job. + * + * @return The current status of the job. + */ public JobStatus getStatus() { return this.getRunningCount() > 0 ? JobStatus.Busy : this.status; } + /** + * Get the count of ongoing requests for the job. + * + * @return The number of ongoing requests. + */ public int getRunningCount() { // TODO: return 0; } - // TODO: + /** + * Connect to the specified DB2 server and initializes the SQL job. + * + * @param db2Server The server details for the connection. + * @return A CompletableFuture that resolves to the connection result. + */ public CompletableFuture connect(DaemonServer db2Server) throws Exception { this.status = JobStatus.Connecting; try { @@ -241,7 +302,7 @@ public CompletableFuture connect(DaemonServer db2Server) throw ObjectNode connectionObject = objectMapper.createObjectNode(); connectionObject.put("id", SqlJob.getNewUniqueId()); connectionObject.put("type", "connect"); - connectionObject.put("technique", "tcp");// TODO: DOVE does not work in cli mode + connectionObject.put("technique", "tcp"); connectionObject.put("application", "Java client"); if (props.length() > 0) { connectionObject.put("props", props); @@ -281,20 +342,48 @@ public CompletableFuture connect(DaemonServer db2Server) throw return CompletableFuture.completedFuture(connectResult); } + /** + * Create a Query object for the specified SQL statement. + * + * @param The type of data to be returned. + * @param sql The SQL query. + * @return A new Query instance. + */ public Query query(String sql) { - QueryOptions options = new QueryOptions(); - return this.query(sql, options); + return this.query(sql, new QueryOptions()); } + /** + * Create a Query object for the specified SQL statement. + * + * @param The type of data to be returned. + * @param sql The SQL query. + * @param opts The options for configuring the query. + * @return A new Query instance. + */ public Query query(String sql, QueryOptions opts) { return new Query(this, sql, opts); } + /** + * Execute an SQL command and returns the result. + * + * @param The type of data to be returned. + * @param sql The SQL command to execute. + * @return A CompletableFuture that resolves to the query result. + */ public CompletableFuture> execute(String sql) throws Exception { - QueryOptions options = new QueryOptions(); - return this.execute(sql, options); + return this.execute(sql, new QueryOptions()); } + /** + * Execute an SQL command and returns the result. + * + * @param The type of data to be returned. + * @param sql The SQL command to execute. + * @param opts The options for configuring the query. + * @return A CompletableFuture that resolves to the query result. + */ public CompletableFuture> execute(String sql, QueryOptions opts) throws Exception { Query query = query(sql, opts); CompletableFuture> future = query.execute(); @@ -313,6 +402,11 @@ public CompletableFuture> execute(String sql, QueryOptions op } } + /** + * Get the version information from the database server. + * + * @return A CompletableFuture that resolves to the version check result. + */ public CompletableFuture getVersion() throws Exception { ObjectNode verObj = objectMapper.createObjectNode(); verObj.put("id", SqlJob.getNewUniqueId()); @@ -345,10 +439,23 @@ public CompletableFuture getVersion() throws Exception { return CompletableFuture.completedFuture(version); } + /** + * Explains a SQL statement and returns the results. + * + * @param statement The SQL statement to explain. + * @return A CompletableFuture that resolves to the explain results. + */ public CompletableFuture> explain(String statement) throws Exception { return this.explain(statement, ExplainType.Run); } + /** + * Explains a SQL statement and returns the results. + * + * @param statement The SQL statement to explain. + * @param type The type of explain to perform (default is ExplainType.Run). + * @return A CompletableFuture that resolves to the explain results. + */ public CompletableFuture> explain(String statement, ExplainType type) throws Exception { ObjectNode explainRequest = objectMapper.createObjectNode(); explainRequest.put("id", SqlJob.getNewUniqueId()); @@ -383,10 +490,18 @@ public CompletableFuture> explain(String statement, ExplainTyp return CompletableFuture.completedFuture(explainResult); } + /** + * Get the file path of the trace file, if available. + */ public String getTraceFilePath() { - return this.traceFile; + return this.tracedest; } + /** + * Get trace data from the backend. + * + * @return A CompletableFuture that resolves to the trace data result. + */ public CompletableFuture getTraceData() throws Exception { ObjectNode tracedataReqObj = objectMapper.createObjectNode(); tracedataReqObj.put("id", SqlJob.getNewUniqueId()); @@ -419,7 +534,15 @@ public CompletableFuture getTraceData() throws Exception { return CompletableFuture.completedFuture(rpy); } - public CompletableFuture setTraceConfig(ServerTraceDest dest, ServerTraceLevel level) throws Exception { + /** + * Set the trace config on the backend. + * + * @param dest The server trace destination. + * @param level The server trace level. + * @return A CompletableFuture that resolves to the set config result. + */ + public CompletableFuture setTraceConfig(ServerTraceDest dest, ServerTraceLevel level) + throws Exception { ObjectNode reqObj = objectMapper.createObjectNode(); reqObj.put("id", SqlJob.getNewUniqueId()); reqObj.put("type", "setconfig"); @@ -452,43 +575,69 @@ public CompletableFuture setTraceConfig(ServerTraceDest dest, S } } - this.traceFile = (rpy.getTracedest().getValue() != null && rpy.getTracedest().getValue().charAt(0) == '/' + this.tracedest = (rpy.getTracedest().getValue() != null && rpy.getTracedest().getValue().charAt(0) == '/' ? rpy.getTracedest().getValue() : null); return CompletableFuture.completedFuture(rpy); } + /** + * Create a CL command query. + * + * @param cmd The CL command. + * @return A new Query instance for the command. + */ public Query clcommand(String cmd) { QueryOptions options = new QueryOptions(); options.setIsClCommand(true); return new Query(this, cmd, options); } + /** + * Check if the job is under commitment control based on the transaction + * isolation level. + * + * @return Whether the job is under commitment control. + */ public boolean underCommitControl() { - return this.options.getOption(Property.TRANSACTION_ISOLATION) != null - && this.options.getOption(Property.TRANSACTION_ISOLATION) != TransactionIsolation.NONE.getValue(); + return this.options.getOption(Option.TRANSACTION_ISOLATION) != null + && this.options.getOption(Option.TRANSACTION_ISOLATION) != TransactionIsolation.NONE.getValue(); } - // // TODO: - // public CompletableFuture getPendingTransactions() { - // return CompletableFuture.supplyAsync(() -> { - // QueryResult rows; - // try { - // rows = this.query(this.transactionCountQuery).execute(1).get(); - - // if (rows.isSuccess() && rows.getData() != null && rows.getData().size() == 1) - // { - // Object row = rows.getData().get(0); - // } - - // return 0; - // } catch (Exception e) { - // e.printStackTrace(); - // return 0; - // } - // }); - // } + /** + * Get the count of pending transactions. + * + * @return A CompletableFuture that resolves to the count of pending + * transactions. + */ + public CompletableFuture getPendingTransactions() { + // TODO: Fix implementation + // return CompletableFuture.supplyAsync(() -> { + // QueryResult rows; + // try { + // rows = this.query(this.transactionCountQuery).execute(1).get(); + + // if (rows.isSuccess() && rows.getData() != null && rows.getData().size() == 1) + // { + // Object row = rows.getData().get(0); + // } + + // return 0; + // } catch (Exception e) { + // e.printStackTrace(); + // return 0; + // } + // }); + return CompletableFuture.completedFuture(0); + } + /** + * Ends the current transaction by committing or rolling back. + * + * @param type The type of transaction ending (commit or rollback). + * @return A CompletableFuture that resolves to the result of the transaction + * operation. + */ public CompletableFuture> endTransaction(TransactionEndType type) throws Exception { String query; @@ -506,14 +655,27 @@ public CompletableFuture> endTransaction(TransactionEnd return this.query(query).execute(); } + /** + * Get the unique ID assigned to this SqlJob instance. + * TODO: Currently unused but we will inevitably need a unique ID assigned to + * each instance since server job names can be reused in some circumstances + * + * @return The unique ID assigned to this SqlJob instance + */ public String getUniqueId() { return this.uniqueId; } + /** + * Close the socket. + */ public void close() { this.dispose(); } + /** + * Close the socket and set the status to be ended. + */ public void dispose() { if (this.socket != null) { this.socket.close(); @@ -521,3 +683,24 @@ public void dispose() { this.status = JobStatus.Ended; } } + +/** + * Represents a manager that handles which X509 certificates may be used to + * authenticate the remote side of a secure socket. + */ +class NoAuthTrustManager implements X509TrustManager { + @Override + public void checkClientTrusted(final X509Certificate[] chain, final String authType) + throws CertificateException { + } + + @Override + public void checkServerTrusted(final X509Certificate[] chain, final String authType) + throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/mapepire_ibmi/Tls.java b/src/main/java/io/github/mapepire_ibmi/Tls.java index 990b067..b0ff777 100644 --- a/src/main/java/io/github/mapepire_ibmi/Tls.java +++ b/src/main/java/io/github/mapepire_ibmi/Tls.java @@ -1,5 +1,28 @@ package io.github.mapepire_ibmi; +import java.util.concurrent.CompletableFuture; + +import io.github.mapepire_ibmi.types.DaemonServer; + +/** + * Represents a TLS configuration. + */ public class Tls { - //TODO: + /** + * Get the SSL/TLS certificate from a specified DB2 server. + * + * This function establishes a secure connection to the server and retrieves the + * peer certificate information, which includes details about the server's + * SSL/TLS certificate. + * + * @param creds The server details for the connection. + * @return A CompletableFuture that resolves to the detailed peer certificate + * information. + */ + public CompletableFuture getCertificate(DaemonServer creds) { + // TODO: Add implementation + // TODO: Add @throws - ts docs -> An error if the connection fails or if there + // is an issue retrieving the certificate. + return CompletableFuture.completedFuture(null); + } } diff --git a/src/main/java/io/github/mapepire_ibmi/types/CLCommandResult.java b/src/main/java/io/github/mapepire_ibmi/types/CLCommandResult.java index 93eadd0..26e440b 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/CLCommandResult.java +++ b/src/main/java/io/github/mapepire_ibmi/types/CLCommandResult.java @@ -5,24 +5,53 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the result of a CL command execution. + */ public class CLCommandResult extends ServerResponse { + /** + * The log entries generated during the execution of the job. + */ @JsonProperty("joblog") private List joblog = new ArrayList(); + /** + * Construct a new CLCommandResult instance. + */ public CLCommandResult() { super(); } + /** + * Construct a new CLCommandResult instance. + * + * @param id The unique identifier for the request. + * @param success Whether the request was successful. + * @param error The error message, if any. + * @param sqlRc The SQL return code. + * @param sqlState The SQL state code. + * @param joblog The log entries generated during the execution of the job. + */ public CLCommandResult(String id, boolean success, String error, int sqlRc, String sqlState, List joblog) { super(id, success, error, sqlRc, sqlState); this.joblog = joblog; } + /** + * Get the log entries generated during the execution of the job. + * + * @return The log entries generated during the execution of the job. + */ public List getJoblog() { return joblog; } + /** + * Set the log entries generated during the execution of the job. + * + * @param joblog The log entries generated during the execution of the job. + */ public void setJoblog(List joblog) { this.joblog = joblog; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/ColumnMetadata.java b/src/main/java/io/github/mapepire_ibmi/types/ColumnMetadata.java index 4bd559c..210c3ce 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/ColumnMetadata.java +++ b/src/main/java/io/github/mapepire_ibmi/types/ColumnMetadata.java @@ -2,23 +2,49 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the metadata for a single column in a query. + */ public class ColumnMetadata { + /** + * The display size of the column. + */ @JsonProperty("display_size") private int displaySize; + /** + * The label of the column. + */ @JsonProperty("label") private String label; + /** + * The name of the column. + */ @JsonProperty("name") private String name; + /** + * The type of the column. + */ @JsonProperty("type") private String type; + /** + * Construct a new ColumnMetadata instance. + */ public ColumnMetadata() { } + /** + * Construct a new ColumnMetadata instance. + * + * @param displaySize The display size of the column. + * @param label The label of the column. + * @param name The name of the column. + * @param type The type of the column. + */ public ColumnMetadata(int displaySize, String label, String name, String type) { this.displaySize = displaySize; this.label = label; @@ -26,34 +52,74 @@ public ColumnMetadata(int displaySize, String label, String name, String type) { this.type = type; } + /** + * Get the display size of the column. + * + * @return The display size of the column. + */ public int getDisplaySize() { return displaySize; } + /** + * Set the display size of the column. + * + * @param displaySize The display size of the column. + */ public void setDisplaySize(int displaySize) { this.displaySize = displaySize; } + /** + * Get the label of the column. + * + * @return The label of the column. + */ public String getLabel() { return label; } + /** + * Set the label of the column. + * + * @param label The label of the column. + */ public void setLabel(String label) { this.label = label; } + /** + * Get the name of the column. + * + * @return The name of the column. + */ public String getName() { return name; } + /** + * Set the name of the column. + * + * @param name The name of the column. + */ public void setName(String name) { this.name = name; } + /** + * Get the type of the column. + * + * @return The type of the column. + */ public String getType() { return type; } + /** + * Set the type of the column. + * + * @param type The type of the column. + */ public void setType(String type) { this.type = type; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/ConnectionResult.java b/src/main/java/io/github/mapepire_ibmi/types/ConnectionResult.java index 76b30b8..65f6a79 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/ConnectionResult.java +++ b/src/main/java/io/github/mapepire_ibmi/types/ConnectionResult.java @@ -2,23 +2,49 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the result of a connection request. + */ public class ConnectionResult extends ServerResponse { + /** + * The unique job identifier for the connection. + */ @JsonProperty("job") private String job; + /** + * Construct a new ConnectionResult instance. + */ public ConnectionResult() { super(); } + /** + * Construct a new ConnectionResult instance. + * @param id The unique identifier for the request. + * @param success Whether the request was successful. + * @param error The error message, if any. + * @param sqlRc The SQL return code. + * @param sqlState The SQL state code. + * @param job The unique job identifier for the connection. + */ public ConnectionResult(String id, boolean success, String error, int sqlRc, String sqlState, String job) { super(id, success, error, sqlRc, sqlState); this.job = job; } + /** + * Get the unique job identifier for the connection. + * @return The unique job identifier for the connection. + */ public String getJob() { return job; } + /** + * Set the unique job identifier for the connection. + * @param job The unique job identifier for the connection. + */ public void setJob(String job) { this.job = job; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/DaemonServer.java b/src/main/java/io/github/mapepire_ibmi/types/DaemonServer.java index d99cc04..37e3193 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/DaemonServer.java +++ b/src/main/java/io/github/mapepire_ibmi/types/DaemonServer.java @@ -2,29 +2,63 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents a DB2 server daemon with connection details. + */ public class DaemonServer { + /** + * The hostname or IP address of the server. + */ @JsonProperty("host") private String host; + /** + * The port number to connect to. + */ @JsonProperty("port") private int port; + /** + * The username for authentication. + */ @JsonProperty("user") private String user; + /** + * The password for authentication. + */ @JsonProperty("password") private String password; + /** + * Whether to ignore unauthorized certificates. + */ @JsonProperty("ignoreUnauthorized") private boolean ignoreUnauthorized; + /** + * The certificate authority (CA) for validating the server's certificate. + */ @JsonProperty("ca") private String ca; + /** + * Construct a new DaemonServer instance. + */ public DaemonServer() { } + /** + * Construct a new DaemonServer instance. + * @param host The hostname or IP address of the server. + * @param port The port number to connect to. + * @param user The username for authentication. + * @param password The password for authentication. + * @param ignoreUnauthorized Whether to ignore unauthorized certificates. + * @param ca The certificate authority (CA) for validating the + * server's certificate. + */ public DaemonServer(String host, int port, String user, String password, boolean ignoreUnauthorized, String ca) { this.host = host; @@ -35,50 +69,100 @@ public DaemonServer(String host, int port, String user, String password, boolean this.ca = ca; } + /** + * Get the hostname or IP address of the server. + * @return The hostname or IP address of the server. + */ public String getHost() { return host; } + /** + * Set the hostname or IP address of the server. + * @param host The hostname or IP address of the server. + */ public void setHost(String host) { this.host = host; } + /** + * Get port number to connect to. + * @return The port number to connect to. + */ public int getPort() { return port; } + /** + * Set port number to connect to. + * @param port The port number to connect to. + */ public void setPort(int port) { this.port = port; } + /** + * Get username for authentication. + * @return The username for authentication. + */ public String getUser() { return user; } + /** + * Set username for authentication. + * @param user The username for authentication. + */ public void setUser(String user) { this.user = user; } + /** + * Get password for authentication. + * @return The password for authentication. + */ public String getPassword() { return password; } + /** + * Set password for authentication. + * @param password The password for authentication. + */ public void setPassword(String password) { this.password = password; } + /** + * Get whether to ignore unauthorized certificates. + * @return Whether to ignore unauthorized certificates. + */ public boolean getIgnoreUnauthorized() { return ignoreUnauthorized; } + /** + * Set whether to ignore unauthorized certificates. + * @param ignoreUnauthorized Whether to ignore unauthorized certificates. + */ public void setIgnoreUnauthorized(boolean ignoreUnauthorized) { this.ignoreUnauthorized = ignoreUnauthorized; } + /** + * Get the certificate authority (CA) for validating the server's certificate. + * @return The certificate authority (CA) for validating the server's + * certificate. + */ public String getCa() { return ca; } + /** + * Set the certificate authority (CA) for validating the server's certificate. + * @param ca The certificate authority (CA) for validating the server's + * certificate. + */ public void setCa(String ca) { this.ca = ca; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/ExplainResults.java b/src/main/java/io/github/mapepire_ibmi/types/ExplainResults.java index 746eaab..8f03d09 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/ExplainResults.java +++ b/src/main/java/io/github/mapepire_ibmi/types/ExplainResults.java @@ -4,17 +4,44 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the results of an explain request. + */ public class ExplainResults extends QueryResult { + /** + * The metadata about the query execution. + */ @JsonProperty("vemetadata") private QueryMetadata vemetadata; + /** + * The data returned from the explain request. + */ @JsonProperty("vedata") private Object vedata; + /** + * Construct a new ExplainResults instance. + */ public ExplainResults() { super(); } + /** + * Construct a new ExplainResults instance. + * @param id The unique identifier for the request. + * @param success Whether the request was successful. + * @param error The error message, if any. + * @param sqlRc The SQL return code. + * @param sqlState The SQL state code. + * @param metadata The metadata about the query results. + * @param isDone Whether the query execution is complete. + * @param hasResults Whether the results were returned. + * @param updateCount The number of rows affected by the query. + * @param data The data returned from the query. + * @param vemetadata The metadata about the query execution. + * @param vedata The data returned from the explain request. + */ public ExplainResults(String id, boolean success, String error, int sqlRc, String sqlState, QueryMetadata metadata, boolean isDone, boolean hasResults, int updateCount, List data, QueryMetadata vemetadata, Object vedata) { @@ -23,18 +50,34 @@ public ExplainResults(String id, boolean success, String error, int sqlRc, Strin this.vedata = vedata; } + /** + * Get the metadata about the query execution. + * @return The metadata about the query execution. + */ public QueryMetadata getVemetadata() { return vemetadata; } + /** + * Set the metadata about the query execution. + * @param vemetadata The metadata about the query execution. + */ public void setVemetadata(QueryMetadata vemetadata) { this.vemetadata = vemetadata; } + /** + * Get the data returned from the explain request. + * @return The data returned from the explain request. + */ public Object getVedata() { return vedata; } + /** + * Set the data returned from the explain request. + * @param vedata The data returned from the explain request. + */ public void setVedata(Object vedata) { this.vedata = vedata; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/ExplainType.java b/src/main/java/io/github/mapepire_ibmi/types/ExplainType.java index af8db02..0dc60a2 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/ExplainType.java +++ b/src/main/java/io/github/mapepire_ibmi/types/ExplainType.java @@ -1,6 +1,16 @@ package io.github.mapepire_ibmi.types; +/** + * Enum representing the possible types of explain requests. + */ public enum ExplainType { + /** + * Run the SQL statement for explanation. + */ Run, + + /** + * Do not run the SQL statement for explanation. + */ DoNotRun } diff --git a/src/main/java/io/github/mapepire_ibmi/types/GetTraceDataResult.java b/src/main/java/io/github/mapepire_ibmi/types/GetTraceDataResult.java index 4a3a562..8598d74 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/GetTraceDataResult.java +++ b/src/main/java/io/github/mapepire_ibmi/types/GetTraceDataResult.java @@ -2,24 +2,50 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the result of a trace data request. + */ public class GetTraceDataResult extends ServerResponse { + /** + * The retrieved trace data. + */ @JsonProperty("tracedata") private String tracedata; + /** + * Construct a new GetTraceDataResult instance. + */ public GetTraceDataResult() { super(); } + /** + * Construct a new GetTraceDataResult instance. + * @param id The unique identifier for the request. + * @param success Whether the request was successful. + * @param error The error message, if any. + * @param sqlRc The SQL return code. + * @param sqlState The SQL state code. + * @param tracedata The retrieved trace data. + */ public GetTraceDataResult(String id, boolean success, String error, int sqlRc, String sqlState, - String _tracedata) { + String tracedata) { super(id, success, error, sqlRc, sqlState); - this.tracedata = _tracedata; + this.tracedata = tracedata; } + /** + * Get the retrieved trace data. + * @return The retrieved trace data. + */ public String getTracedata() { return tracedata; } + /** + * Set the retrieved trace data. + * @param tracedata The retrieved trace data. + */ public void setTracedata(String tracedata) { this.tracedata = tracedata; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/JDBCOptions.java b/src/main/java/io/github/mapepire_ibmi/types/JDBCOptions.java index 29f78bc..7e219b3 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/JDBCOptions.java +++ b/src/main/java/io/github/mapepire_ibmi/types/JDBCOptions.java @@ -15,15 +15,15 @@ import io.github.mapepire_ibmi.types.jdbcOptions.DecfloatRoundingMode; import io.github.mapepire_ibmi.types.jdbcOptions.DecimalSeparator; import io.github.mapepire_ibmi.types.jdbcOptions.Driver; -import io.github.mapepire_ibmi.types.jdbcOptions.Error; +import io.github.mapepire_ibmi.types.jdbcOptions.Errors; import io.github.mapepire_ibmi.types.jdbcOptions.MaximumPrecision; import io.github.mapepire_ibmi.types.jdbcOptions.MetadataSource; import io.github.mapepire_ibmi.types.jdbcOptions.MinimumDivideScale; import io.github.mapepire_ibmi.types.jdbcOptions.Naming; +import io.github.mapepire_ibmi.types.jdbcOptions.Option; import io.github.mapepire_ibmi.types.jdbcOptions.PackageCcsid; import io.github.mapepire_ibmi.types.jdbcOptions.PackageCriteria; import io.github.mapepire_ibmi.types.jdbcOptions.PackageError; -import io.github.mapepire_ibmi.types.jdbcOptions.Property; import io.github.mapepire_ibmi.types.jdbcOptions.QueryOptimizeGoal; import io.github.mapepire_ibmi.types.jdbcOptions.QueryTimeoutMechanism; import io.github.mapepire_ibmi.types.jdbcOptions.Remarks; @@ -37,318 +37,637 @@ import io.github.mapepire_ibmi.types.jdbcOptions.TranslateHex; import io.github.mapepire_ibmi.types.jdbcOptions.XALooselyCoupledSupport; +/** + * Represents the JDBC options. + */ public class JDBCOptions { + /** + * Map of JDBC options. + */ private Map options = new HashMap<>(); + /** + * Construct a new JDBCOptions instance. + */ public JDBCOptions() { } + /** + * Get the map of JDBC options. + * @return The map of JDBC options. + */ public Map getOptions() { return this.options; } - public Object getOption(Property property) { - return this.options.get(property.getValue()); + /** + * Get the value of a JDBC option. + * @param option The JDBC option. + * @return The value of the JDBC option. + */ + public Object getOption(Option option) { + return this.options.get(option.getValue()); } - private void setOption(Property property, Object value) { - this.options.put(property.getValue(), value); + /** + * Set the value of a JDBC option. + * @param option The JDBC option. + * @param value The value of the JDBC option. + */ + private void setOption(Option option, Object value) { + this.options.put(option.getValue(), value); } + /** + * Set the "naming" JDBC option. + * @param naming The value to set. + */ public void setNaming(Naming naming) { - this.setOption(Property.NAMING, naming.getValue()); + this.setOption(Option.NAMING, naming.getValue()); } + /** + * Set the "date format" JDBC option. + * @param dateFormat The value to set. + */ public void setDateFormat(DateFormat dateFormat) { - this.setOption(Property.DATE_FORMAT, dateFormat.getValue()); + this.setOption(Option.DATE_FORMAT, dateFormat.getValue()); } + /** + * Set the "date separator" JDBC option. + * @param dateSeparator The value to set. + */ public void setDateSeparator(DateSeparator dateSeparator) { - this.setOption(Property.DATE_SEPARATOR, dateSeparator.getValue()); + this.setOption(Option.DATE_SEPARATOR, dateSeparator.getValue()); } + /** + * Set the "decimal separator" JDBC option. + * @param decimalSeparator The value to set. + */ public void setDecimalSeparator(DecimalSeparator decimalSeparator) { - this.setOption(Property.DECIMAL_SEPARATOR, decimalSeparator.getValue()); + this.setOption(Option.DECIMAL_SEPARATOR, decimalSeparator.getValue()); } + /** + * Set the "time format" JDBC option. + * @param timeFormat The value to set. + */ public void setTimeFormat(TimeFormat timeFormat) { - this.setOption(Property.TIME_FORMAT, timeFormat.getValue()); + this.setOption(Option.TIME_FORMAT, timeFormat.getValue()); } + /** + * Set the "time separator" JDBC option. + * @param timeSeparator The value to set. + */ public void setTimeSeparator(TimeSeparator timeSeparator) { - this.setOption(Property.TIME_SEPARATOR, timeSeparator.getValue()); + this.setOption(Option.TIME_SEPARATOR, timeSeparator.getValue()); } + /** + * Set the "full open" JDBC option. + * @param fullOpen The value to set. + */ public void setFullOpen(boolean fullOpen) { - this.setOption(Property.FULL_OPEN, fullOpen); + this.setOption(Option.FULL_OPEN, fullOpen); } + /** + * Set the "access" JDBC option. + * @param access The value to set. + */ public void setAccess(Access access) { - this.setOption(Property.ACCESS, access.getValue()); + this.setOption(Option.ACCESS, access.getValue()); } + /** + * Set the "autocommit exception" JDBC option. + * @param autocommitException The value to set. + */ public void setAutocommitException(String autocommitException) { - this.setOption(Property.AUTOCOMMIT_EXCEPTION, autocommitException); + this.setOption(Option.AUTOCOMMIT_EXCEPTION, autocommitException); } + /** + * Set the "bidi string type" JDBC option. + * @param bidiStringType The value to set. + */ public void setBidiStringType(BidiStringType bidiStringType) { - this.setOption(Property.BIDI_STRING_TYPE, bidiStringType.getValue()); + this.setOption(Option.BIDI_STRING_TYPE, bidiStringType.getValue()); } + /** + * Set the "bidi implicit reordering" JDBC option. + * @param bidiImplicitReordering The value to set. + */ public void setBidiImplicitReordering(boolean bidiImplicitReordering) { - this.setOption(Property.BIDI_IMPLICIT_REORDERING, bidiImplicitReordering); + this.setOption(Option.BIDI_IMPLICIT_REORDERING, bidiImplicitReordering); } + /** + * Set the "bidi numeric ordering" JDBC option. + * @param bidiNumericOrdering The value to set. + */ public void setBidiNumericOrdering(boolean bidiNumericOrdering) { - this.setOption(Property.BIDI_NUMERIC_ORDERING, bidiNumericOrdering); + this.setOption(Option.BIDI_NUMERIC_ORDERING, bidiNumericOrdering); } + /** + * Set the "data truncation" JDBC option. + * @param dataTruncation The value to set. + */ public void setDataTruncation(boolean dataTruncation) { - this.setOption(Property.DATA_TRUNCATION, dataTruncation); + this.setOption(Option.DATA_TRUNCATION, dataTruncation); } + /** + * Set the "driver" JDBC option. + * @param driver The value to set. + */ public void setDriver(Driver driver) { - this.setOption(Property.DRIVER, driver.getValue()); + this.setOption(Option.DRIVER, driver.getValue()); } - public void setErrors(Error errors) { - this.setOption(Property.ERRORS, errors.getValue()); + /** + * Set the "errors" JDBC option. + * @param errors The value to set. + */ + public void setErrors(Errors errors) { + this.setOption(Option.ERRORS, errors.getValue()); } + /** + * Set the "extended metadata" JDBC option. + * @param extendedMetadata The value to set. + */ public void setExtendedMetadata(boolean extendedMetadata) { - this.setOption(Property.EXTENDED_METADATA, extendedMetadata); + this.setOption(Option.EXTENDED_METADATA, extendedMetadata); } + /** + * Set the "hold input locators" JDBC option. + * @param holdInputLocators The value to set. + */ public void setHoldInputLocators(boolean holdInputLocators) { - this.setOption(Property.HOLD_INPUT_LOCATORS, holdInputLocators); + this.setOption(Option.HOLD_INPUT_LOCATORS, holdInputLocators); } + /** + * Set the "hold statements" JDBC option. + * @param holdStatements The value to set. + */ public void setHoldStatements(boolean holdStatements) { - this.setOption(Property.HOLD_STATEMENTS, holdStatements); + this.setOption(Option.HOLD_STATEMENTS, holdStatements); } + /** + * Set the "ignore warnings" JDBC option. + * @param ignoreWarnings The value to set. + */ public void setIgnoreWarnings(String ignoreWarnings) { - this.setOption(Property.IGNORE_WARNINGS, ignoreWarnings); + this.setOption(Option.IGNORE_WARNINGS, ignoreWarnings); } + /** + * Set the "keep alive" JDBC option. + * @param keepAlive The value to set. + */ public void setKeepAlive(boolean keepAlive) { - this.setOption(Property.KEEP_ALIVE, keepAlive); + this.setOption(Option.KEEP_ALIVE, keepAlive); } + /** + * Set the "key ring name" JDBC option. + * @param keyRingName The value to set. + */ public void setKeyRingName(String keyRingName) { - this.setOption(Property.KEY_RING_NAME, keyRingName); + this.setOption(Option.KEY_RING_NAME, keyRingName); } + /** + * Set the "key ring password" JDBC option. + * @param keyRingPassword The value to set. + */ public void setKeyRingPassword(String keyRingPassword) { - this.setOption(Property.KEY_RING_PASSWORD, keyRingPassword); + this.setOption(Option.KEY_RING_PASSWORD, keyRingPassword); } + /** + * Set the "metadata source" JDBC option. + * @param metadataSource The value to set. + */ public void setMetadataSource(MetadataSource metadataSource) { - this.setOption(Property.METADATA_SOURCE, metadataSource.getValue()); + this.setOption(Option.METADATA_SOURCE, metadataSource.getValue()); } + /** + * Set the "proxy server" JDBC option. + * @param proxyServer The value to set. + */ public void setProxyServer(String proxyServer) { - this.setOption(Property.PROXY_SERVER, proxyServer); + this.setOption(Option.PROXY_SERVER, proxyServer); } + /** + * Set the "remarks" JDBC option. + * @param remarks The value to set. + */ public void setRemarks(Remarks remarks) { - this.setOption(Property.REMARKS, remarks.getValue()); + this.setOption(Option.REMARKS, remarks.getValue()); } + /** + * Set the "secondary URL" JDBC option. + * @param secondaryUrl The value to set. + */ public void setSecondaryUrl(boolean secondaryUrl) { - this.setOption(Property.SECONDARY_URL, secondaryUrl); + this.setOption(Option.SECONDARY_URL, secondaryUrl); } + /** + * Set the "secure" JDBC option. + * @param secure The value to set. + */ public void setSecure(boolean secure) { - this.setOption(Property.SECURE, secure); + this.setOption(Option.SECURE, secure); } + /** + * Set the "server trace" JDBC option. + * @param serverTrace The value to set. + */ public void setServerTrace(ServerTrace serverTrace) { - this.setOption(Property.SERVER_TRACE, serverTrace.getValue()); + this.setOption(Option.SERVER_TRACE, serverTrace.getValue()); } + /** + * Set the "thread used" JDBC option. + * @param threadUsed The value to set. + */ public void setThreadUsed(boolean threadUsed) { - this.setOption(Property.THREAD_USED, threadUsed); + this.setOption(Option.THREAD_USED, threadUsed); } + /** + * Set the "toolbox trace" JDBC option. + * @param toolboxTrace The value to set. + */ public void setToolboxTrace(ToolboxTrace toolboxTrace) { - this.setOption(Property.TOOLBOX_TRACE, toolboxTrace.getValue()); + this.setOption(Option.TOOLBOX_TRACE, toolboxTrace.getValue()); } + /** + * Set the "trace" JDBC option. + * @param trace The value to set. + */ public void setTrace(boolean trace) { - this.setOption(Property.TRACE, trace); + this.setOption(Option.TRACE, trace); } + /** + * Set the "translate binary" JDBC option. + * @param translateBinary The value to set. + */ public void setTranslateBinary(boolean translateBinary) { - this.setOption(Property.TRANSLATE_BINARY, translateBinary); + this.setOption(Option.TRANSLATE_BINARY, translateBinary); } + /** + * Set the "translate boolean" JDBC option. + * @param translateBoolean The value to set. + */ public void setTranslateBoolean(boolean translateBoolean) { - this.setOption(Property.TRANSLATE_BOOLEAN, translateBoolean); + this.setOption(Option.TRANSLATE_BOOLEAN, translateBoolean); } + /** + * Set the "libraries" JDBC option. + * @param libraries The value to set. + */ public void setLibraries(List libraries) { - this.setOption(Property.LIBRARIES, libraries); + this.setOption(Option.LIBRARIES, libraries); } + /** + * Set the "auto commit" JDBC option. + * @param autoCommit The value to set. + */ public void setAutoCommit(boolean autoCommit) { - this.setOption(Property.AUTO_COMMIT, autoCommit); + this.setOption(Option.AUTO_COMMIT, autoCommit); } + /** + * Set the "concurrent access resolution" JDBC option. + * @param concurrentAccessResolution The value to set. + */ public void setConcurrentAccessResolution(ConcurrentAccessResolution concurrentAccessResolution) { - this.setOption(Property.CONCURRENT_ACCESS_RESOLUTION, concurrentAccessResolution.getValue()); + this.setOption(Option.CONCURRENT_ACCESS_RESOLUTION, concurrentAccessResolution.getValue()); } + /** + * Set the "cursor hold" JDBC option. + * @param cursorHold The value to set. + */ public void setCursorHold(boolean cursorHold) { - this.setOption(Property.CURSOR_HOLD, cursorHold); + this.setOption(Option.CURSOR_HOLD, cursorHold); } + /** + * Set the "cursor sensitivity" JDBC option. + * @param cursorSensitivity The value to set. + */ public void setCursorSensitivity(CursorSensitivity cursorSensitivity) { - this.setOption(Property.CURSOR_SENSITIVITY, cursorSensitivity.getValue()); + this.setOption(Option.CURSOR_SENSITIVITY, cursorSensitivity.getValue()); } + /** + * Set the "database name" JDBC option. + * @param databaseName The value to set. + */ public void setDatabaseName(String databaseName) { - this.setOption(Property.DATABASE_NAME, databaseName); + this.setOption(Option.DATABASE_NAME, databaseName); } + /** + * Set the "decfloat rounding mode" JDBC option. + * @param decfloatRoundingMode The value to set. + */ public void setDecfloatRoundingMode(DecfloatRoundingMode decfloatRoundingMode) { - this.setOption(Property.DECFLOAT_ROUNDING_MODE, decfloatRoundingMode.getValue()); + this.setOption(Option.DECFLOAT_ROUNDING_MODE, decfloatRoundingMode.getValue()); } + /** + * Set the "maximum precision" JDBC option. + * @param maximumPrecision The value to set. + */ public void setMaximumPrecision(MaximumPrecision maximumPrecision) { - this.setOption(Property.MAXIMUM_PRECISION, maximumPrecision.getValue()); + this.setOption(Option.MAXIMUM_PRECISION, maximumPrecision.getValue()); } + /** + * Set the "maximum scale" JDBC option. + * @param maximumScale The value to set. + */ public void setMaximumScale(String maximumScale) { - this.setOption(Property.MAXIMUM_SCALE, maximumScale); + this.setOption(Option.MAXIMUM_SCALE, maximumScale); } + /** + * Set the "minimum divide scale" JDBC option. + * @param minimumDivideScale The value to set. + */ public void setMinimumDivideScale(MinimumDivideScale minimumDivideScale) { - this.setOption(Property.MINIMUM_DIVIDE_SCALE, minimumDivideScale.getValue()); + this.setOption(Option.MINIMUM_DIVIDE_SCALE, minimumDivideScale.getValue()); } + /** + * Set the "package ccsid" JDBC option. + * @param packageCcsid The value to set. + */ public void setPackageCcsid(PackageCcsid packageCcsid) { - this.setOption(Property.PACKAGE_CCID, packageCcsid.getValue()); + this.setOption(Option.PACKAGE_CCSID, packageCcsid.getValue()); } + /** + * Set the "transaction isolation" JDBC option. + * @param transactionIsolation The value to set. + */ public void setTransactionIsolation(TransactionIsolation transactionIsolation) { - this.setOption(Property.TRANSACTION_ISOLATION, transactionIsolation.getValue()); + this.setOption(Option.TRANSACTION_ISOLATION, transactionIsolation.getValue()); } + /** + * Set the "translate hex" JDBC option. + * @param translateHex The value to set. + */ public void setTranslateHex(TranslateHex translateHex) { - this.setOption(Property.TRANSLATE_HEX, translateHex.getValue()); + this.setOption(Option.TRANSLATE_HEX, translateHex.getValue()); } + /** + * Set the "true autocommit" JDBC option. + * @param trueAutocommit The value to set. + */ public void setTrueAutocommit(boolean trueAutocommit) { - this.setOption(Property.TRUE_AUTOCOMMIT, trueAutocommit); + this.setOption(Option.TRUE_AUTOCOMMIT, trueAutocommit); } + /** + * Set the "xa loosely coupled support" JDBC option. + * @param xaLooselyCoupledSupport The value to set. + */ public void setXALooselyCoupledSupport(XALooselyCoupledSupport xaLooselyCoupledSupport) { - this.setOption(Property.XA_LOOSELY_COUPLED_SUPPORT, xaLooselyCoupledSupport.getValue()); + this.setOption(Option.XA_LOOSELY_COUPLED_SUPPORT, xaLooselyCoupledSupport.getValue()); } + /** + * Set the "big decimal" JDBC option. + * @param bigDecimal The value to set. + */ public void setBigDecimal(boolean bigDecimal) { - this.setOption(Property.BIG_DECIMAL, bigDecimal); + this.setOption(Option.BIG_DECIMAL, bigDecimal); } + /** + * Set the "block criteria" JDBC option. + * @param blockCriteria The value to set. + */ public void setBlockCriteria(BlockCriteria blockCriteria) { - this.setOption(Property.BLOCK_CRITERIA, blockCriteria.getValue()); + this.setOption(Option.BLOCK_CRITERIA, blockCriteria.getValue()); } + /** + * Set the "block size" JDBC option. + * @param blockSize The value to set. + */ public void setBlockSize(BlockSize blockSize) { - this.setOption(Property.BLOCK_SIZE, blockSize.getValue()); + this.setOption(Option.BLOCK_SIZE, blockSize.getValue()); } + /** + * Set the "data compression" JDBC option. + * @param dataCompression The value to set. + */ public void setDataCompression(boolean dataCompression) { - this.setOption(Property.DATA_COMPRESSION, dataCompression); + this.setOption(Option.DATA_COMPRESSION, dataCompression); } + /** + * Set the "extended dynamic" JDBC option. + * @param extendedDynamic The value to set. + */ public void setExtendedDynamic(boolean extendedDynamic) { - this.setOption(Property.EXTENDED_DYNAMIC, extendedDynamic); + this.setOption(Option.EXTENDED_DYNAMIC, extendedDynamic); } + /** + * Set the "lazy close" JDBC option. + * @param lazyClose The value to set. + */ public void setLazyClose(boolean lazyClose) { - this.setOption(Property.LAZY_CLOSE, lazyClose); + this.setOption(Option.LAZY_CLOSE, lazyClose); } + /** + * Set the "lob threshold" JDBC option. + * @param lobThreshold The value to set. + */ public void setLobThreshold(String lobThreshold) { - this.setOption(Property.LOB_THRESHOLD, lobThreshold); + this.setOption(Option.LOB_THRESHOLD, lobThreshold); } + /** + * Set the "maximum blocked input rows" JDBC option. + * @param maximumBlockedInputRows The value to set. + */ public void setMaximumBlockedInputRows(String maximumBlockedInputRows) { - this.setOption(Property.MAXIMUM_BLOCKED_INPUT_ROWS, maximumBlockedInputRows); + this.setOption(Option.MAXIMUM_BLOCKED_INPUT_ROWS, maximumBlockedInputRows); } + /** + * Set the "package" JDBC option. + * @param pkg The value to set. + */ public void setPackage(String pkg) { - this.setOption(Property.PACKAGE, pkg); + this.setOption(Option.PACKAGE, pkg); } + /** + * Set the "package add" JDBC option. + * @param packageAdd The value to set. + */ public void setPackageAdd(boolean packageAdd) { - this.setOption(Property.PACKAGE_ADD, packageAdd); + this.setOption(Option.PACKAGE_ADD, packageAdd); } + /** + * Set the "package cache" JDBC option. + * @param packageCache The value to set. + */ public void setPackageCache(boolean packageCache) { - this.setOption(Property.PACKAGE_CACHE, packageCache); + this.setOption(Option.PACKAGE_CACHE, packageCache); } + /** + * Set the "package criteria" JDBC option. + * @param packageCriteria The value to set. + */ public void setPackageCriteria(PackageCriteria packageCriteria) { - this.setOption(Property.PACKAGE_CRITERIA, packageCriteria.getValue()); + this.setOption(Option.PACKAGE_CRITERIA, packageCriteria.getValue()); } + /** + * Set the "package error" JDBC option. + * @param packageError The value to set. + */ public void setPackageError(PackageError packageError) { - this.setOption(Property.PACKAGE_ERROR, packageError.getValue()); + this.setOption(Option.PACKAGE_ERROR, packageError.getValue()); } + /** + * Set the "package library" JDBC option. + * @param packageLibrary The value to set. + */ public void setPackageLibrary(String packageLibrary) { - this.setOption(Property.PACKAGE_LIBRARY, packageLibrary); + this.setOption(Option.PACKAGE_LIBRARY, packageLibrary); } + /** + * Set the "prefetch" JDBC option. + * @param prefetch The value to set. + */ public void setPrefetch(boolean prefetch) { - this.setOption(Property.PREFETCH, prefetch); + this.setOption(Option.PREFETCH, prefetch); } + /** + * Set the "qaqqinilib" JDBC option. + * @param qaqqinilib The value to set. + */ public void setQaqqinilib(String qaqqinilib) { - this.setOption(Property.QAQQINILIB, qaqqinilib); + this.setOption(Option.QAQQINILIB, qaqqinilib); } + /** + * Set the "query optimize goal" JDBC option. + * @param queryOptimizeGoal The value to set. + */ public void setQueryOptimizeGoal(QueryOptimizeGoal queryOptimizeGoal) { - this.setOption(Property.QUERY_OPTIMIZE_GOAL, queryOptimizeGoal.getValue()); + this.setOption(Option.QUERY_OPTIMIZE_GOAL, queryOptimizeGoal.getValue()); } + /** + * Set the "query timeout mechanism" JDBC option. + * @param queryTimeoutMechanism The value to set. + */ public void setQueryTimeoutMechanism(QueryTimeoutMechanism queryTimeoutMechanism) { - this.setOption(Property.QUERY_TIMEOUT_MECHANISM, queryTimeoutMechanism.getValue()); + this.setOption(Option.QUERY_TIMEOUT_MECHANISM, queryTimeoutMechanism.getValue()); } + /** + * Set the "query storage limit" JDBC option. + * @param queryStorageLimit The value to set. + */ public void setQueryStorageLimit(String queryStorageLimit) { - this.setOption(Property.QUERY_STORAGE_LIMIT, queryStorageLimit); + this.setOption(Option.QUERY_STORAGE_LIMIT, queryStorageLimit); } + /** + * Set the "receive buffer size" JDBC option. + * @param receiveBufferSize The value to set. + */ public void receiveBufferSize(String receiveBufferSize) { - this.setOption(Property.RECEIVE_BUFFER_SIZE, receiveBufferSize); + this.setOption(Option.RECEIVE_BUFFER_SIZE, receiveBufferSize); } + /** + * Set the "send buffer size" JDBC option. + * @param sendBufferSize The value to set. + */ public void sendBufferSize(String sendBufferSize) { - this.setOption(Property.SEND_BUFFER_SIZE, sendBufferSize); + this.setOption(Option.SEND_BUFFER_SIZE, sendBufferSize); } - public void vairiableFieldCompression(boolean vairiableFieldCompression) { - this.setOption(Property.VARIABLE_FIELD_COMPRESSION, vairiableFieldCompression); + /** + * Set the "variable field compression" JDBC option. + * @param variableFieldCompression The value to set. + */ + public void variableFieldCompression(boolean variableFieldCompression) { + this.setOption(Option.VARIABLE_FIELD_COMPRESSION, variableFieldCompression); } + /** + * Set the "sort" JDBC option. + * @param sort The value to set. + */ public void setSort(Sort sort) { - this.setOption(Property.SORT, sort); + this.setOption(Option.SORT, sort); } + /** + * Set the "sort language" JDBC option. + * @param sortLanguage The value to set. + */ public void sortLanguage(String sortLanguage) { - this.setOption(Property.SORT_LANGUAGE, sortLanguage); + this.setOption(Option.SORT_LANGUAGE, sortLanguage); } + /** + * Set the "sort table" JDBC option. + * @param sortTable The value to set. + */ public void sortTable(String sortTable) { - this.setOption(Property.SORT_TABLE, sortTable); + this.setOption(Option.SORT_TABLE, sortTable); } + /** + * Set the "sort weight" JDBC option. + * @param sortWeight The value to set. + */ public void setWeight(SortWeight sortWeight) { - this.setOption(Property.SORT_WEIGHT, sortWeight); + this.setOption(Option.SORT_WEIGHT, sortWeight); } } diff --git a/src/main/java/io/github/mapepire_ibmi/types/JobLogEntry.java b/src/main/java/io/github/mapepire_ibmi/types/JobLogEntry.java index c3b2e8d..61fce34 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/JobLogEntry.java +++ b/src/main/java/io/github/mapepire_ibmi/types/JobLogEntry.java @@ -2,35 +2,78 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents a job log entry. + */ public class JobLogEntry { + /** + * The unique message identifier. + */ @JsonProperty("MESSAGE_ID") private String messageId; + /** + * The severity level of the message. + */ @JsonProperty("SEVERITY") private String severity; + /** + * The timestamp when the message was generated. + */ @JsonProperty("MESSAGE_TIMESTAMP") private String messageTimestamp; + /** + * The library from which the message originated. + */ @JsonProperty("FROM_LIBRARY") private String fromLibrary; + /** + * The program from which the message originated. + */ @JsonProperty("FROM_PROGRAM") private String fromProgram; + /** + * The type of message. + */ @JsonProperty("MESSAGE_TYPE") private String messageType; + /** + * The message text. + */ @JsonProperty("MESSAGE_TEXT") private String messageText; + /** + * The second level text of the message, if available. + */ @JsonProperty("MESSAGE_SECOND_LEVEL_TEXT") private String messageSecondLevelText; + /** + * Construct a new JobLogEntry instance. + */ public JobLogEntry() { } + /** + * Construct a new JobLogEntry instance. + * + * @param messageId The unique message identifier. + * @param severity The severity level of the message. + * @param messageTimestamp The timestamp when the message was generated. + * @param fromLibrary The library from which the message originated. + * @param fromProgram The program from which the message originated. + * @param messageType The type of message. + * @param messageText The message text. + * @param messageSecondLevelText The second level text of the message, if + * available. + */ public JobLogEntry(String messageId, String severity, String messageTimestamp, String fromLibrary, String fromProgram, String messageType, String messageText, String messageSecondLevelText) { @@ -44,66 +87,147 @@ public JobLogEntry(String messageId, String severity, String messageTimestamp, this.messageSecondLevelText = messageSecondLevelText; } + /** + * Get the unique message identifier. + * + * @return The unique message identifier. + */ public String getMessageId() { return messageId; } + /** + * Set the unique message identifier. + * + * @param messageId The unique message identifier. + */ public void setMessageId(String messageId) { this.messageId = messageId; } + /** + * Get the severity level of the message. + * + * @return The severity level of the message. + */ public String getSeverity() { return severity; } + /** + * Set the severity level of the message. + * + * @param severity The severity level of the message. + */ public void setSeverity(String severity) { this.severity = severity; } + /** + * Get the timestamp when the message was generated. + * + * @return The timestamp when the message was generated. + */ public String getMessageTimestamp() { return messageTimestamp; } + /** + * Set the timestamp when the message was generated. + * + * @param messageTimestamp The timestamp when the message was generated. + */ public void setMessageTimestamp(String messageTimestamp) { this.messageTimestamp = messageTimestamp; } + /** + * Get the library from which the message originated. + * + * @return The library from which the message originated. + */ public String getFromLibrary() { return fromLibrary; } + /** + * Set the library from which the message originated. + * + * @param fromLibrary The library from which the message originated. + */ public void setFromLibrary(String fromLibrary) { this.fromLibrary = fromLibrary; } + /** + * Get the program from which the message originated. + * + * @return The program from which the message originated. + */ public String getFromProgram() { return fromProgram; } + /** + * Set the program from which the message originated. + * + * @param fromProgram The program from which the message originated. + */ public void setFromProgram(String fromProgram) { this.fromProgram = fromProgram; } + /** + * Get the type of message. + * + * @return The type of message. + */ public String getMessageType() { return messageType; } + /** + * Set the type of message. + * + * @param messageType The type of message. + */ public void setMessageType(String messageType) { this.messageType = messageType; } + /** + * Get the message text. + * + * @return The message text. + */ public String getMessageText() { return messageText; } + /** + * Set the message text. + * + * @param messageText The message text. + */ public void setMessageText(String messageText) { this.messageText = messageText; } + /** + * Get the second level text of the message, if available. + * + * @return The second level text of the message, if available. + */ public String getMessageSecondLevelText() { return messageSecondLevelText; } + /** + * Set the second level text of the message, if available. + * + * @param messageSecondLevelText The second level text of the message, if + * available. + */ public void setMessageSecondLevelText(String messageSecondLevelText) { this.messageSecondLevelText = messageSecondLevelText; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/JobStatus.java b/src/main/java/io/github/mapepire_ibmi/types/JobStatus.java index 0356408..1f3f3a3 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/JobStatus.java +++ b/src/main/java/io/github/mapepire_ibmi/types/JobStatus.java @@ -1,22 +1,63 @@ package io.github.mapepire_ibmi.types; +/** + * Enum representing the possible job statuses. + */ public enum JobStatus { + /** + * The job has not started yet. + */ NotStarted("notStarted"), + + /** + * The job is currently connecting to the server. + */ Connecting("connecting"), + + /** + * The job is ready to process queries. + */ Ready("ready"), + + /** + * The job is currently processing requests. + */ Busy("busy"), + + /** + * The job has ended. + */ Ended("ended"); + /** + * The job status. + */ private String value; + /** + * Construct a new JobStatus instance. + * + * @param value The job status. + */ JobStatus(String value) { this.value = value; } + /** + * Get the job status. + * + * @return The job status. + */ public String getValue() { return value; } + /** + * Get the enum job status representation of a string. + * + * @param value The string representation of the job status. + * @return The enum representation of the job status. + */ public static JobStatus fromValue(String value) { for (JobStatus type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/PoolAddOptions.java b/src/main/java/io/github/mapepire_ibmi/types/PoolAddOptions.java new file mode 100644 index 0000000..3259652 --- /dev/null +++ b/src/main/java/io/github/mapepire_ibmi/types/PoolAddOptions.java @@ -0,0 +1,67 @@ +package io.github.mapepire_ibmi.types; + +import io.github.mapepire_ibmi.SqlJob; + +/** + * Represents the options for configuring an addition to a connection pool. + */ +public class PoolAddOptions { + /** + * An existing job to add to the pool. + */ + private SqlJob existingJob; + + /** + * Whether to not add to the pool. + */ + private boolean poolIgnore; + + /** + * Construct a new PoolAddOptions instance. + */ + public PoolAddOptions() { + + } + + /** + * Construct a new PoolAddOptions instance. + * @param existingJob An existing job to add to the pool. + * @param poolIgnore Whether to not add to the pool. + */ + public PoolAddOptions(SqlJob existingJob, boolean poolIgnore) { + this.existingJob = existingJob; + this.poolIgnore = poolIgnore; + } + + /** + * Get the existing job to add to the pool. + * @return An existing job to add to the pool. + */ + public SqlJob getExistingJob() { + return existingJob; + } + + /** + * Set the existing job to add to the pool. + * @param existingJob An existing job to add to the pool. + */ + public void setExistingJob(SqlJob existingJob) { + this.existingJob = existingJob; + } + + /** + * Get whether to not add to the pool. + * @return Whether to not add to the pool + */ + public boolean getPoolIgnore() { + return poolIgnore; + } + + /** + * Set whether to not add to the pool. + * @param poolIgnore Whether to not add to the pool + */ + public void setPoolIgnore(boolean poolIgnore) { + this.poolIgnore = poolIgnore; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/mapepire_ibmi/types/PoolOptions.java b/src/main/java/io/github/mapepire_ibmi/types/PoolOptions.java new file mode 100644 index 0000000..16a9d4d --- /dev/null +++ b/src/main/java/io/github/mapepire_ibmi/types/PoolOptions.java @@ -0,0 +1,123 @@ +package io.github.mapepire_ibmi.types; + +/** + * Represents the options for configuring a connection pool. + */ +public class PoolOptions { + /** + * The credentials required to connect to the daemon server. + */ + private DaemonServer creds; + + /** + * The JDBC options for configuring the connection. These options may + * include settings such as connection timeout, SSL settings, etc. + */ + private JDBCOptions opts; + + /** + * The maximum number of connections allowed in the pool. This defines + * the upper limit on the number of active connections. + */ + private int maxSize; + + /** + * The number of connections to create when the pool is initialized. + * This determines the starting size of the connection pool. + */ + private int startingSize; + + /** + * Construct a new PoolOptions instance. + * @param creds The credentials required to connect to the daemon server. + * @param opts The JDBC options for configuring the connection. + * @param maxSize The maximum number of connections allowed in the pool. + * @param startingSize The number of connections to create when the pool + * is initialized. + */ + public PoolOptions(DaemonServer creds, JDBCOptions opts, int maxSize, int startingSize) { + this.creds = creds; + this.opts = opts; + this.maxSize = maxSize; + this.startingSize = startingSize; + } + + /** + * Construct a new PoolOptions instance. + * @param creds The credentials required to connect to the daemon server. + * @param maxSize The maximum number of connections allowed in the pool. + * @param startingSize The number of connections to create when the pool + * is initialized. + */ + public PoolOptions(DaemonServer creds, int maxSize, int startingSize) { + this.creds = creds; + this.opts = new JDBCOptions(); + this.maxSize = maxSize; + this.startingSize = startingSize; + } + + /** + * Get the credentials required to connect to the daemon server. + * @return The credentials required to connect to the daemon server. + */ + public DaemonServer getCreds() { + return creds; + } + + /** + * Set the credentials required to connect to the daemon server. + * @param creds The credentials required to connect to the daemon server. + */ + public void setCreds(DaemonServer creds) { + this.creds = creds; + } + + /** + * Get the JDBC options for configuring the connection. + * @return The JDBC options for configuring the connection. + */ + public JDBCOptions getOpts() { + return opts; + } + + /** + * Set the JDBC options for configuring the connection. + * @param opts The JDBC options for configuring the connection. + */ + public void setOpts(JDBCOptions opts) { + this.opts = opts; + } + + /** + * Get the maximum number of connections allowed in the pool. + * @return The maximum number of connections allowed in the pool. + */ + public int getMaxSize() { + return maxSize; + } + + /** + * Set the maximum number of connections allowed in the pool. + * @param maxSize The maximum number of connections allowed in the pool. + */ + public void setMaxSize(int maxSize) { + this.maxSize = maxSize; + } + + /** + * Get the number of connections to create when the pool is initialized. + * @return The number of connections to create when the pool is initialized. + */ + public int getStartingSize() { + return startingSize; + } + + /** + * Set the number of connections to create when the pool is initialized. + * @param startingSize The number of connections to create when the pool is + * initialized. + */ + public void setStartingSize(int startingSize) { + this.startingSize = startingSize; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/mapepire_ibmi/types/QueryMetadata.java b/src/main/java/io/github/mapepire_ibmi/types/QueryMetadata.java index d45b4f4..06b0fe6 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/QueryMetadata.java +++ b/src/main/java/io/github/mapepire_ibmi/types/QueryMetadata.java @@ -4,46 +4,98 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the metadata for a query. + */ public class QueryMetadata { + /** + * The number of columns returned by the query. + */ @JsonProperty("column_count") private int columnCount; + /** + * The metadata for each column. + */ @JsonProperty("columns") private List columns; + /** + * The unique job identifier for the query. + */ @JsonProperty("job") private String job; + /** + * Construct a new QueryMetadata instance. + */ public QueryMetadata() { } + /** + * Construct a new QueryMetadata instance. + * + * @param columnCount The number of columns returned by the query. + * @param columns The metadata for each column. + * @param job The unique job identifier for the query. + */ public QueryMetadata(int columnCount, List columns, String job) { this.columnCount = columnCount; this.columns = columns; this.job = job; } + /** + * Get the number of columns returned by the query. + * + * @return The number of columns returned by the query. + */ public int getColumnCount() { return columnCount; } + /** + * Set the number of columns returned by the query. + * + * @param columnCount The number of columns returned by the query. + */ public void setColumnCount(int columnCount) { this.columnCount = columnCount; } + /** + * Get the metadata for each column. + * + * @return The metadata for each column. + */ public List getColumns() { return columns; } + /** + * Set the metadata for each column. + * + * @param columns The metadata for each column. + */ public void setColumns(List columns) { this.columns = columns; } + /** + * Get the unique job identifier for the query. + * + * @return The unique job identifier for the query. + */ public String getJob() { return job; } + /** + * Set the unique job identifier for the query. + * + * @param job The unique job identifier for the query. + */ public void setJob(String job) { this.job = job; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/QueryOptions.java b/src/main/java/io/github/mapepire_ibmi/types/QueryOptions.java index 3b28082..9f876bb 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/QueryOptions.java +++ b/src/main/java/io/github/mapepire_ibmi/types/QueryOptions.java @@ -4,46 +4,98 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the options for configuring a query. + */ public class QueryOptions { + /** + * Whether to return terse results. + */ @JsonProperty("isTerseResults") private boolean isTerseResults; + /** + * Whether the command is a CL command. + */ @JsonProperty("isClCommand") private boolean isClCommand; + /** + * The parameters for the query. + */ @JsonProperty("parameters") private List parameters; + /** + * Construct a new QueryOptions instance. + */ public QueryOptions() { } + /** + * Construct a new QueryOptions instance. + * + * @param isTerseResults Whether to return terse results. + * @param isClCommand Whether the command is a CL command. + * @param parameters The parameters for the query. + */ public QueryOptions(boolean isTerseResults, boolean isClCommand, List parameters) { this.isTerseResults = isTerseResults; this.isClCommand = isClCommand; this.parameters = parameters; } + /** + * Get whether to return terse results. + * + * @return Whether to return terse results. + */ public boolean getIsTerseResults() { return isTerseResults; } + /** + * Set whether to return terse results. + * + * @param isTerseResults Whether to return terse results. + */ public void setIsTerseResults(boolean isTerseResults) { this.isTerseResults = isTerseResults; } + /** + * Get whether the command is a CL command. + * + * @return Whether the command is a CL command. + */ public boolean getIsClCommand() { return isClCommand; } + /** + * Set whether the command is a CL command. + * + * @param isClCommand Whether the command is a CL command. + */ public void setIsClCommand(boolean isClCommand) { this.isClCommand = isClCommand; } + /** + * Get the parameters for the query. + * + * @return The parameters for the query. + */ public List getParameters() { return parameters; } + /** + * Set the parameters for the query. + * + * @param parameters The parameters for the query. + */ public void setParameters(List parameters) { this.parameters = parameters; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/QueryResult.java b/src/main/java/io/github/mapepire_ibmi/types/QueryResult.java index 2707565..ec598b2 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/QueryResult.java +++ b/src/main/java/io/github/mapepire_ibmi/types/QueryResult.java @@ -4,26 +4,61 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents a standard query result. + */ public class QueryResult extends ServerResponse { + /** + * The metadata about the query results. + */ @JsonProperty("metadata") private QueryMetadata metadata; + /** + * Whether the query execution is complete. + */ @JsonProperty("is_done") private boolean isDone; + /** + * Whether the results were returned. + */ @JsonProperty("has_results") private boolean hasResults; + /** + * The number of rows affected by the query. + */ @JsonProperty("update_count") private int updateCount; + /** + * The data returned from the query. + */ @JsonProperty("data") private List data; + /** + * Construct a new QueryResult instance. + */ public QueryResult() { super(); } + /** + * Construct a new QueryResult instance. + * + * @param id The unique identifier for the request. + * @param success Whether the request was successful. + * @param error The error message, if any. + * @param sqlRc The SQL return code. + * @param sqlState The SQL state code. + * @param metadata The metadata about the query results. + * @param isDone Whether the query execution is complete. + * @param hasResults Whether the results were returned. + * @param updateCount The number of rows affected by the query. + * @param data The data returned from the query. + */ public QueryResult(String id, boolean success, String error, int sqlRc, String sqlState, QueryMetadata metadata, boolean isDone, boolean hasResults, int updateCount, List data) { super(id, success, error, sqlRc, sqlState); @@ -34,42 +69,92 @@ public QueryResult(String id, boolean success, String error, int sqlRc, String s this.data = data; } + /** + * Get the metadata about the query results. + * + * @return The metadata about the query results. + */ public QueryMetadata getMetadata() { return metadata; } + /** + * Set the metadata about the query results. + * + * @param metadata The metadata about the query results. + */ public void setMetadata(QueryMetadata metadata) { this.metadata = metadata; } + /** + * Get whether the query execution is complete. + * + * @return Whether the query execution is complete. + */ public boolean getIsDone() { return isDone; } + /** + * Set whether the query execution is complete. + * + * @param isDone Whether the query execution is complete. + */ public void setIsDone(boolean isDone) { this.isDone = isDone; } + /** + * Get whether the results were returned. + * + * @return Whether the results were returned. + */ public boolean getHasResults() { return hasResults; } + /** + * Set whether the results were returned. + * + * @param hasResults Whether the results were returned. + */ public void setHasResults(boolean hasResults) { this.hasResults = hasResults; } + /** + * Get the number of rows affected by the query. + * + * @return The number of rows affected by the query. + */ public int getUpdateCount() { return updateCount; } + /** + * Set the number of rows affected by the query. + * + * @param updateCount The number of rows affected by the query. + */ public void setUpdateCount(int updateCount) { this.updateCount = updateCount; } + /** + * Get the data returned from the query. + * + * @return The data returned from the query. + */ public List getData() { return data; } + /** + * Set the data returned from the query. + * + * @param data The data returned from the query. + */ public void setData(List data) { this.data = data; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/QueryState.java b/src/main/java/io/github/mapepire_ibmi/types/QueryState.java index e33bb3e..6753535 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/QueryState.java +++ b/src/main/java/io/github/mapepire_ibmi/types/QueryState.java @@ -1,21 +1,60 @@ package io.github.mapepire_ibmi.types; +/** + * Enum representing the possible states of a query execution. + */ public enum QueryState { + /** + * Indicates that the query has not yet been run. + */ NOT_YET_RUN(1), + + /** + * Indicates that the query has been executed, and more data is available for + * retrieval. + */ RUN_MORE_DATA_AVAILABLE(2), + + /** + * Indicates that the query has been successfully executed and all data has been + * retrieved. + */ RUN_DONE(3), + + /** + * Indicates that an error occurred during the query execution. + */ ERROR(4); + /** + * The query state. + */ private int value; + /** + * Construct a new QueryState instance. + * + * @param value The query state. + */ QueryState(int value) { this.value = value; } + /** + * Get the query state. + * + * @return The query state. + */ public int getValue() { return value; } + /** + * Get the enum query state representation of a string. + * + * @param value The string representation of the query state. + * @return The enum representation of the query state. + */ public static QueryState fromValue(int value) { for (QueryState type : values()) { if (type.value == value) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/ServerResponse.java b/src/main/java/io/github/mapepire_ibmi/types/ServerResponse.java index 628029c..4fc4ddd 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/ServerResponse.java +++ b/src/main/java/io/github/mapepire_ibmi/types/ServerResponse.java @@ -2,26 +2,56 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents a standard server response. + */ public class ServerResponse { + /** + * The unique identifier for the request. + */ @JsonProperty("id") private String id; + /** + * Whether the request was successful. + */ @JsonProperty("success") private boolean success; + /** + * The error message, if any. + */ @JsonProperty("error") private String error; + /** + * The SQL return code. + */ @JsonProperty("sql_rc") private int sqlRc; + /** + * The SQL state code. + */ @JsonProperty("sql_state") private String sqlState; + /** + * Construct a new ServerResponse instance. + */ public ServerResponse() { } + /** + * Construct a new ServerResponse instance. + * + * @param id The unique identifier for the request. + * @param success Whether the request was successful. + * @param error The error message, if any. + * @param sqlRc The SQL return code. + * @param sqlState The SQL state code. + */ public ServerResponse(String id, boolean success, String error, int sqlRc, String sqlState) { this.id = id; this.success = success; @@ -30,42 +60,92 @@ public ServerResponse(String id, boolean success, String error, int sqlRc, Strin this.sqlState = sqlState; } + /** + * Get the unique identifier for the request. + * + * @return The unique identifier for the request. + */ public String getId() { return id; } + /** + * Set the unique identifier for the request. + * + * @param id The unique identifier for the request. + */ public void setId(String id) { this.id = id; } + /** + * Get whether the request was successful. + * + * @return Whether the request was successful. + */ public boolean getSuccess() { return success; } + /** + * Set whether the request was successful. + * + * @param success Whether the request was successful. + */ public void setSuccess(boolean success) { this.success = success; } + /** + * Get the error message, if any. + * + * @return The error message, if any. + */ public String getError() { return error; } + /** + * Set the error message, if any. + * + * @param error The error message, if any. + */ public void setError(String error) { this.error = error; } + /** + * Get the SQL return code. + * + * @return The SQL return code. + */ public int getSqlRc() { return sqlRc; } + /** + * Set the SQL return code. + * + * @param sqlRc The SQL return code. + */ public void setSqlRc(int sqlRc) { this.sqlRc = sqlRc; } + /** + * Get the SQL state code. + * + * @return The SQL state code. + */ public String getSqlState() { return sqlState; } + /** + * Set the SQL state code. + * + * @param sqlState The SQL state code. + */ public void setSqlState(String sqlState) { this.sqlState = sqlState; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/ServerTraceDest.java b/src/main/java/io/github/mapepire_ibmi/types/ServerTraceDest.java index 6d5c354..bb8b645 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/ServerTraceDest.java +++ b/src/main/java/io/github/mapepire_ibmi/types/ServerTraceDest.java @@ -1,19 +1,48 @@ package io.github.mapepire_ibmi.types; +/** + * Enum representing the possible server trace destinations. + */ public enum ServerTraceDest { + /** + * Trace data is saved to a file. + */ FILE("FILE"), + + /** + * Trace data is kept in memory. + */ IN_MEM("IN_MEM"); + /** + * The server trace destination. + */ private String value; + /** + * Construct a new ServerTraceDest instance. + * + * @param value The server trace destination. + */ ServerTraceDest(String value) { this.value = value; } + /** + * Get the server trace destination. + * + * @return The server trace destination. + */ public String getValue() { return value; } + /** + * Get the enum server trace destination representation of a string. + * + * @param value The string representation of the server trace destination. + * @return The enum representation of the server trace destination. + */ public static ServerTraceDest fromValue(String value) { for (ServerTraceDest type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/ServerTraceLevel.java b/src/main/java/io/github/mapepire_ibmi/types/ServerTraceLevel.java index 85712e7..afa960d 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/ServerTraceLevel.java +++ b/src/main/java/io/github/mapepire_ibmi/types/ServerTraceLevel.java @@ -1,21 +1,58 @@ package io.github.mapepire_ibmi.types; +/** + * Enum representing the possible server trace levels. + */ public enum ServerTraceLevel { - OFF("OFF"), // off - ON("ON"), // all except datastream - ERRORS("ERRORS"), // errors only - DATASTREAM("DATASTREAM"); // all including datastream + /** + * Tracing is turned off. + */ + OFF("OFF"), + /** + * All trace data is collected except datastream. + */ + ON("ON"), + + /** + * Only error trace data is collected. + */ + ERRORS("ERRORS"), + + /** + * All trace data is collected including datastream. + */ + DATASTREAM("DATASTREAM"); + + /** + * The server trace level. + */ private String value; + /** + * Construct a new ServerTraceLevel instance. + * + * @param value The server trace level. + */ ServerTraceLevel(String value) { this.value = value; } + /** + * Get the server trace level. + * + * @return The server trace level. + */ public String getValue() { return value; } + /** + * Get the enum server trace level representation of a string. + * + * @param value The string representation of the server trace level. + * @return The enum representation of the server trace level. + */ public static ServerTraceLevel fromValue(String value) { for (ServerTraceLevel type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/SetConfigResult.java b/src/main/java/io/github/mapepire_ibmi/types/SetConfigResult.java index 332fd4a..5290163 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/SetConfigResult.java +++ b/src/main/java/io/github/mapepire_ibmi/types/SetConfigResult.java @@ -2,17 +2,40 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the result of a connection request. + */ public class SetConfigResult extends ServerResponse { + /** + * The destination for trace data. + */ @JsonProperty("tracedest") private ServerTraceDest tracedest; + /** + * The level of tracing set on the server. + */ @JsonProperty("tracelevel") private ServerTraceLevel tracelevel; + /** + * Construct a new SetConfigResult instance. + */ public SetConfigResult() { super(); } + /** + * Construct a new SetConfigResult instance. + * + * @param id The unique identifier for the request. + * @param success Whether the request was successful. + * @param error The error message, if any. + * @param sqlRc The SQL return code. + * @param sqlState The SQL state code. + * @param tracedest The destination for trace data. + * @param tracelevel The level of tracing set on the server. + */ public SetConfigResult(String id, boolean success, String error, int sqlRc, String sqlState, ServerTraceDest tracedest, ServerTraceLevel tracelevel) { super(id, success, error, sqlRc, sqlState); @@ -20,18 +43,38 @@ public SetConfigResult(String id, boolean success, String error, int sqlRc, Stri this.tracelevel = tracelevel; } + /** + * Get the destination for trace data. + * + * @return The destination for trace data. + */ public ServerTraceDest getTracedest() { return tracedest; } + /** + * Set the destination for trace data. + * + * @param tracedest The destination for trace data. + */ public void setTracedest(ServerTraceDest tracedest) { this.tracedest = tracedest; } + /** + * Get the level of tracing set on the server. + * + * @return The level of tracing set on the server. + */ public ServerTraceLevel getTracelevel() { return tracelevel; } + /** + * Set the level of tracing set on the server. + * + * @param tracelevel The level of tracing set on the server. + */ public void setTracelevel(ServerTraceLevel tracelevel) { this.tracelevel = tracelevel; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/TransactionEndType.java b/src/main/java/io/github/mapepire_ibmi/types/TransactionEndType.java index 9e2580b..6532c26 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/TransactionEndType.java +++ b/src/main/java/io/github/mapepire_ibmi/types/TransactionEndType.java @@ -1,6 +1,16 @@ package io.github.mapepire_ibmi.types; +/** + * Enum representing the possible types of transaction endings. + */ public enum TransactionEndType { + /** + * Commit the transaction. + */ COMMIT, + + /** + * Rollback the transaction. + */ ROLLBACK } diff --git a/src/main/java/io/github/mapepire_ibmi/types/VersionCheckResult.java b/src/main/java/io/github/mapepire_ibmi/types/VersionCheckResult.java index 3ced557..cf820e1 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/VersionCheckResult.java +++ b/src/main/java/io/github/mapepire_ibmi/types/VersionCheckResult.java @@ -2,13 +2,40 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * Represents the result of a version check. + */ public class VersionCheckResult extends ServerResponse { + /** + * The build date of the version. + */ @JsonProperty("buildDate") private String buildDate; + /** + * The version string. + */ @JsonProperty("version") private String version; + /** + * Construct a new VersionCheckResult instance. + */ + public VersionCheckResult() { + + } + + /** + * Construct a new VersionCheckResult instance. + * + * @param id The unique identifier for the request. + * @param success Whether the request was successful. + * @param error The error message, if any. + * @param sqlRc The SQL return code. + * @param sqlState The SQL state code. + * @param buildDate The build date of the version. + * @param version The version string. + */ public VersionCheckResult(String id, boolean success, String error, int sqlRc, String sqlState, String buildDate, String version) { super(id, success, error, sqlRc, sqlState); @@ -16,18 +43,38 @@ public VersionCheckResult(String id, boolean success, String error, int sqlRc, S this.version = version; } + /** + * Get the build date of the version. + * + * @return The build date of the version. + */ public String getBuildDate() { return buildDate; } + /** + * Set the build date of the version. + * + * @param buildDate The build date of the version. + */ public void setBuildDate(String buildDate) { this.buildDate = buildDate; } + /** + * Get the version string. + * + * @return The version string. + */ public String getVersion() { return version; } + /** + * Set the version string. + * + * @param version The version string. + */ public void setVersion(String version) { this.version = version; } diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Access.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Access.java index c1fda0d..3c3c905 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Access.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Access.java @@ -1,20 +1,53 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "access" JDBC option. + */ public enum Access { + /** + * All SQL statements allowed. + */ ALL("all"), + + /** + * SELECT and CALL statements allowed. + */ READ_CALL("read call"), + + /** + * SELECT statements only. + */ READ_ONLY("read only"); + /** + * The "access" value. + */ private final String value; + /** + * Construct a new Access instance. + * + * @param value The "access" value. + */ Access(String value) { this.value = value; } + /** + * Get the "access" value. + * + * @return The "access" value. + */ public String getValue() { return value; } + /** + * Get the enum "access" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static Access fromValue(String value) { for (Access type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BidiStringType.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BidiStringType.java index e13aa46..c24c42c 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BidiStringType.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BidiStringType.java @@ -1,25 +1,79 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "bidi string type" + * JDBC option. + */ public enum BidiStringType { + /** + * Bidi String Type 4 + */ TYPE_4("4"), + + /** + * Bidi String Type 5 + */ TYPE_5("5"), + + /** + * Bidi String Type 6 + */ TYPE_6("6"), + + /** + * Bidi String Type 7 + */ TYPE_7("7"), + + /** + * Bidi String Type 8 + */ TYPE_8("8"), + + /** + * Bidi String Type 9 + */ TYPE_9("9"), + + /** + * Bidi String Type 10 + */ TYPE_10("10"), + + /** + * Bidi String Type 11 + */ TYPE_11("11"); + /** + * The "bidi string type" value. + */ private final String value; + /** + * Construct a new BidiStringType instance. + * + * @param value The "bidi string type" value. + */ BidiStringType(String value) { this.value = value; } + /** + * Get the "bidi string type" value. + * + * @return The "bidi string type" value. + */ public String getValue() { return value; } + /** + * Get the enum "bidi string type" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static BidiStringType fromValue(String value) { for (BidiStringType type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BlockCriteria.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BlockCriteria.java index 77eda55..5c09811 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BlockCriteria.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BlockCriteria.java @@ -1,20 +1,54 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "block criteria" JDBC + * option. + */ public enum BlockCriteria { + /** + * No record blocking. + */ CRITERIA_0("0"), + + /** + * Block if FOR FETCH ONLY is specified. + */ CRITERIA_1("1"), + + /** + * Block unless FOR UPDATE is specified. + */ CRITERIA_2("2"); + /** + * The "block criteria" value. + */ private final String value; + /** + * Construct a new BlockCriteria instance. + * + * @param value The "block criteria" value. + */ BlockCriteria(String value) { this.value = value; } + /** + * Get the "block criteria" value. + * + * @return The "block criteria" value. + */ public String getValue() { return value; } + /** + * Get the enum "block criteria" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static BlockCriteria fromValue(String value) { for (BlockCriteria type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BlockSize.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BlockSize.java index 8979427..0937fce 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BlockSize.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/BlockSize.java @@ -1,25 +1,79 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "block size" JDBC + * option. + */ public enum BlockSize { + /** + * 0 kilobytes + */ SIZE_0("0"), + + /** + * 8 kilobytes. + */ SIZE_8("8"), + + /** + * 16 kilobytes. + */ SIZE_16("16"), + + /** + * 32 kilobytes. + */ SIZE_32("32"), + + /** + * 64 kilobytes. + */ SIZE_64("64"), + + /** + * 128 kilobytes. + */ SIZE_128("128"), + + /** + * 256 kilobytes. + */ SIZE_256("256"), + + /** + * 512 kilobytes. + */ SIZE_512("512"); + /** + * The "block size" value. + */ private final String value; + /** + * Construct a new BlockSize instance. + * + * @param value The "block size" value. + */ BlockSize(String value) { this.value = value; } + /** + * Get the "block size" value. + * + * @return The "block size" value. + */ public String getValue() { return value; } + /** + * Get the enum "block size" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static BlockSize fromValue(String value) { for (BlockSize type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ConcurrentAccessResolution.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ConcurrentAccessResolution.java index 3893254..5b7eb9e 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ConcurrentAccessResolution.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ConcurrentAccessResolution.java @@ -1,20 +1,54 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "concurrent access + * resolution" JDBC option. + */ public enum ConcurrentAccessResolution { + /** + * Currently committed. + */ RESOLUTION_1("1"), + + /** + * Wait for outcome. + */ RESOLUTION_2("2"), + + /** + * Skip locks. + */ RESOLUTION_3("3"); + /** + * The "concurrent access resolution" value. + */ private final String value; + /** + * Construct a new ConcurrentAccessResolution instance. + * + * @param value The "concurrent access resolution" value. + */ ConcurrentAccessResolution(String value) { this.value = value; } + /** + * Get the "concurrent access resolution" value. + * + * @return The "concurrent access resolution" value. + */ public String getValue() { return value; } + /** + * Get the enum "concurrent access resolution" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static ConcurrentAccessResolution fromValue(String value) { for (ConcurrentAccessResolution type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/CursorSensitivity.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/CursorSensitivity.java index ce40e25..fe79c4a 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/CursorSensitivity.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/CursorSensitivity.java @@ -1,20 +1,54 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "cursor sensitivity" + * JDBC option. + */ public enum CursorSensitivity { + /** + * Asensitive cursor sensitivity. + */ ASENSITIVE("asensitive"), + + /** + * Insensitive cursor sensitivity. + */ INSENSITIVE("insensitive"), + + /** + * Sensitive cursor sensitivity. + */ SENSITIVE("sensitive"); + /** + * The "cursor sensitivity" value. + */ private final String value; + /** + * Construct a new CursorSensitivity instance. + * + * @param value The "cursor sensitivity" value. + */ CursorSensitivity(String value) { this.value = value; } + /** + * Get the "cursor sensitivity" value. + * + * @return The "cursor sensitivity" value. + */ public String getValue() { return value; } + /** + * Get the enum "cursor sensitivity" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static CursorSensitivity fromValue(String value) { for (CursorSensitivity type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DateFormat.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DateFormat.java index 0280def..2156db4 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DateFormat.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DateFormat.java @@ -1,25 +1,79 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "date format" JDBC + * option. + */ public enum DateFormat { + /** + * mdy date format. + */ MDY("mdy"), + + /** + * dmy date format. + */ DMY("dmy"), + + /** + * ymd date format. + */ YMD("ymd"), + + /** + * usa date format. + */ USA("usa"), + + /** + * iso date format. + */ ISO("iso"), + + /** + * eur date format. + */ EUR("eur"), + + /** + * jis date format. + */ JIS("jis"), + + /** + * julian date format. + */ JULIAN("julian"); + /** + * The "date format" value. + */ private final String value; + /** + * Construct a new DateFormat instance. + * + * @param value The "date format" value. + */ DateFormat(String value) { this.value = value; } + /** + * Get the "date format" value. + * + * @return The "date format" value. + */ public String getValue() { return value; } + /** + * Get the enum "date format" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static DateFormat fromValue(String value) { for (DateFormat type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DateSeparator.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DateSeparator.java index 3dfa4b4..b00d829 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DateSeparator.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DateSeparator.java @@ -1,22 +1,64 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "date separator" JDBC + * option. + */ public enum DateSeparator { + /** + * Slash date separator. + */ SLASH("/"), + + /** + * Dash date separator. + */ DASH("-"), + + /** + * Dot date separator. + */ DOT("."), + + /** + * Comma date separator. + */ COMMA(","), + + /** + * Space date separator. + */ B("b"); + /** + * The "date separator" value. + */ private final String value; + /** + * Construct a new DateSeparator instance. + * + * @param value The "date separator" value. + */ DateSeparator(String value) { this.value = value; } + /** + * Get the "date separator" value. + * + * @return The "date separator" value. + */ public String getValue() { return value; } + /** + * Get the enum "date separator" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static DateSeparator fromValue(String value) { for (DateSeparator type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DecfloatRoundingMode.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DecfloatRoundingMode.java index 991d4f6..eabf0d3 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DecfloatRoundingMode.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DecfloatRoundingMode.java @@ -1,24 +1,74 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "decfloat rounding + * mode" JDBC option. + */ public enum DecfloatRoundingMode { + /** + * Half even rounding mode. + */ HALF_EVEN("half even"), + + /** + * Half up rounding mode. + */ HALF_UP("half up"), + + /** + * Down rounding mode. + */ DOWN("down"), + + /** + * Ceiling rounding mode. + */ CEILING("ceiling"), + + /** + * Floor rounding mode. + */ FLOOR("floor"), + + /** + * Up rounding mode. + */ UP("up"), + + /** + * Half down rounding mode. + */ HALF_DOWN("half down"); + /** + * The "decfloat rounding mode" value. + */ private final String value; + /** + * Construct a new DecfloatRoundingMode instance. + * + * @param value The "decfloat rounding mode" value. + */ DecfloatRoundingMode(String value) { this.value = value; } + /** + * Get the "decfloat rounding mode" value. + * + * @return The "decfloat rounding mode" value. + */ public String getValue() { return value; } + /** + * Get the enum "decfloat rounding mode" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static DecfloatRoundingMode fromValue(String value) { for (DecfloatRoundingMode type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DecimalSeparator.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DecimalSeparator.java index bddcfaf..a5099ca 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DecimalSeparator.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/DecimalSeparator.java @@ -1,19 +1,49 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "decimal separator" + * JDBC option. + */ public enum DecimalSeparator { + /** + * Period decimal separator. + */ DOT("."), + + /** + * Comma decimal separator. + */ COMMA(","); + /** + * The "decimal separator" value. + */ private final String value; + /** + * Construct a new DecimalSeparator instance. + * + * @param value The "decimal separator" value. + */ DecimalSeparator(String value) { this.value = value; } + /** + * Get the "decimal separator" value. + * + * @return The "decimal separator" value. + */ public String getValue() { return value; } + /** + * Get the enum "decimal separator" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static DecimalSeparator fromValue(String value) { for (DecimalSeparator type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Driver.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Driver.java index 77d0ff5..5cea154 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Driver.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Driver.java @@ -1,19 +1,49 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "driver" JDBC option. + */ public enum Driver { + /** + * Use only the IBM Toolbox for Java JDBC driver. + */ TOOLBOX("toolbox"), + + /** + * Use the IBM Developer Kit for Java JDBC driver if running on the server, + * otherwise use the IBM Toolbox for Java JDBC driver. + */ NATIVE("native"); + /** + * The "driver" value. + */ private final String value; + /** + * Construct a new Driver instance. + * + * @param value The "driver" value. + */ Driver(String value) { this.value = value; } + /** + * Get the "driver" value. + * + * @return The "driver" value. + */ public String getValue() { return value; } + /** + * Get the enum "driver" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static Driver fromValue(String value) { for (Driver type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Error.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Error.java deleted file mode 100644 index 464685c..0000000 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Error.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.github.mapepire_ibmi.types.jdbcOptions; - -public enum Error { - FULL("full"), - BASIC("basic"); - - private final String value; - - Error(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - public static Error fromValue(String value) { - for (Error type : values()) { - if (type.value.equals(value)) { - return type; - } - } - throw new IllegalArgumentException("Unknown value: " + value); - } -} diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Errors.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Errors.java new file mode 100644 index 0000000..33e1899 --- /dev/null +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Errors.java @@ -0,0 +1,52 @@ +package io.github.mapepire_ibmi.types.jdbcOptions; + +/** + * Enum representing the possible types of values for the "errors" JDBC option. + */ +public enum Errors { + /** + * Full error detail. + */ + FULL("full"), + + /** + * Basic error detail. + */ + BASIC("basic"); + + /** + * The "errors" value. + */ + private final String value; + + /** + * Construct a new Errors instance. + * @param value The "errors" value. + */ + Errors(String value) { + this.value = value; + } + + /** + * Get the "errors" value. + * @return The "errors" value. + */ + public String getValue() { + return value; + } + + /** + * Get the enum "errors" value representation of a string. + * @param value The string representation of the option. + * @return The enum representation of the option. + */ + public static Errors fromValue(String value) { + for (Errors type : values()) { + if (type.value.equals(value)) { + return type; + } + } + + throw new IllegalArgumentException("Unknown value: " + value); + } +} diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MaximumPrecision.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MaximumPrecision.java index 4e9510a..32800be 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MaximumPrecision.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MaximumPrecision.java @@ -1,19 +1,49 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "maximum precision" + * JDBC option. + */ public enum MaximumPrecision { + /** + * 31 maximum decimal precision. + */ PRECISION_31("31"), + + /** + * 63 maximum decimal precision. + */ PRECISION_63("63"); + /** + * The "maximum precision" value. + */ private final String value; + /** + * Construct a new MaximumPrecision instance. + * + * @param value The "maximum precision" value. + */ MaximumPrecision(String value) { this.value = value; } + /** + * Get the "maximum precision" value. + * + * @return The "maximum precision" value. + */ public String getValue() { return value; } + /** + * Get the enum "maximum precision" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static MaximumPrecision fromValue(String value) { for (MaximumPrecision type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MetadataSource.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MetadataSource.java index dec8b82..e78a375 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MetadataSource.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MetadataSource.java @@ -1,19 +1,49 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "metadata source" JDBC + * option. + */ public enum MetadataSource { + /** + * ROI access. + */ SOURCE_0("0"), + + /** + * SQL stored procedures. + */ SOURCE_1("1"); + /** + * The "metadata source" value. + */ private final String value; + /** + * Construct a new MetadataSource instance. + * + * @param value The "metadata source" value. + */ MetadataSource(String value) { this.value = value; } + /** + * Get the "metadata source" value. + * + * @return The "metadata source" value. + */ public String getValue() { return value; } + /** + * Get the enum "metadata source" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static MetadataSource fromValue(String value) { for (MetadataSource type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MinimumDivideScale.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MinimumDivideScale.java index 72da186..5f2533c 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MinimumDivideScale.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/MinimumDivideScale.java @@ -1,27 +1,89 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "minimum divide scale" + * JDBC option. + */ public enum MinimumDivideScale { + /** + * 0 scale value. + */ SCALE_0("0"), + + /** + * 1 scale value. + */ SCALE_1("1"), + + /** + * 2 scale value. + */ SCALE_2("2"), + + /** + * 3 scale value. + */ SCALE_3("3"), + + /** + * 4 scale value. + */ SCALE_4("4"), + + /** + * 5 scale value. + */ SCALE_5("5"), + + /** + * 6 scale value. + */ SCALE_6("6"), + + /** + * 7 scale value. + */ SCALE_7("7"), + + /** + * 8 scale value. + */ SCALE_8("8"), + + /** + * 9 scale value. + */ SCALE_9("9"); + /** + * The "minimum divide scale" value. + */ private final String value; + /** + * Construct a new MinimumDivideScale instance. + * + * @param value The "minimum divide scale" value. + */ MinimumDivideScale(String value) { this.value = value; } + /** + * Get the "minimum divide scale" value. + * + * @return The "minimum divide scale" value. + */ public String getValue() { return value; } + /** + * Get the enum "minimum divide scale" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static MinimumDivideScale fromValue(String value) { for (MinimumDivideScale type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Naming.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Naming.java index 01ad57d..8822000 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Naming.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Naming.java @@ -1,19 +1,48 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "naming" JDBC option. + */ public enum Naming { + /** + * As in schema.table. + */ SQL("sql"), + + /** + * As in schema/table. + */ SYSTEM("system"); + /** + * The "naming" value. + */ private final String value; + /** + * Construct a new Naming instance. + * + * @param value The "naming" value. + */ Naming(String value) { this.value = value; } + /** + * Get the "naming" value. + * + * @return The "naming" value. + */ public String getValue() { return value; } + /** + * Get the enum "naming" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static Naming fromValue(String value) { for (Naming type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Option.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Option.java new file mode 100644 index 0000000..5762adb --- /dev/null +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Option.java @@ -0,0 +1,595 @@ +package io.github.mapepire_ibmi.types.jdbcOptions; + +/** + * Enum representing the possible types of JDBC options. + */ +public enum Option { + /** + * Specifies the naming convention used when referring to tables. + */ + NAMING("naming"), + + /** + * Specifies the date format used in date literals within SQL statements. + */ + DATE_FORMAT("date format"), + + /** + * Specifies the date separator used in date literals within SQL statements. + * This property has no effect unless the "date format" property is set to + * "julian", "mdy", "dmy" or "ymd". + */ + DATE_SEPARATOR("date separator"), + + /** + * Specifies the decimal separator used in numeric literals within SQL + * statements. + */ + DECIMAL_SEPARATOR("decimal separator"), + + /** + * Specifies the time format used in time literals within SQL statements. + */ + TIME_FORMAT("time format"), + + /** + * Specifies the time separator used in time literals within SQL statements. + * This property has no effect unless the "time format" property is set to + * "hms". + */ + TIME_SEPARATOR("time separator"), + + /** + * Specifies whether the server fully opens a file for each query. By default + * the server optimizes open requests. This optimization improves performance + * but may fail if a database monitor is active when a query is run more than + * once. Set the property to true only when identical queries are issued when + * monitors are active. + */ + FULL_OPEN("full open"), + + /** + * Specifies the level of database access for the connection. + */ + ACCESS("access"), + + /** + * Specifies whether to throw an SQLException when Connection.commit() or + * Connection.rollback() is called if autocommit is enabled. + */ + AUTOCOMMIT_EXCEPTION("autocommit exception"), + + /** + * Specifies the output string type of bidirectional data. + */ + BIDI_STRING_TYPE("bidi string type"), + + /** + * Specifies if bidi implicit LTR-RTL reordering should be used. + */ + BIDI_IMPLICIT_REORDERING("bidi implicit reordering"), + + /** + * Specifies if the numeric ordering round trip feature should be used. + */ + BIDI_NUMERIC_ORDERING("bidi numeric ordering"), + + /** + * Specifies whether truncation of character data generates attention notices + * and exceptions. When this property is "true", writing truncated character + * data to the database throws an exception and using truncated character data + * in a query posts an attention notice. When this property is "false", writing + * truncated data to the database or using such data in a query generates no + * exception or attention notice. The default value is "true". This property + * does not affect numeric data. Writing truncated numeric data to the database + * always throws an error and using truncated numeric data in a query always + * posts attention notices. + */ + DATA_TRUNCATION("data truncation"), + + /** + * Specifies the JDBC driver implementation. The IBM Toolbox for Java JDBC + * driver can use different JDBC driver implementations based on the + * environment. If the environment is an IBM i JVM on the same server as the + * database to which the program is connecting, the native IBM Developer Kit for + * Java JDBC driver can be used. In any other environment, the IBM Toolbox for + * Java JDBC driver is used. This property has no effect if the "secondary URL" + * property is set. + */ + DRIVER("driver"), + + /** + * Specifies the amount of detail to be returned in the message for errors that + * occur on the server. + */ + ERRORS("errors"), + + /** + * Specifies whether the driver requests extended metadata from the server. + * Setting this property to true increases the accuracy of the information + * returned from the following ResultSetMetaData methods: getColumnLabel(int), + * isReadOnly(int), isSearchable(int), isWriteable(int). Additionally, setting + * this property to true enables support for the + * ResultSetMetaData.getSchemaName(int) and + * ResultSetMetaData.isAutoIncrement(int) methods. + */ + EXTENDED_METADATA("extended metadata"), + + /** + * Specifies whether input locators should be allocated as type hold locators or + * not hold locators. If the locators are of type hold, they will not be + * released when a commit is done. + */ + HOLD_INPUT_LOCATORS("hold input locators"), + + /** + * Specifies if statements should remain open until a transaction boundary when + * autocommit is off and they are associated with a LOB locator. By default, all + * the resources associated with a statement are released when the statement is + * closed. Set this property to true only when access to a LOB locator is needed + * after a statement has been closed. + */ + HOLD_STATEMENTS("hold statements"), + + /** + * Specifies a list of SQL states for which the driver should not create warning + * objects. By default, the IBM Toolbox for Java JDBC driver will internally + * create a java.sql.SQLWarning object for each warning returned by the + * database. For example, a warning with the SQLSTATE 0100C is created every + * time a result set is returned from a stored procedure. This warning can be + * safely ignored to improve the performance of applications that call stored + * procedures. + */ + IGNORE_WARNINGS("ignore warnings"), + + /** + * Specifies whether socket connection is to be periodically checked for + * operational status. + */ + KEEP_ALIVE("keep alive"), + + /** + * Specifies the key ring class name used for SSL connections with the server. + * This property has no effect unless "secure" is set to true and a key ring + * password is set using the "key ring password" property. + */ + KEY_RING_NAME("key ring name"), + + /** + * Specifies the password for the key ring class used for SSL communications + * with the server. This property has no effect unless "secure" is set to true + * and a key ring name is set using the "key ring name" property. + */ + KEY_RING_PASSWORD("key ring password"), + + /** + * Specifies how to retrieve DatabaseMetaData. If set to "0," database metadata + * will be retrieved through the Retrieve Object Information (ROI) data flow. If + * set to "1," database metadata will be retrieved by calling system stored + * procedures. + */ + METADATA_SOURCE("metadata source"), + + /** + * Specifies the host name and port of the middle-tier machine where the proxy + * server is running. The format for this is hostname[:port], where the port is + * optional. If this is not set, then the hostname and port are retrieved from + * the com.ibm.as400.access.AS400.proxyServer property. The default port is 3470 + * (if the connection uses SSL, the default port is 3471). The ProxyServer must + * be running on the middle-tier machine. The name of the middle-tier machine is + * ignored in a two-tier environment. + */ + PROXY_SERVER("proxy server"), + + /** + * Specifies the source of the text for REMARKS columns in ResultSets returned + * by DatabaseMetaData methods. This property is only used if the "metadata + * source" property is set to "0". + */ + REMARKS("remarks"), + + /** + * Specifies the URL to be used for a connection on the middle-tier's + * DriverManager in a multiple tier environment, if it is different than already + * specified. This property allows you to use this driver to connect to other + * databases. Use a backslash as an escape character before backslashes and + * semicolons in the URL. + */ + SECONDARY_URL("secondary URL"), + + /** + * Specifies whether a Secure Sockets Layer (SSL) connection is used to + * communicate with the server. + */ + SECURE("secure"), + + /** + * Specifies the level of tracing of the JDBC server job. When tracing is + * enabled, tracing starts when the client connects to the server and ends when + * the connection is disconnected. You must start tracing before connecting to + * the server, because the client enables server tracing only at connect time. + */ + SERVER_TRACE("server trace"), + + /** + * Specifies whether threads are used in communication with the host servers. + */ + THREAD_USED("thread used"), + + /** + * Specifies what category of an IBM Toolbox for Java trace to log. Trace + * messages are useful for debugging programs that call JDBC. However, there is + * a performance penalty associated with logging trace messages, so this + * property is only set for debugging. Trace messages are logged to System.out. + */ + TOOLBOX_TRACE("toolbox trace"), + + /** + * Specifies whether trace messages are logged. Trace messages are useful for + * debugging programs that call JDBC. However, there is a performance penalty + * associated with logging trace messages, so this property only set to "true" + * for debugging. Trace messages are logged to System.out. + */ + TRACE("trace"), + + /** + * Specifies whether binary data is translated. If this property is set to + * "true", then BINARY and VARBINARY fields are treated as CHAR and VARCHAR + * fields. + */ + TRANSLATE_BINARY("translate binary"), + + /** + * Specifies how Boolean objects are interpreted when setting the value for a + * character field/parameter using the PreparedStatement.setObject(), + * CallableStatement.setObject() or ResultSet.updateObject() methods. Setting + * the property to "true" would store the Boolean object in the character field + * as either "true" or "false." Setting the property to "false" would store the + * Boolean object in the character field as either "1" or "0." + */ + TRANSLATE_BOOLEAN("translate boolean"), + + /** + * + * Specifies one or more libraries that you want to add to or replace the + * library list of the server job, and optionally sets the default SQL schema + * (default library). Note that libraries cannot be longer than 10 characters in + * length. You must use the SET PATH SQL statement if you have libraries longer + * than 10 characters. + */ + LIBRARIES("libraries"), + + /** + * Specifies whether auto-commit mode is the default connection mode for new + * connections. Calling AS400JDBCConnection.setAutoCommit() will override this + * property on a per-connection basis. + */ + AUTO_COMMIT("auto commit"), + + /** + * Specifies whether "currently committed" access is used on the connection. A + * value of 1 indicates that "currently committed" will be used. A value of 2 + * indicates that "wait for outcome" will be used. A value of 3 indicates that + * "skip locks" will be used. + */ + CONCURRENT_ACCESS_RESOLUTION("concurrent access resolution"), + + /** + * Specifies whether to hold the cursor across transactions. If this property is + * set to "true", cursors are not closed when a transaction is committed or + * rolled back. All resources acquired during the unit of work are held, but + * locks on specific rows and objects implicitly acquired during the unit of + * work are released. + */ + CURSOR_HOLD("cursor hold"), + + /** + * Specifies the cursor sensitivity to request from the database. The behavior + * depends on the resultSetType. ResultSet.TYPE_FORWARD_ONLY or + * ResultSet.TYPE_SCROLL_SENSITIVE means that the value of this property + * controls what cursor sensitivity the Java™ program requests from the + * database. ResultSet.TYPE_SCROLL_INSENSITIVE causes this property to be + * ignored. + */ + CURSOR_SENSITIVITY("cursor sensitivity"), + + /** + * Specifies the database to use for the connection to an independent auxiliary + * storage pool (ASP). This property applies only when connecting to an IBM® i + * server. When you specify a database name, the name must exist in the + * relational database directory on the server and correspond to either an + * independent ASP or the system default database. There are several criteria + * which determine which database is accessed. When this property is used to + * specify a database which corresponds to an independent ASP, the connection is + * made to the independent ASP. When the specified database does not exist, the + * connection fails. When this property is used to specify *SYSBAS as the + * database name, the system default database is used. When this property is + * omitted, the initial ASP group specified in the job description for the user + * profile is used. When the job description does not specify an initial ASP + * group, the system default database is used. + */ + DATABASE_NAME("database name"), + + /** + * Specifies the rounding mode to use when working with the decfloat data type. + * This property is ignored when connecting to systems running IBM i 5.4 and + * earlier. + */ + DECFLOAT_ROUNDING_MODE("decfloat rounding mode"), + + /** + * Specifies the maximum decimal precision the database might use. + */ + MAXIMUM_PRECISION("maximum precision"), + + /** + * Specifies the maximum scale the database might use. + */ + MAXIMUM_SCALE("maximum scale"), + + /** + * Specifies the minimum scale value for the result of decimal division. + */ + MINIMUM_DIVIDE_SCALE("minimum divide scale"), + + /** + * Specifies the character encoding to use for the SQL package and any + * statements sent to the server. + */ + PACKAGE_CCSID("package ccsid"), + + /** + * Specifies the default transaction isolation. + */ + TRANSACTION_ISOLATION("transaction isolation"), + + /** + * Specifies how hexadecimal literals are interpreted. + */ + TRANSLATE_HEX("translate hex"), + + /** + * Specifies whether the connection should use true auto commit support. True + * autocommit means that autocommit is on and is running under a isolation level + * other than *NONE. By default, the driver handles autocommit by running under + * the server isolation level of *NONE. + */ + TRUE_AUTOCOMMIT("true autocommit"), + + /** + * Specifies whether lock sharing is allowed for loosely coupled transaction + * branches. + */ + XA_LOOSELY_COUPLED_SUPPORT("XA loosely coupled support"), + + /** + * Specifies whether an intermediate java.math.BigDecimal object is used for + * packed and zoned decimal conversions. If this property is set to "true", an + * intermediate java.math.BigDecimal object is used for packed and zoned decimal + * conversions as described by the JDBC specification. If this property is set + * to "false", no intermediate objects are used for packed and zoned decimal + * conversions. Instead, such values are converted directly to and from Java + * double values. Such conversions will be faster but may not follow all + * conversion and data truncation rules documented by the JDBC specification. + */ + BIG_DECIMAL("big decimal"), + + /** + * Specifies the criteria for retrieving data from the server in blocks of + * records. Specifying a non-zero value for this property will reduce the + * frequency of communication to the server, and therefore improve performance. + * Ensure that record blocking is off if the cursor is going to be used for + * subsequent UPDATEs, or else the row that is updated will not necessarily be + * the current row. + */ + BLOCK_CRITERIA("block criteria"), + + /** + * Specifies the block size (in kilobytes) to retrieve from the server and cache + * on the client. This property has no effect unless the "block criteria" + * property is non-zero. Larger block sizes reduce the frequency of + * communication to the server, and therefore may improve performance. + */ + BLOCK_SIZE("block size"), + + /** + * Specifies whether result set data is compressed. If this property is set to + * "true", then result set data is compressed. If this property is set to + * "false", then result set data is not compressed. Data compression may improve + * performance when retrieving large result sets. + */ + DATA_COMPRESSION("data compression"), + + /** + * Specifies whether to use extended dynamic support. Extended dynamic support + * provides a mechanism for caching dynamic SQL statements on the server. The + * first time a particular SQL statement is prepared, it is stored in a SQL + * package on the server. If the package does not exist, it is automatically + * created. On subsequent prepares of the same SQL statement, the server can + * skip a significant part of the processing by using information stored in the + * SQL package. If this is set to "true", then a package name must be set using + * the "package" property. + */ + EXTENDED_DYNAMIC("extended dynamic"), + + /** + * Specifies whether to delay closing cursors until subsequent requests. This + * will improve overall performance by reducing the total number of requests. + */ + LAZY_CLOSE("lazy close"), + + /** + * Specifies the maximum LOB (large object) size (in bytes) that can be + * retrieved as part of a result set. LOBs that are larger than this threshold + * will be retrieved in pieces using extra communication to the server. Larger + * LOB thresholds will reduce the frequency of communication to the server, but + * will download more LOB data, even if it is not used. Smaller LOB thresholds + * may increase frequency of communication to the server, but will only download + * LOB data as it is needed. + */ + LOB_THRESHOLD("lob threshold"), + + /** + * Specifies the maximum number of rows to be sent to the database engine when + * using a blocked insert or update operation. The database engine has a limit + * of 32000 rows with a total of 16MB of data. This property may be used to + * reduce the size of buffers in the JVM when using batched insert operations. + */ + MAXIMUM_BLOCKED_INPUT_ROWS("maximum blocked input rows"), + + /** + * Specifies the base name of the SQL package. Note that only the first six + * characters are used to generate the name of the SQL package on the server. + * This property has no effect unless the "extended dynamic" property is set to + * "true". In addition, this property must be set if the "extended dynamic" + * property is set to "true". + */ + PACKAGE("package"), + + /** + * Specifies whether to add newly prepared statements to the SQL package + * specified on the "package" property. This property has no effect unless the + * "extended dynamic" property is set to "true". + */ + PACKAGE_ADD("package add"), + + /** + * Specifies whether to cache a subset of the SQL package information in client + * memory. Caching SQL packages locally reduces the amount of communication to + * the server for prepares and describes. This property has no effect unless the + * "extended dynamic" property is set to "true". + */ + PACKAGE_CACHE("package cache"), + + /** + * Specifies the type of SQL statements to be stored in the SQL package. This + * can be useful to improve the performance of complex join conditions. This + * property has no effect unless the "extended dynamic" property is set to + * "true". + */ + PACKAGE_CRITERIA("package criteria"), + + /** + * Specifies the action to take when SQL package errors occur. When a SQL + * package error occurs, the driver will optionally throw a SQLException or post + * a notice to the Connection, based on the value of this property. This + * property has no effect unless the "extended dynamic" property is set to + * "true". + */ + PACKAGE_ERROR("package error"), + + /** + * Specifies the library for the SQL package. This property has no effect unless + * the "extended dynamic" property is set to "true". + */ + PACKAGE_LIBRARY("package library"), + + /** + * Specifies whether to prefetch data upon executing a SELECT statement. This + * will improve performance when accessing the initial rows in the ResultSet. + */ + PREFETCH("prefetch"), + + /** + * Specifies a QAQQINI library name. Used to specify the library that contains + * the qaqqini file to use. A qaqqini file contains all of the attributes that + * can potentially impact the performance of the Db2® for i database engine. + */ + QAQQINILIB("qaqqinilib"), + + /** + * Specifies the goal the server should use with optimization of queries. This + * setting corresponds to the server's QAQQINI option called OPTIMIZATION_GOAL. + */ + QUERY_OPTIMIZE_GOAL("query optimize goal"), + + /** + * Specifies the mechanism to implement the queryTimeout feature. + */ + QUERY_TIMEOUT_MECHANISM("query timeout mechanism"), + + /** + * Limits the storage used by a query. This property compares the storage limit + * you specify to the estimated storage usage of the query. If the estimated + * storage usage exceeds the specified storage limit, the query is not allowed + * to execute. + */ + QUERY_STORAGE_LIMIT("query storage limit"), + + /** + * Specifies the buffer size used to receive data through the socket connection + * between the front-end driver and the system. + */ + RECEIVE_BUFFER_SIZE("receive buffer size"), + + /** + * Specifies the buffer size used to send data through the socket connection + * between the front-end driver and the system. + */ + SEND_BUFFER_SIZE("send buffer size"), + + /** + * Specifies whether variable-length fields should be compressed. + */ + VARIABLE_FIELD_COMPRESSION("variable field compression"), + + /** + * Specifies how the server sorts records before sending them to the client. + */ + SORT("sort"), + + /** + * Specifies a 3-character language id to use for selection of a sort sequence. + * This property has no effect unless the "sort" property is set to "language". + */ + SORT_LANGUAGE("sort language"), + + /** + * Specifies the library and file name of a sort sequence table stored on the + * server. This property has no effect unless the "sort" property is set to + * "table". + */ + SORT_TABLE("sort table"), + + /** + * Specifies how the server treats case while sorting records. This property has + * no effect unless the "sort" property is set to "language." + */ + SORT_WEIGHT("sort weight"); + + /** + * The JDBC option. + */ + private final String value; + + /** + * Construct a new Option instance. + * @param value The JDBC option. + */ + Option(String value) { + this.value = value; + } + + /** + * Get the JDBC option. + * @return The JDBC option. + */ + public String getValue() { + return value; + } + + /** + * Get the enum JDBC option representation of a string. + * @param value The string representation of the option. + * @return The enum representation of the option. + */ + public static Option fromValue(String value) { + for (Option type : values()) { + if (type.value.equals(value)) { + return type; + } + } + + throw new IllegalArgumentException("Unknown value: " + value); + } +} diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageCcsid.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageCcsid.java index 7bb5908..62842af 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageCcsid.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageCcsid.java @@ -1,20 +1,54 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "package ccsid" JDBC + * option. + */ public enum PackageCcsid { + /** + * UCS-2 encoding. + */ CCSID_1200("1200"), + + /** + * UTF-16 encoding. + */ CCSID_13488("13488"), + + /** + * System encoding. + */ SYSTEM("system"); + /** + * The "package ccsid" value. + */ private final String value; + /** + * Construct a new PackageCcsid instance. + * + * @param value The "package ccsid" value. + */ PackageCcsid(String value) { this.value = value; } + /** + * Get the "package ccsid" value. + * + * @return The "package ccsid" value. + */ public String getValue() { return value; } + /** + * Get the enum "package ccsid" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static PackageCcsid fromValue(String value) { for (PackageCcsid type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageCriteria.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageCriteria.java index 25e4e72..1342c1b 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageCriteria.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageCriteria.java @@ -1,19 +1,49 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "package criteria" + * JDBC option. + */ public enum PackageCriteria { + /** + * Only store SQL statements with parameter markers in the package. + */ DEFAULT("default"), + + /** + * Store all SQL SELECT statements in the package. + */ SELECT("select"); + /** + * The "package criteria" value. + */ private final String value; + /** + * Construct a new PackageCriteria instance. + * + * @param value The "package criteria" value. + */ PackageCriteria(String value) { this.value = value; } + /** + * Get the "package criteria" value. + * + * @return The "package criteria" value. + */ public String getValue() { return value; } + /** + * Get the enum "package criteria" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static PackageCriteria fromValue(String value) { for (PackageCriteria type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageError.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageError.java index 4a60d0e..6237ea5 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageError.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/PackageError.java @@ -1,20 +1,54 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "package error" JDBC + * option. + */ public enum PackageError { + /** + * Exception action. + */ EXCEPTION("exception"), + + /** + * Warning action. + */ WARNING("warning"), + + /** + * No action. + */ NONE("none"); + /** + * The "package error" value. + */ private final String value; + /** + * Construct a new PackageError instance. + * + * @param value The "package error" value. + */ PackageError(String value) { this.value = value; } + /** + * Get the "package error" value. + * + * @return The "package error" value. + */ public String getValue() { return value; } + /** + * Get the enum "package error" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static PackageError fromValue(String value) { for (PackageError type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Property.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Property.java deleted file mode 100644 index 70bead8..0000000 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Property.java +++ /dev/null @@ -1,106 +0,0 @@ -package io.github.mapepire_ibmi.types.jdbcOptions; - -public enum Property { - // Format properties - NAMING("naming"), - DATE_FORMAT("date format"), - DATE_SEPARATOR("date separator"), - DECIMAL_SEPARATOR("decimal separator"), - TIME_FORMAT("time format"), - TIME_SEPARATOR("time separator"), - - // Other properties - FULL_OPEN("full open"), - ACCESS("access"), - AUTOCOMMIT_EXCEPTION("autocommit exception"), - BIDI_STRING_TYPE("bidi string type"), - BIDI_IMPLICIT_REORDERING("bidi implicit reordering"), - BIDI_NUMERIC_ORDERING("bidi numeric ordering"), - DATA_TRUNCATION("data truncation"), - DRIVER("driver"), - ERRORS("errors"), - EXTENDED_METADATA("extended metadata"), - HOLD_INPUT_LOCATORS("hold input locators"), - HOLD_STATEMENTS("hold statements"), - IGNORE_WARNINGS("ignore warnings"), - KEEP_ALIVE("keep alive"), - KEY_RING_NAME("key ring name"), - KEY_RING_PASSWORD("key ring password"), - METADATA_SOURCE("metadata source"), - PROXY_SERVER("proxy server"), - REMARKS("remarks"), - SECONDARY_URL("secondary URL"), - SECURE("secure"), - SERVER_TRACE("server trace"), - THREAD_USED("thread used"), - TOOLBOX_TRACE("toolbox trace"), - TRACE("trace"), - TRANSLATE_BINARY("translate binary"), - TRANSLATE_BOOLEAN("translate boolean"), - - // System Properties - LIBRARIES("libraries"), - AUTO_COMMIT("auto commit"), - CONCURRENT_ACCESS_RESOLUTION("concurrent access resolution"), - CURSOR_HOLD("cursor hold"), - CURSOR_SENSITIVITY("cursor sensitivity"), - DATABASE_NAME("database name"), - DECFLOAT_ROUNDING_MODE("decfloat rounding mode"), - MAXIMUM_PRECISION("maximum precision"), - MAXIMUM_SCALE("maximum scale"), - MINIMUM_DIVIDE_SCALE("minimum divide scale"), - PACKAGE_CCID("package ccsid"), - TRANSACTION_ISOLATION("transaction isolation"), - TRANSLATE_HEX("translate hex"), - TRUE_AUTOCOMMIT("true autocommit"), - XA_LOOSELY_COUPLED_SUPPORT("XA loosely coupled support"), - - // Performance Properties - BIG_DECIMAL("big decimal"), - BLOCK_CRITERIA("block criteria"), - BLOCK_SIZE("block size"), - DATA_COMPRESSION("data compression"), - EXTENDED_DYNAMIC("extended dynamic"), - LAZY_CLOSE("lazy close"), - LOB_THRESHOLD("lob threshold"), - MAXIMUM_BLOCKED_INPUT_ROWS("maximum blocked input rows"), - PACKAGE("package"), - PACKAGE_ADD("package add"), - PACKAGE_CACHE("package cache"), - PACKAGE_CRITERIA("package criteria"), - PACKAGE_ERROR("package error"), - PACKAGE_LIBRARY("package library"), - PREFETCH("prefetch"), - QAQQINILIB("qaqqinilib"), - QUERY_OPTIMIZE_GOAL("query optimize goal"), - QUERY_TIMEOUT_MECHANISM("query timeout mechanism"), - QUERY_STORAGE_LIMIT("query storage limit"), - RECEIVE_BUFFER_SIZE("receive buffer size"), - SEND_BUFFER_SIZE("send buffer size"), - VARIABLE_FIELD_COMPRESSION("variable field compression"), - - // Sort Properties - SORT("sort"), - SORT_LANGUAGE("sort language"), - SORT_TABLE("sort table"), - SORT_WEIGHT("sort weight"); - - private final String value; - - Property(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - public static Property fromValue(String value) { - for (Property type : values()) { - if (type.value.equals(value)) { - return type; - } - } - throw new IllegalArgumentException("Unknown value: " + value); - } -} diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/QueryOptimizeGoal.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/QueryOptimizeGoal.java index 8d10a45..2574fe5 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/QueryOptimizeGoal.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/QueryOptimizeGoal.java @@ -1,20 +1,56 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "query optimize goal" + * JDBC option. + */ public enum QueryOptimizeGoal { + /** + * Optimize query for first block of data (*FIRSTIO) when extended dynamic + * packages are used; Optimize query for entire result set (*ALLIO) when + * packages are not used. + */ GOAL_0("0"), + + /** + * Optimize query for first block of data (*FIRSTIO). + */ GOAL_1("1"), + + /** + * Optimize query for entire result set (*ALLIO). + */ GOAL_2("2"); + /** + * The "query optimize goal" value. + */ private final String value; + /** + * Construct a new QueryOptimizeGoal instance. + * + * @param value The "query optimize goal" value. + */ QueryOptimizeGoal(String value) { this.value = value; } + /** + * Get the "query optimize goal" value. + * + * @return The "query optimize goal" value. + */ public String getValue() { return value; } + /** + * Get the enum "query optimize goal" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static QueryOptimizeGoal fromValue(String value) { for (QueryOptimizeGoal type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/QueryTimeoutMechanism.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/QueryTimeoutMechanism.java index 1cf8a95..f61ab41 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/QueryTimeoutMechanism.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/QueryTimeoutMechanism.java @@ -1,19 +1,51 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "query timeout + * mechanism" JDBC option. + */ public enum QueryTimeoutMechanism { + /** + * The queryTimeout feature uses the "QQRYTIMLMT" feature of the database + * engine. + */ QQRYTIMLMT("qqrytimlmt"), + + /** + * The queryTimeout feature uses a database CANCEL request to cancel a running + * SQL statement after the specified timeout expires. + */ CANCEL("cancel"); + /** + * The "query timeout mechanism" value. + */ private final String value; + /** + * Construct a new QueryTimeoutMechanism instance. + * + * @param value The "query timeout mechanism" value. + */ QueryTimeoutMechanism(String value) { this.value = value; } + /** + * Get the "query timeout mechanism" value. + * + * @return The "query timeout mechanism" value. + */ public String getValue() { return value; } + /** + * Get the enum "query timeout mechanism" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static QueryTimeoutMechanism fromValue(String value) { for (QueryTimeoutMechanism type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Remarks.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Remarks.java index abde571..fce7ab1 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Remarks.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Remarks.java @@ -1,19 +1,48 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "remarks" JDBC option. + */ public enum Remarks { + /** + * SQL object comment. + */ SQL("sql"), + + /** + * IBM i object description. + */ SYSTEM("system"); + /** + * The "remarks" value. + */ private final String value; + /** + * Construct a new Remarks instance. + * + * @param value The "remarks" value. + */ Remarks(String value) { this.value = value; } + /** + * Get the "remarks" value. + * + * @return The "remarks" value. + */ public String getValue() { return value; } + /** + * Get the enum "remarks" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static Remarks fromValue(String value) { for (Remarks type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ServerTrace.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ServerTrace.java index 8000a21..575d571 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ServerTrace.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ServerTrace.java @@ -1,24 +1,74 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "server trace" JDBC + * option. + */ public enum ServerTrace { + /** + * Trace is not active. + */ TRACE_0("0"), + + /** + * Start the database monitor on the JDBC server job. + */ TRACE_2("2"), + + /** + * Start debug on the JDBC server job. + */ TRACE_4("4"), + + /** + * Save the job log when the JDBC server job ends. + */ TRACE_8("8"), + + /** + * Start job trace on the JDBC server job. + */ TRACE_16("16"), + + /** + * Save SQL information. + */ TRACE_32("32"), + + /** + * Supports the activation of database host server tracing. + */ TRACE_64("64"); + /** + * The "server trace" value. + */ private final String value; + /** + * Construct a new ServerTrace instance. + * + * @param value The "server trace" value. + */ ServerTrace(String value) { this.value = value; } + /** + * Get the "server trace" value. + * + * @return The "server trace" value. + */ public String getValue() { return value; } + /** + * Get the enum "server trace" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static ServerTrace fromValue(String value) { for (ServerTrace type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Sort.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Sort.java index d0ef51c..451f402 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Sort.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/Sort.java @@ -1,20 +1,53 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "sort" JDBC option. + */ public enum Sort { + /** + * Base the sort on hexadecimal values. + */ HEX("hex"), + + /** + * Base the sort on the language set in the "sort language" property. + */ LANGUAGE("language"), + + /** + * Base the sort on the sort sequence table set in the "sort table" property. + */ TABLE("table"); + /** + * The "sort" value. + */ private final String value; + /** + * Construct a new Sort instance. + * + * @param value The "sort" value. + */ Sort(String value) { this.value = value; } + /** + * Get the "sort" value. + * + * @return The "sort" value. + */ public String getValue() { return value; } + /** + * Get the enum "sort" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static Sort fromValue(String value) { for (Sort type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/SortWeight.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/SortWeight.java index 2da34d4..664dcf1 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/SortWeight.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/SortWeight.java @@ -1,19 +1,49 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "sort weight" JDBC + * option. + */ public enum SortWeight { + /** + * Uppercase and lowercase characters sort as the same character. + */ SHARED("shared"), + + /** + * Uppercase and lowercase characters sort as different characters. + */ UNIQUE("unique"); + /** + * The "sort weight" value. + */ private final String value; + /** + * Construct a new SortWeight instance. + * + * @param value The "sort weight" value. + */ SortWeight(String value) { this.value = value; } + /** + * Get the "sort weight" value. + * + * @return The "sort weight" value. + */ public String getValue() { return value; } + /** + * Get the enum "sort weight" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static SortWeight fromValue(String value) { for (SortWeight type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TimeFormat.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TimeFormat.java index fb17e3f..d292f73 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TimeFormat.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TimeFormat.java @@ -1,22 +1,64 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "time format" JDBC + * option. + */ public enum TimeFormat { + /** + * hms time format. + */ HMS("hms"), + + /** + * usa time format. + */ USA("usa"), + + /** + * iso time format. + */ ISO("iso"), + + /** + * eur time format. + */ EUR("eur"), + + /** + * jis time format. + */ JIS("jis"); + /** + * The "time format" value. + */ private final String value; + /** + * Construct a new TimeFormat instance. + * + * @param value The "time format" value. + */ TimeFormat(String value) { this.value = value; } + /** + * Get the "time format" value. + * + * @return The "time format" value. + */ public String getValue() { return value; } + /** + * Get the enum "time format" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static TimeFormat fromValue(String value) { for (TimeFormat type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TimeSeparator.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TimeSeparator.java index 55cd544..063948a 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TimeSeparator.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TimeSeparator.java @@ -1,21 +1,59 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "time separator" JDBC + * option. + */ public enum TimeSeparator { + /** + * Colon time separator. + */ COLON(":"), + + /** + * period time separator. + */ DOT("."), + + /** + * Comma time separator. + */ COMMA(","), + + /** + * Space time separator. + */ B("b"); + /** + * The "time separator" value. + */ private final String value; + /** + * Construct a new TimeSeparator instance. + * + * @param value The "time separator" value. + */ TimeSeparator(String value) { this.value = value; } + /** + * Get the "time separator" value. + * + * @return The "time separator" value. + */ public String getValue() { return value; } + /** + * Get the enum "time separator" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static TimeSeparator fromValue(String value) { for (TimeSeparator type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ToolboxTrace.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ToolboxTrace.java index 94b8842..eb92fe7 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ToolboxTrace.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/ToolboxTrace.java @@ -1,30 +1,105 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "toolbox trace" JDBC + * option. + */ public enum ToolboxTrace { + /** + * Empty. + */ EMPTY(""), + + /** + * None. + */ NONE("NONE"), + + /** + * Log data flow between the local host and the remote system. + */ DATASTREAM("datastream"), + + /** + * Log object state information. + */ DIAGNOSTIC("diagnostic"), + + /** + * Log errors that cause an exception. + */ ERROR("error"), + + /** + * Log errors that are recoverable. + */ WARNING("warning"), + + /** + * Log character set conversions between Unicode and native code pages. + */ CONVERSION("conversion"), + + /** + * Log jdbc information. + */ JDBC("jdbc"), + + /** + * Used to determine how PCML interprets the data that is sent to and from the + * server. + */ PCML("pcml"), + + /** + * Log all categories. + */ ALL("all"), + + /** + * Log data flow between the client and the proxy server. + */ PROXY("proxy"), + + /** + * Log thread information. + */ THREAD("thread"), + + /** + * Used to track the flow of control through the code. + */ INFORMATION("information"); + /** + * The "toolbox trace" value. + */ private final String value; + /** + * Construct a new ToolboxTrace instance. + * + * @param value The "toolbox trace" value. + */ ToolboxTrace(String value) { this.value = value; } + /** + * Get the "toolbox trace" value. + * + * @return The "toolbox trace" value. + */ public String getValue() { return value; } + /** + * Get the enum "toolbox trace" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static ToolboxTrace fromValue(String value) { for (ToolboxTrace type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TransactionIsolation.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TransactionIsolation.java index b34b100..8aa8234 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TransactionIsolation.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TransactionIsolation.java @@ -1,22 +1,64 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "transaction + * isolation" JDBC option. + */ public enum TransactionIsolation { + /** + * None transaction isolation. + */ NONE("none"), + + /** + * Read uncommitted transaction isolation. + */ READ_UNCOMMITTED("read uncommitted"), + + /** + * Read committed transaction isolation. + */ READ_COMMITTED("read committed"), + + /** + * Repeatable read transaction isolation. + */ REPEATABLE_READ("repeatable read"), + + /** + * Serializable transaction isolation. + */ SERIALIZABLE("serializable"); + /** + * The "transaction isolation" value. + */ private final String value; + /** + * Construct a new TransactionIsolation instance. + * + * @param value The "transaction isolation" value. + */ TransactionIsolation(String value) { this.value = value; } + /** + * Get the "transaction isolation" value. + * + * @return The "transaction isolation" value. + */ public String getValue() { return value; } + /** + * Get the enum "transaction isolation" value representation of a string. + * + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static TransactionIsolation fromValue(String value) { for (TransactionIsolation type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TranslateHex.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TranslateHex.java index 85d38fc..7c02163 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TranslateHex.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/TranslateHex.java @@ -1,19 +1,46 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "translate hex" JDBC + * option. + */ public enum TranslateHex { + /** + * Interpret hexadecimal literals as character data. + */ CHARACTER("character"), + + /** + * Interpret hexadecimal literals as binary data. + */ BINARY("binary"); + /** + * The "translate hex" value. + */ private final String value; + /** + * Construct a new TranslateHex instance. + * @param value The "translate hex" value. + */ TranslateHex(String value) { this.value = value; } + /** + * Get the "translate hex" value. + * @return The "translate hex" value. + */ public String getValue() { return value; } + /** + * Get the enum "translate hex" value representation of a string. + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static TranslateHex fromValue(String value) { for (TranslateHex type : values()) { if (type.value.equals(value)) { diff --git a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/XALooselyCoupledSupport.java b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/XALooselyCoupledSupport.java index 7dd933d..b32b169 100644 --- a/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/XALooselyCoupledSupport.java +++ b/src/main/java/io/github/mapepire_ibmi/types/jdbcOptions/XALooselyCoupledSupport.java @@ -1,19 +1,46 @@ package io.github.mapepire_ibmi.types.jdbcOptions; +/** + * Enum representing the possible types of values for the "XA loosely coupled + * support" JDBC option. + */ public enum XALooselyCoupledSupport { + /** + * Locks cannot be shared. + */ SUPPORT_0("0"), + + /** + * Locks can be shared. + */ SUPPORT_1("1"); + /** + * The "XA loosely coupled support" value. + */ private final String value; + /** + * Construct a new XALooselyCoupledSupport instance. + * @param value The "XA loosely coupled support" value. + */ XALooselyCoupledSupport(String value) { this.value = value; } + /** + * Get the "XA loosely coupled support" value. + * @return The "XA loosely coupled support" value. + */ public String getValue() { return value; } + /** + * Get the enum "XA loosely coupled support" value representation of a string. + * @param value The string representation of the option. + * @return The enum representation of the option. + */ public static XALooselyCoupledSupport fromValue(String value) { for (XALooselyCoupledSupport type : values()) { if (type.value.equals(value)) { diff --git a/src/test/java/io/github/mapepire_ibmi/MapepireTest.java b/src/test/java/io/github/mapepire_ibmi/MapepireTest.java index 8c7e04c..fc31ff2 100644 --- a/src/test/java/io/github/mapepire_ibmi/MapepireTest.java +++ b/src/test/java/io/github/mapepire_ibmi/MapepireTest.java @@ -1,7 +1,5 @@ package io.github.mapepire_ibmi; -import io.github.mapepire_ibmi.types.DaemonServer; - import java.io.InputStream; import java.io.IOException; import java.util.Arrays; @@ -15,6 +13,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; +import io.github.mapepire_ibmi.types.DaemonServer; + @Timeout(5) class MapepireTest { private static final String CONFIG_FILE = "config.properties"; diff --git a/src/test/java/io/github/mapepire_ibmi/PoolTest.java b/src/test/java/io/github/mapepire_ibmi/PoolTest.java index 70fc7a1..1bffa2e 100644 --- a/src/test/java/io/github/mapepire_ibmi/PoolTest.java +++ b/src/test/java/io/github/mapepire_ibmi/PoolTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; +import io.github.mapepire_ibmi.types.PoolOptions; import io.github.mapepire_ibmi.types.QueryResult; class PoolTest extends MapepireTest { diff --git a/src/test/java/io/github/mapepire_ibmi/SimpleTest.java b/src/test/java/io/github/mapepire_ibmi/SimpleTest.java index 7529542..f4b9659 100644 --- a/src/test/java/io/github/mapepire_ibmi/SimpleTest.java +++ b/src/test/java/io/github/mapepire_ibmi/SimpleTest.java @@ -1,11 +1,13 @@ package io.github.mapepire_ibmi; -import io.github.mapepire_ibmi.types.QueryResult; - import java.util.concurrent.CompletableFuture; import org.junit.jupiter.api.Test; +import io.github.mapepire_ibmi.Query; +import io.github.mapepire_ibmi.SqlJob; +import io.github.mapepire_ibmi.types.QueryResult; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue;