1 22 package org.enhydra.jdbc.core; 23 24 import org.enhydra.jdbc.util.JdbcUtil; 25 26 import java.sql.CallableStatement ; 27 import java.sql.Connection ; 28 import java.sql.DatabaseMetaData ; 29 import java.sql.PreparedStatement ; 30 import java.sql.SQLException ; 31 import java.sql.SQLWarning ; 32 import java.sql.Statement ; 33 import java.util.Map ; 34 35 40 public abstract class CoreConnection extends JdbcUtil implements Connection { 41 public Connection con; 43 46 public CoreConnection(Connection con) { 47 this.con = con; 48 } 49 50 public CoreConnection() { 51 } 52 53 public void clearWarnings() throws SQLException { 54 preInvoke(); 55 try { 56 con.clearWarnings(); 57 } catch (SQLException e) { 58 catchInvoke(e); 59 } 60 } 61 62 public void close() throws SQLException { 63 preInvoke(); 64 try { 65 con.close(); 66 } catch (SQLException e) { 67 catchInvoke(e); 68 } 69 } 70 71 public void commit() throws SQLException { 72 preInvoke(); 73 try { 74 con.commit(); 75 } catch (SQLException e) { 76 catchInvoke(e); 77 } 78 } 79 80 public Statement createStatement() throws SQLException { 81 preInvoke(); 82 try { 83 return con.createStatement(); 84 } catch (SQLException e) { 85 catchInvoke(e); 86 } 87 return null; 88 } 89 90 public Statement createStatement( 91 int resultSetType, 92 int resultSetConcurrency) 93 throws SQLException { 94 preInvoke(); 95 try { 96 return con.createStatement(resultSetType, resultSetConcurrency); 97 } catch (SQLException e) { 98 catchInvoke(e); 99 } 100 return null; 101 } 102 103 public boolean getAutoCommit() throws SQLException { 104 preInvoke(); 105 try { 106 return con.getAutoCommit(); 107 } catch (SQLException e) { 108 catchInvoke(e); 109 } 110 return false; 111 } 112 113 public String getCatalog() throws SQLException { 114 preInvoke(); 115 try { 116 return con.getCatalog(); 117 } catch (SQLException e) { 118 catchInvoke(e); 119 } 120 return null; 121 } 122 123 public DatabaseMetaData getMetaData() throws SQLException { 124 preInvoke(); 125 try { 126 return con.getMetaData(); 127 } catch (SQLException e) { 128 catchInvoke(e); 129 } 130 return null; 131 } 132 133 public int getTransactionIsolation() throws SQLException { 134 preInvoke(); 135 try { 136 return con.getTransactionIsolation(); 137 } catch (SQLException e) { 138 catchInvoke(e); 139 } 140 return 0; 141 } 142 143 public Map getTypeMap() throws SQLException { 144 preInvoke(); 145 try { 146 return con.getTypeMap(); 147 } catch (SQLException e) { 148 catchInvoke(e); 149 } 150 return null; 151 } 152 153 public SQLWarning getWarnings() throws SQLException { 154 preInvoke(); 155 try { 156 return con.getWarnings(); 157 } catch (SQLException e) { 158 catchInvoke(e); 159 } 160 return null; 161 } 162 163 public boolean isReadOnly() throws SQLException { 164 preInvoke(); 165 try { 166 return con.isReadOnly(); 167 } catch (SQLException e) { 168 catchInvoke(e); 169 } 170 return false; 171 } 172 173 public String nativeSQL(String sql) throws SQLException { 174 preInvoke(); 175 try { 176 return con.nativeSQL(sql); 177 } catch (SQLException e) { 178 catchInvoke(e); 179 } 180 return null; 181 } 182 183 public CallableStatement prepareCall(String sql) throws SQLException { 184 preInvoke(); 185 try { 186 return con.prepareCall(sql); 187 } catch (SQLException e) { 188 catchInvoke(e); 189 } 190 return null; 191 } 192 193 public PreparedStatement prepareStatement(String sql) throws SQLException { 194 preInvoke(); 195 try { 196 return con.prepareStatement(sql); 197 } catch (SQLException e) { 198 catchInvoke(e); 199 } 200 return null; 201 } 202 203 public PreparedStatement prepareStatement( 204 String sql, 205 int resultSetType, 206 int resultSetConcurrency) 207 throws SQLException { 208 preInvoke(); 209 try { 210 return con.prepareStatement( 211 sql, 212 resultSetType, 213 resultSetConcurrency); 214 } catch (SQLException e) { 215 catchInvoke(e); 216 } 217 return null; 218 } 219 220 public void rollback() throws SQLException { 221 preInvoke(); 222 try { 223 con.rollback(); 224 } catch (SQLException e) { 225 catchInvoke(e); 226 } 227 } 228 229 public void setAutoCommit(boolean autoCommit) throws SQLException { 230 log.debug("CoreConnection:Setautocommit autoCommit was = " + con.getAutoCommit()); 231 log.debug("CoreConnection:Setautocommit = " + autoCommit); 232 preInvoke(); 233 try { 234 con.setAutoCommit(autoCommit); 235 } catch (SQLException e) { 236 catchInvoke(e); 237 } 238 } 239 240 public void setCatalog(String catalog) throws SQLException { 241 preInvoke(); 242 try { 243 con.setCatalog(catalog); 244 } catch (SQLException e) { 245 catchInvoke(e); 246 } 247 } 248 249 public void setReadOnly(boolean readOnly) throws SQLException { 250 preInvoke(); 251 try { 252 con.setReadOnly(readOnly); 253 } catch (SQLException e) { 254 catchInvoke(e); 255 } 256 } 257 258 public void setTransactionIsolation(int level) throws SQLException { 259 preInvoke(); 260 try { 261 con.setTransactionIsolation(level); 262 } catch (SQLException e) { 263 catchInvoke(e); 264 } 265 } 266 267 public void setTypeMap(Map map) throws SQLException { 268 preInvoke(); 269 try { 270 con.setTypeMap(map); 271 } catch (SQLException e) { 272 catchInvoke(e); 273 } 274 } 275 276 281 public Statement createStatement( 282 int resultSetType, 283 int resultSetConcurrency, 284 int resultSetHoldability) 285 throws SQLException { 286 preInvoke(); 287 try { 288 return con.createStatement(resultSetType,resultSetConcurrency,resultSetHoldability); 289 } catch (SQLException e) { 290 catchInvoke(e); 291 } 292 return null; 293 } 294 public int getHoldability() throws SQLException { 295 preInvoke(); 296 try { 297 return con.getHoldability(); 298 } catch (SQLException e) { 299 catchInvoke(e); 300 } 301 return 0; 302 } 303 public CallableStatement prepareCall( 304 String sql, 305 int resultSetType, 306 int resultSetConcurrency, 307 int resultSetHoldability) 308 throws SQLException { 309 preInvoke(); 310 try { 311 return con.prepareCall(sql,resultSetType,resultSetConcurrency,resultSetHoldability); 312 } catch (SQLException e) { 313 catchInvoke(e); 314 } 315 return null; 316 } 317 public PreparedStatement prepareStatement( 318 String sql, 319 int autoGeneratedKeys) 320 throws SQLException { 321 preInvoke(); 322 try { 323 return con.prepareStatement(sql,autoGeneratedKeys); 324 } catch (SQLException e) { 325 catchInvoke(e); 326 } 327 return null; 328 } 329 public PreparedStatement prepareStatement( 330 String sql, 331 int resultSetType, 332 int resultSetConcurrency, 333 int resultSetHoldability) 334 throws SQLException { 335 preInvoke(); 336 try { 337 return prepareStatement(sql,resultSetType,resultSetConcurrency,resultSetHoldability); 338 } catch (SQLException e) { 339 catchInvoke(e); 340 } 341 return null; 342 } 343 public PreparedStatement prepareStatement(String sql, int[] columnIndexes) 344 throws SQLException { 345 preInvoke(); 346 try { 347 return con.prepareStatement(sql,columnIndexes); 348 } catch (SQLException e) { 349 catchInvoke(e); 350 } 351 return null; 352 } 353 public PreparedStatement prepareStatement(String sql, String [] columnNames) 354 throws SQLException { 355 preInvoke(); 356 try { 357 return con.prepareStatement(sql,columnNames); 358 } catch (SQLException e) { 359 catchInvoke(e); 360 } 361 return null; 362 } 363 public void releaseSavepoint(java.sql.Savepoint savepoint) 364 throws SQLException { 365 preInvoke(); 366 try { 367 con.releaseSavepoint(savepoint); 368 } catch (SQLException e) { 369 catchInvoke(e); 370 } 371 372 } 373 public void rollback(java.sql.Savepoint savepoint) throws SQLException { 374 preInvoke(); 375 try { 376 con.rollback(savepoint); 377 } catch (SQLException e) { 378 catchInvoke(e); 379 } 380 } 381 public void setHoldability(int holdability) throws SQLException { 382 preInvoke(); 383 try { 384 con.setHoldability(holdability); 385 } catch (SQLException e) { 386 catchInvoke(e); 387 } 388 389 } 390 public java.sql.Savepoint setSavepoint() throws SQLException { 391 preInvoke(); 392 try { 393 return con.setSavepoint(); 394 } catch (SQLException e) { 395 catchInvoke(e); 396 } 397 return null; 398 } 399 public java.sql.Savepoint setSavepoint(String name) throws SQLException { 400 preInvoke(); 401 try { 402 return con.setSavepoint(name); 403 } catch (SQLException e) { 404 catchInvoke(e); 405 } 406 return null; 407 } 408 409 413 abstract public void preInvoke() throws SQLException ; 414 abstract public void catchInvoke(SQLException e) throws SQLException ; 415 416 } 417 | Popular Tags |