Add close connection

This commit is contained in:
Sambo Chea 2023-03-27 09:40:40 +07:00
parent fe66992d05
commit 94098a10f3
Signed by: sombochea
GPG Key ID: 3C7CF22A05D95490
3 changed files with 26 additions and 4 deletions

View File

@ -3,12 +3,12 @@ plugins {
}
group 'com.cubetiqs'
version = '1.0.0'
version = '1.0.1'
// java.sourceCompatibility = JavaVersion.VERSION_1_8
java.sourceCompatibility = JavaVersion.VERSION_17
dependencies {
testRuntimeOnly("mysql:mysql-connector-java:8.0.30")
testRuntimeOnly('mysql:mysql-connector-java:8.0.32')
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
}

View File

@ -116,9 +116,29 @@ public final class JdbcDataFactory {
public boolean isConnected() {
try {
return !queryManager.getManager().getConnection().isClosed();
return !getManager().getConnection().isClosed();
} catch (SQLException e) {
return false;
}
}
public JdbcDataQuery getDataQuery() {
return queryManager;
}
public IDataManager getManager() {
return queryManager.getManager();
}
public void close() throws SQLException {
getManager().getConnection().close();
}
public void tryClose() {
try {
close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}

View File

@ -21,5 +21,7 @@ public class ConnectionTests {
IExecuteResult<List<Object>> result = factory.queryForList("select * from um");
System.out.println(result.getData());
factory.tryClose();
}
}