Skip to content

Commit 0795f4c

Browse files
committed
update examples
1 parent d642db5 commit 0795f4c

File tree

8 files changed

+78
-372
lines changed

8 files changed

+78
-372
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@
2323
hs_err_pid*
2424

2525
.idea/
26+
build/

build.gradle

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java'
3-
id 'org.jetbrains.kotlin.jvm' version '1.2.71'
3+
id 'org.jetbrains.kotlin.jvm' version '1.8.22'
44
}
55

66
group 'com.github.jasync-sql'
@@ -10,18 +10,16 @@ sourceCompatibility = 1.8
1010

1111
repositories {
1212
mavenCentral()
13-
jcenter()
1413
}
1514

1615
dependencies {
17-
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.71"
18-
compile 'com.github.jasync-sql:jasync-mysql:0.8.31'
19-
compile "log4j:log4j:1.2.17"
20-
compile "org.slf4j:slf4j-log4j12:1.7.25"
21-
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.25.0'
22-
compile 'org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:0.25.0'
23-
testCompile group: 'junit', name: 'junit', version: '4.12'
24-
compile 'io.github.microutils:kotlin-logging:1.6.10'
16+
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.22"
17+
implementation 'com.github.jasync-sql:jasync-mysql:2.2.2'
18+
implementation "org.apache.logging.log4j:log4j-core:2.20.0"
19+
implementation "org.slf4j:slf4j-log4j12:1.7.25"
20+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4'
21+
testImplementation group: 'junit', name: 'junit', version: '4.12'
22+
implementation 'io.github.oshai:kotlin-logging-jvm:5.0.2'
2523
}
2624

2725
compileKotlin {
@@ -30,8 +28,4 @@ compileKotlin {
3028
compileTestKotlin {
3129
kotlinOptions.jvmTarget = "1.8"
3230
}
33-
kotlin {
34-
experimental {
35-
coroutines "enable"
36-
}
37-
}
31+

gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 6 deletions
This file was deleted.

gradlew

Lines changed: 0 additions & 172 deletions
This file was deleted.

gradlew.bat

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/main/java/com/github/jasync/mysql/example/MainJava.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
package com.github.jasync.mysql.example;
22

3-
import com.github.jasync.sql.db.Configuration;
43
import com.github.jasync.sql.db.Connection;
54
import com.github.jasync.sql.db.QueryResult;
65
import com.github.jasync.sql.db.general.ArrayRowData;
7-
import com.github.jasync.sql.db.mysql.pool.MySQLConnectionFactory;
6+
import com.github.jasync.sql.db.mysql.MySQLConnection;
7+
import com.github.jasync.sql.db.mysql.MySQLConnectionBuilder;
88
import com.github.jasync.sql.db.pool.ConnectionPool;
9-
import com.github.jasync.sql.db.pool.PoolConfiguration;
109
import org.slf4j.Logger;
1110
import org.slf4j.LoggerFactory;
1211

1312
import java.util.Arrays;
1413
import java.util.concurrent.CompletableFuture;
1514
import java.util.concurrent.ExecutionException;
16-
import java.util.concurrent.TimeUnit;
1715

1816
public class MainJava {
1917

@@ -27,21 +25,15 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc
2725
logger.debug("starting debug");
2826
logger.trace("starting trace");
2927

30-
PoolConfiguration poolConfiguration = new PoolConfiguration(
31-
100, // maxObjects
32-
TimeUnit.MINUTES.toMillis(15), // maxIdle
33-
10_000, // maxQueueSize
34-
TimeUnit.SECONDS.toMillis(30) // validationInterval
28+
String host = "host.com";
29+
int port = 3306;
30+
String database = "schema";
31+
String username = "username";
32+
String password = "password";
33+
ConnectionPool<MySQLConnection> pool = MySQLConnectionBuilder.createConnectionPool(
34+
"jdbc:mysql://$host:$port/$database?user=$username&password=$password"
3535
);
36-
Connection connection = new ConnectionPool<>(
37-
new MySQLConnectionFactory(new Configuration(
38-
"username",
39-
"host.com",
40-
3306,
41-
"password",
42-
"schema"
43-
)), poolConfiguration);
44-
connection.connect().get();
36+
Connection connection = pool.connect().get();
4537
CompletableFuture<QueryResult> future = connection.sendPreparedStatement("select * from table limit 2");
4638
QueryResult queryResult = future.get();
4739
System.out.println(Arrays.toString(((ArrayRowData) (queryResult.getRows().get(0))).getColumns()));

0 commit comments

Comments
 (0)