An open API service indexing awesome lists of open source software.

https://github.com/labelzoom/labelzoom-moca-client-java

MOCA client for Java
https://github.com/labelzoom/labelzoom-moca-client-java

blue-yonder blueyonder jda moca redprairie

Last synced: 6 months ago
JSON representation

MOCA client for Java

Awesome Lists containing this project

README

          

![LabelZoom Logo](docs/LabelZoom_Logo_f_400px.png)

# labelzoom-moca-client-java

[![Build Status](https://github.com/labelzoom/labelzoom-moca-client-java/actions/workflows/gradle-build.yml/badge.svg?branch=main)](https://github.com/labelzoom/labelzoom-moca-client-java/actions?query=branch%3Amain)
[![Release](https://img.shields.io/github/release/labelzoom/labelzoom-moca-client-java.svg?style=flat-square)](https://github.com/labelzoom/labelzoom-moca-client-java/releases)
[![codecov](https://codecov.io/gh/labelzoom/labelzoom-moca-client-java/graph/badge.svg?token=R1Z1Q2W4EF)](https://codecov.io/gh/labelzoom/labelzoom-moca-client-java)

MOCA client for Java, sponsored by [LabelZoom](https://www.labelzoom.net).

## Installation

### Gradle
#### Step 1
Add a new `maven` closure to your `repositories` section that points to this repository.
```groovy
repositories {
mavenCentral() // You probably already have this
maven {
url = uri('https://maven.pkg.github.com/labelzoom/labelzoom-moca-client-java')
credentials {
username = project.findProperty('gpr.user') ?: System.getenv('GITHUB_ACTOR') // your GitHub username goes here
password = project.findProperty('gpr.key') ?: System.getenv('GITHUB_TOKEN') // your GitHub PAT (Personal Access Token) goes here
}
}
}
```

#### Step 2
Add the dependency to your `implementation` dependencies:
```groovy
dependencies {
implementation 'com.labelzoom:labelzoom-moca-client-java:1.0.2'
}
```

### Maven
TODO

## How To Use
See [tests](src/test) for more examples.

### Nested _try-with-resources_
```java
try (final MocaConnection conn = new HttpMocaConnection(url, userId, password))
{
try (final ResultSet res = conn.execute("publish data where message = 'Hello World!'"))
{
res.next();
System.out.println("Message: " + res.getString("message"));
}
}
catch (final SQLException | IOException e)
{
e.printStackTrace();
}
```

### Single _try-with-resources_ with multiple resources
```java
try (final MocaConnection conn = new HttpMocaConnection(url, userId, password);
final ResultSet res = conn.execute("publish data where message = 'Hello World!'"))
{
res.next();
System.out.println("Message: " + res.getString("message"));
}
catch (final SQLException | IOException e)
{
e.printStackTrace();
}
```