Add close connection
This commit is contained in:
parent
fe66992d05
commit
94098a10f3
@ -3,12 +3,12 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'com.cubetiqs'
|
group 'com.cubetiqs'
|
||||||
version = '1.0.0'
|
version = '1.0.1'
|
||||||
|
|
||||||
// java.sourceCompatibility = JavaVersion.VERSION_1_8
|
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
dependencies {
|
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'
|
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,9 +116,29 @@ public final class JdbcDataFactory {
|
|||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
try {
|
try {
|
||||||
return !queryManager.getManager().getConnection().isClosed();
|
return !getManager().getConnection().isClosed();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return false;
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,7 @@ public class ConnectionTests {
|
|||||||
|
|
||||||
IExecuteResult<List<Object>> result = factory.queryForList("select * from um");
|
IExecuteResult<List<Object>> result = factory.queryForList("select * from um");
|
||||||
System.out.println(result.getData());
|
System.out.println(result.getData());
|
||||||
|
|
||||||
|
factory.tryClose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user