1 32 33 package com.mockobjects.eziba.sql; 34 import java.sql.SQLException ; 35 import java.util.Map ;public class Connection 36 implements java.sql.Connection 37 { 38 39 Connection() 40 { 41 } 42 43 44 public static final Object WILDCARD = Wildcard.WILDCARD; 45 46 java.sql.ResultSet getRegisteredResult(String p_sql, Object [] p_args) 47 throws SQLException 48 { 49 java.sql.ResultSet rs = 50 (java.sql.ResultSet ) m_resultMap.get(p_sql, p_args); 51 rs.first(); 52 return rs; 53 } 54 55 int getRegisteredUpdate(String p_sql, Object [] p_args) 56 throws SQLException 57 { 58 Integer r = (Integer ) m_updateMap.get(p_sql, p_args); 59 return r.intValue(); 60 } 61 62 Object [] getRegisteredCall(String p_sql, Object [] p_args) 63 throws SQLException 64 { 65 Object [] rv = (Object [] ) m_callMap.get(p_sql, p_args); 66 return rv; 67 } 68 69 public String getRegistryContents() 70 { 71 return m_resultMap + "\n" 72 + m_callMap + "\n" 73 + m_updateMap; 74 } 75 76 public int getRegisteredResultCount() 77 { 78 return m_resultMap.size(); 79 } 80 81 public int getRegisteredCallCount() 82 { 83 return m_callMap.size(); 84 } 85 86 public int getRegisteredUpdateCount() 87 { 88 return m_updateMap.size(); 89 } 90 91 public int getRegisteredCount() 92 { 93 return ( getRegisteredResultCount() 94 + getRegisteredCallCount() 95 + getRegisteredUpdateCount() ); 96 } 97 98 public void registerResult(String p_sql, 99 Object [] p_args, 100 java.sql.ResultSet p_resultSet) 101 { 102 if (p_resultSet == null) 103 { 104 throw new IllegalArgumentException ("ResultSet can't be null"); 105 } 106 if (p_args == null) 107 { 108 throw new IllegalArgumentException ("Argument array can't be null"); 109 } 110 m_resultMap.put(p_sql, p_args, p_resultSet); 111 } 112 113 public void registerCall(String p_sql, 114 Object [] p_args, 115 Object [] p_output) 116 { 117 if (p_args == null) 118 { 119 throw new IllegalArgumentException ("Argument array can't be null"); 120 } 121 if (p_output == null) 122 { 123 throw new IllegalArgumentException ("Output array can't be null"); 124 } 125 m_callMap.put(p_sql,p_args, p_output); 126 } 127 128 public void registerUpdate(String p_sql, 129 Object [] p_args, 130 int p_result) 131 { 132 if (p_args == null) 133 { 134 throw new IllegalArgumentException ("Argument array can't be null"); 135 } 136 m_updateMap.put(p_sql, p_args,new Integer (p_result)); 137 } 138 139 public void close() 140 throws SQLException 141 { 142 m_closed = true; 143 } 144 145 public boolean isClosed() 146 { 147 return m_closed; 148 } 149 150 private boolean m_closed = false; 151 152 public java.sql.CallableStatement prepareCall(String p_sql) 153 throws SQLException 154 { 155 if ( isClosed() ) 156 { 157 throw new SQLException ("Attempt to use a closed connection"); 158 } 159 return new CallableStatement(this,p_sql); 160 } 161 162 public java.sql.PreparedStatement prepareStatement(String p_sql) 163 throws SQLException 164 { 165 if ( isClosed() ) 166 { 167 throw new SQLException ("Attempt to use a closed connection"); 168 } 169 return new PreparedStatement(this,p_sql); 170 } 171 172 173 174 private ConnectionMap m_resultMap = new ConnectionMap("result set"); 175 private ConnectionMap m_callMap = new ConnectionMap("call"); 176 private ConnectionMap m_updateMap = new ConnectionMap("update"); 177 178 181 public void clearWarnings() 182 { 183 throw new NotImplementedException(); 184 } 185 186 public void commit() 187 { 188 throw new NotImplementedException(); 189 } 190 191 public java.sql.Statement createStatement() 192 { 193 throw new NotImplementedException(); 194 } 195 196 public java.sql.Statement createStatement(int p_resultSetType, 197 int p_resultSetConcurrency) 198 { 199 throw new NotImplementedException(); 200 } 201 202 public boolean getAutoCommit() 203 { 204 throw new NotImplementedException(); 205 } 206 207 public String getCatalog() 208 { 209 throw new NotImplementedException(); 210 } 211 212 public java.sql.DatabaseMetaData getMetaData() 213 { 214 throw new NotImplementedException(); 215 } 216 217 public int getTransactionIsolation() 218 { 219 throw new NotImplementedException(); 220 } 221 222 public Map getTypeMap() 223 { 224 throw new NotImplementedException(); 225 } 226 227 public java.sql.SQLWarning getWarnings() 228 { 229 throw new NotImplementedException(); 230 } 231 232 public boolean isReadOnly() 233 { 234 throw new NotImplementedException(); 235 } 236 237 public String nativeSQL(String p_sql) 238 { 239 throw new NotImplementedException(); 240 } 241 242 public java.sql.CallableStatement prepareCall(String p_sql, 243 int rsType, 244 int rsConcurrency) 245 { 246 throw new NotImplementedException(); 247 } 248 249 public java.sql.PreparedStatement prepareStatement(String p_sql, 250 int rsType, 251 int rsConcurrency) 252 { 253 throw new NotImplementedException(); 254 } 255 256 public void rollback() 257 { 258 throw new NotImplementedException(); 259 } 260 261 public void setAutoCommit(boolean p_autoCommit) 262 { 263 throw new NotImplementedException(); 264 } 265 266 public void setCatalog(String p_catalog) 267 { 268 throw new NotImplementedException(); 269 } 270 271 public void setReadOnly(boolean p_readOnly) 272 { 273 throw new NotImplementedException(); 274 } 275 276 public void setTransactionIsolation(int p_level) 277 { 278 throw new NotImplementedException(); 279 } 280 281 public void setTypeMap(Map p_map) 282 { 283 throw new NotImplementedException(); 284 } 285 } | Popular Tags |