1 21 22 package org.apache.derby.impl.jdbc; 24 25 import org.apache.derby.iapi.services.context.ContextImpl; 27 import org.apache.derby.iapi.services.context.ContextManager; 28 import org.apache.derby.iapi.sql.conn.StatementContext; 29 import org.apache.derby.iapi.jdbc.ConnectionContext; 30 import org.apache.derby.iapi.error.StandardException; 31 import org.apache.derby.iapi.sql.ResultSet; 32 33 import org.apache.derby.iapi.error.ExceptionSeverity; 34 import java.sql.SQLException ; 35 import java.util.Vector ; 36 import java.util.Enumeration ; 37 40 class EmbedConnectionContext extends ContextImpl 41 implements ConnectionContext 42 { 43 44 52 private java.lang.ref.SoftReference connRef; 53 54 55 EmbedConnectionContext(ContextManager cm, EmbedConnection conn) { 56 super(cm, ConnectionContext.CONTEXT_ID); 57 58 connRef = new java.lang.ref.SoftReference (conn); 59 } 60 61 public void cleanupOnError(Throwable error) { 62 63 if (connRef == null) 64 return; 65 66 EmbedConnection conn = (EmbedConnection) connRef.get(); 67 68 if (error instanceof StandardException) { 69 70 StandardException se = (StandardException) error; 71 if (se.getSeverity() < ExceptionSeverity.SESSION_SEVERITY) { 72 73 if (conn != null) { 79 conn.needCommit = false; 80 } 81 return; 82 } 83 } 84 85 if (conn != null) 87 conn.setInactive(); 89 connRef = null; 90 popMe(); 91 } 92 93 98 104 public java.sql.Connection getNestedConnection(boolean internal) throws SQLException { 105 106 EmbedConnection conn = (EmbedConnection) connRef.get(); 107 108 if ((conn == null) || conn.isClosed()) 109 throw Util.noCurrentConnection(); 110 111 if (!internal) { 112 StatementContext sc = conn.getLanguageConnection().getStatementContext(); 113 if ((sc == null) || (sc.getSQLAllowed() < org.apache.derby.catalog.types.RoutineAliasInfo.MODIFIES_SQL_DATA)) 114 throw Util.noCurrentConnection(); 115 } 116 117 return conn.getLocalDriver().getNewNestedConnection(conn); 118 } 119 120 126 public java.sql.ResultSet getResultSet 127 ( 128 ResultSet executionResultSet 129 ) throws SQLException 130 { 131 EmbedConnection conn = (EmbedConnection) connRef.get(); 132 133 EmbedResultSet rs = conn.getLocalDriver().newEmbedResultSet(conn, executionResultSet, 134 false, (EmbedStatement) null, true); 135 return rs; 136 } 137 } 138 | Popular Tags |