提交 91eef920 authored 作者: taojinlong's avatar taojinlong

fix: 处理连接池为空的情况

上级 3733b869
...@@ -35,8 +35,10 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -35,8 +35,10 @@ public class JdbcProvider extends DatasourceProvider {
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); throw new Exception("ERROR:" + e.getMessage(), e);
} finally { } finally {
if(connection != null){
connection.close(); connection.close();
} }
}
return list; return list;
} }
...@@ -52,9 +54,11 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -52,9 +54,11 @@ public class JdbcProvider extends DatasourceProvider {
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); throw new Exception("ERROR:" + e.getMessage(), e);
} finally { } finally {
if(connection != null){
connection.close(); connection.close();
} }
} }
}
@Override @Override
public List<String[]> fetchResult(DatasourceRequest datasourceRequest) throws Exception { public List<String[]> fetchResult(DatasourceRequest datasourceRequest) throws Exception {
...@@ -70,9 +74,11 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -70,9 +74,11 @@ public class JdbcProvider extends DatasourceProvider {
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); throw new Exception("ERROR:" + e.getMessage(), e);
} finally { } finally {
if(connection != null){
connection.close(); connection.close();
} }
} }
}
private List<String[]> fetchResult(ResultSet rs) throws Exception { private List<String[]> fetchResult(ResultSet rs) throws Exception {
List<String[]> list = new LinkedList<>(); List<String[]> list = new LinkedList<>();
...@@ -110,9 +116,11 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -110,9 +116,11 @@ public class JdbcProvider extends DatasourceProvider {
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); throw new Exception("ERROR:" + e.getMessage(), e);
} finally { } finally {
if(connection != null){
connection.close(); connection.close();
} }
} }
}
@Override @Override
public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception { public Map<String, List> fetchResultAndField(DatasourceRequest datasourceRequest) throws Exception {
...@@ -135,9 +143,11 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -135,9 +143,11 @@ public class JdbcProvider extends DatasourceProvider {
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); throw new Exception("ERROR:" + e.getMessage(), e);
} finally { } finally {
if(connection != null){
connection.close(); connection.close();
} }
} }
}
private List<TableFiled> fetchResultField(ResultSet rs) throws Exception { private List<TableFiled> fetchResultField(ResultSet rs) throws Exception {
List<TableFiled> fieldList = new ArrayList<>(); List<TableFiled> fieldList = new ArrayList<>();
...@@ -175,9 +185,11 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -175,9 +185,11 @@ public class JdbcProvider extends DatasourceProvider {
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR: " + e.getMessage(), e); throw new Exception("ERROR: " + e.getMessage(), e);
} finally { } finally {
if(con != null){
con.close(); con.close();
} }
} }
}
@Override @Override
public List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception { public List<TableFiled> getTableFileds(DatasourceRequest datasourceRequest) throws Exception {
...@@ -214,8 +226,10 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -214,8 +226,10 @@ public class JdbcProvider extends DatasourceProvider {
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); throw new Exception("ERROR:" + e.getMessage(), e);
} finally { } finally {
if(connection != null){
connection.close(); connection.close();
} }
}
return list; return list;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论