1 23 24 package org.apache.slide.store.impl.rdbms; 25 26 import java.io.FilterInputStream ; 27 import java.io.IOException ; 28 import java.io.InputStream ; 29 import java.sql.Connection ; 30 import java.sql.ResultSet ; 31 import java.sql.SQLException ; 32 import java.sql.Statement ; 33 34 41 class JDBCAwareInputStream 42 extends FilterInputStream { 43 44 45 47 48 52 private Statement stmt = null; 53 private ResultSet rs = null; 54 private Connection connection = null; 55 56 57 59 60 65 public JDBCAwareInputStream(InputStream in, Statement stmt, ResultSet rs, Connection connection) { 66 super(in); 67 68 this.stmt = stmt; 69 this.rs = rs; 70 this.connection = connection; 71 } 72 73 74 76 77 81 public void close() throws IOException { 82 try { 83 if (rs != null) { 84 rs.close(); 85 } 86 } catch (SQLException e) { 87 throw new IOException (e.getMessage()); 88 } finally { 89 try { 90 if (stmt != null) { 91 stmt.close(); 92 } 93 } catch (SQLException e) { 94 throw new IOException (e.getMessage()); 95 } finally { 96 try { 97 if (connection != null) { 98 try { 99 connection.commit(); 100 } catch (SQLException e) { 101 throw new IOException (e.getMessage()); 102 } finally { 103 try { 104 connection.close(); 105 } catch (SQLException e) { 106 throw new IOException (e.getMessage()); 107 } 108 } 109 } 110 } finally { 111 super.close(); 112 } 113 } 114 } 115 } 116 } 117 118 | Popular Tags |