1 21 22 package org.apache.derby.impl.jdbc; 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.Connection ; 29 import java.sql.NClob ; 30 import java.sql.SQLException ; 31 import java.sql.SQLXML ; 32 import java.sql.Struct ; 33 import java.util.HashMap ; 34 import java.util.Map ; 35 import java.util.Properties ; 36 import java.util.Enumeration ; 37 import org.apache.derby.jdbc.InternalDriver; 38 import org.apache.derby.iapi.reference.SQLState; 39 import org.apache.derby.iapi.error.StandardException; 40 import org.apache.derby.iapi.jdbc.FailedProperties40; 41 42 public class EmbedConnection40 extends EmbedConnection30 { 43 44 45 public EmbedConnection40(EmbedConnection inputConnection) { 46 super(inputConnection); 47 } 48 49 public EmbedConnection40( 50 InternalDriver driver, 51 String url, 52 Properties info) 53 throws SQLException { 54 super(driver, url, info); 55 } 56 57 62 63 public Array createArrayOf(String typeName, Object [] elements) 64 throws SQLException { 65 throw Util.notImplemented(); 66 } 67 68 81 public Clob createClob() throws SQLException { 82 checkIfClosed(); 83 return new EmbedClob("",this); 84 } 85 86 99 public Blob createBlob() throws SQLException { 100 checkIfClosed(); 101 return new EmbedBlob(new byte[0],this); 102 } 103 104 public NClob createNClob() throws SQLException { 105 throw Util.notImplemented(); 106 } 107 108 public SQLXML createSQLXML() throws SQLException { 109 throw Util.notImplemented(); 110 } 111 112 public Struct createStruct(String typeName, Object [] attributes) 113 throws SQLException { 114 throw Util.notImplemented(); 115 } 116 117 129 public boolean isValid(int timeout) throws SQLException { 130 if (timeout < 0) { 132 throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER, 133 new Integer (timeout), "timeout", 134 "java.sql.Connection.isValid"); 135 } 136 137 return !isClosed(); 140 } 141 142 151 public void setClientInfo(String name, String value) 152 throws SQLClientInfoException { 153 Properties p = FailedProperties40.makeProperties(name,value); 154 try { checkIfClosed(); } 155 catch (SQLException se) { 156 FailedProperties40 fp = new FailedProperties40(p); 157 throw new SQLClientInfoException (se.getMessage(), 158 se.getSQLState(), 159 fp.getProperties()); 160 } 161 if (name == null && value == null) { 165 return; 166 } 167 setClientInfo(p); 168 } 169 170 184 public void setClientInfo(Properties properties) 185 throws SQLClientInfoException { 186 FailedProperties40 fp = new FailedProperties40(properties); 187 188 try { checkIfClosed(); } 189 catch (SQLException se) { 190 throw new SQLClientInfoException (se.getMessage(), se.getSQLState(), 191 fp.getProperties()); 192 } 193 194 if (properties == null || properties.isEmpty()) { 199 return; 200 } 201 202 StandardException se = 203 StandardException.newException 204 (SQLState.PROPERTY_UNSUPPORTED_CHANGE, 205 fp.getFirstKey(), 206 fp.getFirstValue()); 207 throw new SQLClientInfoException (se.getMessage(), 208 se.getSQLState(), fp.getProperties()); 209 } 210 211 220 public String getClientInfo(String name) 221 throws SQLException { 222 checkIfClosed(); 223 return null; 224 } 225 226 234 public Properties getClientInfo() 235 throws SQLException { 236 checkIfClosed(); 237 return new Properties (); 238 } 239 240 246 public final Map <String , Class <?>> getTypeMap() throws SQLException { 247 Map typeMap = super.getTypeMap(); 253 if (typeMap == null) return null; 254 Map <String , Class <?>> genericTypeMap = new HashMap <String , Class <?>>(); 255 for (Object key : typeMap.keySet()) { 256 genericTypeMap.put((String ) key, (Class ) typeMap.get(key)); 257 } 258 return genericTypeMap; 259 } 260 261 272 public boolean isWrapperFor(Class <?> interfaces) throws SQLException { 273 checkIfClosed(); 274 return interfaces.isInstance(this); 275 } 276 277 285 public <T> T unwrap(java.lang.Class <T> interfaces) 286 throws SQLException { 287 checkIfClosed(); 288 try { 293 return interfaces.cast(this); 294 } catch (ClassCastException cce) { 295 throw newSQLException(SQLState.UNABLE_TO_UNWRAP,interfaces); 296 } 297 } 298 } 299 | Popular Tags |