diff --git a/modules/cases/build.gradle b/modules/cases/build.gradle index 837ddb4..caf4db9 100644 --- a/modules/cases/build.gradle +++ b/modules/cases/build.gradle @@ -41,3 +41,16 @@ tasks.register('runMS', JavaExec) { systemProperty 'org.slf4j.simpleLogger.showShortLogName', 'true' systemProperty 'org.slf4j.simpleLogger.levelInBrackets', 'true' } + + +tasks.register('run345', JavaExec) { + classpath = sourceSets.main.runtimeClasspath + mainClass = 'com.tsurugidb.tsubakuro.examples.sesscionClose.Main' + + systemProperty 'tsurugi.dbname', findProperty('tsurugi.dbname') ?: 'ipc:tsurugi' + + systemProperty 'org.slf4j.simpleLogger.defaultLogLevel', findProperty('loglevel') ?: 'info' + systemProperty 'org.slf4j.simpleLogger.showThreadName', 'false' + systemProperty 'org.slf4j.simpleLogger.showShortLogName', 'true' + systemProperty 'org.slf4j.simpleLogger.levelInBrackets', 'true' +} diff --git a/modules/cases/src/main/java/com/tsurugidb/tsubakuro/examples/sesscionClose/Main.java b/modules/cases/src/main/java/com/tsurugidb/tsubakuro/examples/sesscionClose/Main.java new file mode 100644 index 0000000..fa93d11 --- /dev/null +++ b/modules/cases/src/main/java/com/tsurugidb/tsubakuro/examples/sesscionClose/Main.java @@ -0,0 +1,40 @@ +package com.tsurugidb.tsubakuro.examples.sesscionClose; + +import com.tsurugidb.tsubakuro.exception.ServerException; +import com.tsurugidb.tsubakuro.common.Session; +import com.tsurugidb.tsubakuro.common.SessionBuilder; +import com.tsurugidb.tsubakuro.sql.SqlClient; + + +public final class Main { + private static String url = System.getProperty("tsurugi.dbname"); + + public static void main(String[] args) { + for (int i = 0; i < 50; i++) { + try { + Session session = SessionBuilder.connect(url).create(); + SqlClient sqlClient = SqlClient.attach(session); + var futureTransaction = sqlClient.createTransaction(); + + session.close(); + } catch (Exception e) { + System.out.println(e); + } + } + System.out.println("================"); + for (int i = 0; i < 50; i++) { + try { + Session session = SessionBuilder.connect(url).create(); + SqlClient sqlClient = SqlClient.attach(session); + var futureTransaction = sqlClient.createTransaction().get(); + + session.close(); + } catch (Exception e) { + System.out.println(e); + } + } + } + + private Main(String[] args) { + } +}