1 21 22 package org.apache.derby.client.am; 23 24 import java.sql.Array ; 25 import java.sql.Blob ; 26 import java.sql.SQLClientInfoException ; 27 import java.sql.Clob ; 28 import java.sql.NClob ; 29 import java.sql.SQLXML ; 30 import java.sql.SQLException ; 31 import java.sql.Struct ; 32 import java.sql.Wrapper ; 33 import java.util.Properties ; 34 35 import org.apache.derby.client.ClientPooledConnection; 36 import org.apache.derby.shared.common.reference.SQLState; 37 import java.util.Map ; 38 39 46 public class LogicalConnection40 47 extends LogicalConnection { 48 49 public LogicalConnection40(Connection physicalConnection, 50 ClientPooledConnection pooledConnection) 51 throws SqlException { 52 super(physicalConnection, pooledConnection); 53 } 54 55 public Array createArrayOf(String typeName, Object [] elements) 56 throws SQLException { 57 checkForNullPhysicalConnection(); 58 return physicalConnection_.createArrayOf( typeName, elements ); 59 } 60 61 public Blob createBlob() 62 throws SQLException { 63 checkForNullPhysicalConnection(); 64 return physicalConnection_.createBlob(); 65 } 66 67 public Clob createClob() 68 throws SQLException { 69 checkForNullPhysicalConnection(); 70 return physicalConnection_.createClob(); 71 } 72 73 public NClob createNClob() 74 throws SQLException { 75 checkForNullPhysicalConnection(); 76 return physicalConnection_.createNClob(); 77 } 78 79 public SQLXML createSQLXML() 80 throws SQLException { 81 checkForNullPhysicalConnection(); 82 return physicalConnection_.createSQLXML(); 83 } 84 85 public Struct createStruct(String typeName, Object [] attributes) 86 throws SQLException { 87 checkForNullPhysicalConnection(); 88 return physicalConnection_.createStruct( typeName, attributes ); 89 } 90 91 101 public Properties getClientInfo() 102 throws SQLException { 103 checkForNullPhysicalConnection(); 104 return physicalConnection_.getClientInfo(); 105 } 106 107 117 public String getClientInfo(String name) 118 throws SQLException { 119 checkForNullPhysicalConnection(); 120 return physicalConnection_.getClientInfo(name); 121 } 122 123 129 public Map <String , Class <?>> getTypeMap() throws SQLException { 130 checkForNullPhysicalConnection(); 131 return ((java.sql.Connection ) physicalConnection_).getTypeMap(); 132 } 133 134 148 synchronized public boolean isValid(int timeout) throws SQLException { 149 if (physicalConnection_ == null) { 151 return false; 152 } 153 return physicalConnection_.isValid(timeout); 154 } 155 156 157 public boolean isWrapperFor(Class <?> interfaces) 158 throws SQLException { 159 checkForNullPhysicalConnection(); 160 return interfaces.isInstance(this); 161 } 162 163 171 public void setClientInfo(Properties properties) 172 throws SQLClientInfoException { 173 try { checkForNullPhysicalConnection(); } 174 catch (SQLException se) { 175 throw new SQLClientInfoException 176 (se.getMessage(), se.getSQLState(), 177 (new FailedProperties40(properties)).getProperties()); 178 } 179 physicalConnection_.setClientInfo(properties); 180 } 181 182 190 public void setClientInfo(String name, String value) 191 throws SQLClientInfoException { 192 try { checkForNullPhysicalConnection(); } 193 catch (SQLException se) { 194 throw new SQLClientInfoException 195 (se.getMessage(), se.getSQLState(), 196 new FailedProperties40 197 (FailedProperties40.makeProperties 198 (name,value)).getProperties()); 199 } 200 physicalConnection_.setClientInfo(name, value); 201 } 202 203 public <T>T unwrap(Class <T> interfaces) 204 throws SQLException { 205 checkForNullPhysicalConnection(); 206 try { 208 return interfaces.cast(this); 209 } catch (ClassCastException cce) { 210 throw new SqlException(null, 211 new ClientMessageId(SQLState.UNABLE_TO_UNWRAP), 212 interfaces).getSQLException(); 213 } 214 } 215 216 } | Popular Tags |