Mercurial > hg > monetdb-java
comparison src/main/java/nl/cwi/monetdb/jdbc/MonetDatabaseMetaData.java @ 300:8cc3b51d1984
Add a utility method to close objects ignoring any possible SQLExceptions thrown.
Use it in finally clauses to reduce object code.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 15 Aug 2019 16:57:25 +0200 (2019-08-15) |
parents | 1f0324072b0c |
children | 1b6c514106ce |
comparison
equal
deleted
inserted
replaced
299:1f0324072b0c | 300:8cc3b51d1984 |
---|---|
67 } | 67 } |
68 } | 68 } |
69 } | 69 } |
70 /* do not catch SQLException here, as we want to know it when it fails */ | 70 /* do not catch SQLException here, as we want to know it when it fails */ |
71 } finally { | 71 } finally { |
72 if (rs != null) { | 72 MonetConnection.closeResultsetStatement(rs, st); |
73 try { | |
74 rs.close(); | |
75 } catch (SQLException e) { /* ignore */ } | |
76 } | |
77 if (st != null) { | |
78 try { | |
79 st.close(); | |
80 } catch (SQLException e) { /* ignore */ } | |
81 } | |
82 } | 73 } |
83 // for debug: System.out.println("Read: env_current_user: " + env_current_user + " env_monet_version: " + env_monet_version + " env_max_clients: " + env_max_clients); | 74 // for debug: System.out.println("Read: env_current_user: " + env_current_user + " env_monet_version: " + env_monet_version + " env_max_clients: " + env_max_clients); |
84 } | 75 } |
85 | 76 |
86 | 77 |
463 } | 454 } |
464 } | 455 } |
465 } catch (SQLException e) { | 456 } catch (SQLException e) { |
466 /* ignore */ | 457 /* ignore */ |
467 } finally { | 458 } finally { |
468 if (rs != null) { | 459 MonetConnection.closeResultsetStatement(rs, st); |
469 try { | |
470 rs.close(); | |
471 } catch (SQLException e) { /* ignore */ } | |
472 } | |
473 if (st != null) { | |
474 try { | |
475 st.close(); | |
476 } catch (SQLException e) { /* ignore */ } | |
477 } | |
478 } | 460 } |
479 // for debug: System.out.println("SQL query: " + query + "\nResult string: " + sb.toString()); | 461 // for debug: System.out.println("SQL query: " + query + "\nResult string: " + sb.toString()); |
480 return sb.toString(); | 462 return sb.toString(); |
481 } | 463 } |
482 | 464 |
3171 table_row_count = count_value; | 3153 table_row_count = count_value; |
3172 } | 3154 } |
3173 } catch (SQLException e) { | 3155 } catch (SQLException e) { |
3174 // ignore | 3156 // ignore |
3175 } finally { | 3157 } finally { |
3176 if (count != null) { | 3158 MonetConnection.closeResultsetStatement(count, null); |
3177 try { | |
3178 count.close(); | |
3179 } catch (SQLException e) { /* ignore */ } | |
3180 } | |
3181 } | 3159 } |
3182 } | 3160 } |
3183 | 3161 |
3184 final StringBuilder query = new StringBuilder(1250); | 3162 final StringBuilder query = new StringBuilder(1250); |
3185 query.append( | 3163 query.append( |