Skip to content

Instantly share code, notes, and snippets.

@tsegismont
Last active July 4, 2022 19:53
Show Gist options
  • Save tsegismont/3f6f00ca3052ef11f941c93728a01f80 to your computer and use it in GitHub Desktop.
Save tsegismont/3f6f00ca3052ef11f941c93728a01f80 to your computer and use it in GitHub Desktop.
Vert.x Reactive Oracle Client with Oracle Cloud
package com.example.oracle_cloud_test;
import io.vertx.core.AbstractVerticle;
import io.vertx.oracleclient.OracleConnectOptions;
import io.vertx.oracleclient.OraclePool;
import io.vertx.sqlclient.PoolOptions;
import io.vertx.sqlclient.Row;
public class MainVerticle extends AbstractVerticle {
@Override
public void start() throws Exception {
// Connection URI
String connectionUri = "oracle:thin:@db20220704211630_tpurgent?TNS_ADMIN=/home/tsegismont/Temp/oracle-cloud-test/wallet/";
// Connect options
OracleConnectOptions connectOptions = OracleConnectOptions.fromUri(connectionUri)
.setUser("ADMIN")
.setPassword("SuperSecret");
// Pool Options
PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
// Create the pool from the connection URI
OraclePool pool = OraclePool.pool(vertx, connectOptions, poolOptions);
pool
.query("SELECT * FROM v$instance")
.execute(ar -> {
if (ar.succeeded()) {
Row row = ar.result().iterator().next();
System.out.println("row = " + row.toJson().encodePrettily());
} else {
System.out.println("Failure: " + ar.cause().getMessage());
}
});
}
}
Jul 04, 2022 9:43:07 PM io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer
INFO: Succeeded in deploying verticle
row = {
"INSTANCE_NUMBER" : 1,
"INSTANCE_NAME" : "fesd1pod1",
"HOST_NAME" : null,
"VERSION" : "19.0.0.0.0",
"VERSION_LEGACY" : "19.0.0.0.0",
"VERSION_FULL" : "19.16.0.1.0",
"STARTUP_TIME" : "2022-06-24T18:33:02",
"STATUS" : "OPEN",
"PARALLEL" : "YES",
"THREAD#" : 1,
"ARCHIVER" : "STARTED",
"LOG_SWITCH_WAIT" : null,
"LOGINS" : "ALLOWED",
"SHUTDOWN_PENDING" : "NO",
"DATABASE_STATUS" : "ACTIVE",
"INSTANCE_ROLE" : "PRIMARY_INSTANCE",
"ACTIVE_STATE" : "NORMAL",
"BLOCKED" : "NO",
"CON_ID" : 0,
"INSTANCE_MODE" : "REGULAR",
"EDITION" : "EE",
"FAMILY" : null,
"DATABASE_TYPE" : "RAC"
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>oracle-cloud-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>
<vertx.version>4.3.2-SNAPSHOT</vertx.version>
<junit-jupiter.version>5.7.0</junit-jupiter.version>
<main.verticle>com.example.oracle_cloud_test.MainVerticle</main.verticle>
<launcher.class>io.vertx.core.Launcher</launcher.class>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>${vertx.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc-bom</artifactId>
<version>21.6.0.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-oracle-client</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ucp</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.security</groupId>
<artifactId>oraclepki</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.security</groupId>
<artifactId>osdt_core</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.security</groupId>
<artifactId>osdt_cert</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.ha</groupId>
<artifactId>ons</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.ha</groupId>
<artifactId>simplefan</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>${launcher.class}</Main-Class>
<Main-Verticle>${main.verticle}</Main-Verticle>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-fat.jar
</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<configuration>
<mainClass>io.vertx.core.Launcher</mainClass>
<arguments>
<argument>run</argument>
<argument>${main.verticle}</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>sonatype-oss-snapshots</id>
<name>Sonatype OSSRH Snapshots</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
<layout>default</layout>
<releases>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment