You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/guides/Usage/java.md
+81-2Lines changed: 81 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,14 @@ Using DB2 for IBM i with Java is now easy with the help of the `mapepire-java` c
23
23
24
24
## Specifying the `mapepire-server` Instance for the Connection
25
25
26
-
The location and port of the `mapepire-server` instance as well as the credentials for IBM i Db2 can be specified in a `config.properties` file. Copy the [`config.properties.sample`](https://github.com/Mapepire-IBMi/samples/blob/main/java/simple-app/src/main/resources/config.properties.sample) file from the [simple-app](https://github.com/Mapepire-IBMi/samples/tree/main/java/simple-app) demo project to `config.properties` and fill in the credentials.
26
+
The location and port of the `mapepire-server` instance as well as the credentials for IBM i Db2 can be specified in a `config.properties` file. Copy the [`config.properties.sample`](https://github.com/Mapepire-IBMi/samples/blob/main/java/simple-app/src/main/resources/config.properties.sample) file from the [simple-app](https://github.com/Mapepire-IBMi/samples/tree/main/java/simple-app) demo project to `config.properties` and fill in the credentials. Note that the `IBMI_PORT` is set to where the mapepire server is running.
27
+
28
+
```ini
29
+
IBMI_HOST=host.somewhere.com
30
+
IBMI_USER=JIMBOB
31
+
IBMI_PASSWORD=letMeInNow
32
+
IBMI_PORT=8076
33
+
```
27
34
28
35
The following function can be used to construct a `DaemonServer` object with the credentials you just specified. This object will be passed to a `SqlJob` or `Pool` object.
29
36
@@ -64,11 +71,52 @@ job.connect(creds).get();
64
71
65
72
// Initialize and execute query
66
73
Query query = job.query("SELECT * FROM SAMPLE.DEPARTMENT");
67
-
QueryResult<Object> result = query.execute().get();
74
+
QueryResult<Object> result = query.execute(3).get();
Query query = job.query("INSERT INTO SAMPLE.EMPLOYEE VALUES (?, ?)", options);
144
+
QueryResult<Object> result = query.execute().get();
145
+
```
146
+
84
147
### CL Commands
85
148
86
149
CL commands can be easily run by setting the `isClCommand` option to be `true` on the `QueryOptions` object or by directly using the `clCommand` API on a job:
For any `SqlJob` object, you can check its status via its [JobStatus](https://github.com/Mapepire-IBMi/mapepire-java/blob/main/src/main/java/io/github/mapepire_ibmi/types/JobStatus.java):
214
+
215
+
```java
216
+
SqlJob job =newSqlJob();
217
+
JobStatus status = job.getStatus();
218
+
```
219
+
220
+
Similarily, you can check the state of a query via its [QueryState](https://github.com/Mapepire-IBMi/mapepire-java/blob/main/src/main/java/io/github/mapepire_ibmi/types/QueryState.java):
221
+
222
+
```java
223
+
Query query = job.query("SELECT * FROM SAMPLE.DEPARTMENT");
224
+
QueryState state = query.getState();
225
+
```
226
+
148
227
## Exception Handling
149
228
150
229
The APIs provided by the client SDK can throw various checked exceptions which should be caught and handled. In particular, the following exceptions communicate important error information from either the `mapepire-server` component or the client SDK itself:
0 commit comments