1 28 29 package com.caucho.sql; 30 31 import com.caucho.log.Log; 32 import com.caucho.util.L10N; 33 34 import java.sql.Connection ; 35 import java.sql.ResultSet ; 36 import java.sql.SQLException ; 37 import java.sql.SQLWarning ; 38 import java.sql.Statement ; 39 import java.util.logging.Logger ; 40 41 42 45 public class UserStatement implements Statement { 46 protected final static Logger log = Log.open(UserStatement.class); 47 protected final static L10N L = new L10N(UserStatement.class); 48 49 protected UserConnection _conn; 51 52 protected Statement _stmt; 54 55 protected boolean _isChanged; 57 58 UserStatement(UserConnection conn, Statement stmt) 59 { 60 _conn = conn; 61 _stmt = stmt; 62 } 63 64 67 boolean isChanged() 68 { 69 return _isChanged; 70 } 71 72 75 public Statement getStatement() 76 { 77 Statement stmt = _stmt; 78 79 if (stmt instanceof com.caucho.sql.spy.SpyStatement) { 80 stmt = ((com.caucho.sql.spy.SpyStatement)stmt).getStatement(); 81 } 82 83 return stmt; 84 } 85 86 public void addBatch(String sql) 87 throws SQLException 88 { 89 _stmt.addBatch(sql); 90 } 91 92 public void cancel() 93 throws SQLException 94 { 95 _stmt.cancel(); 96 } 97 98 public void clearBatch() 99 throws SQLException 100 { 101 _stmt.clearBatch(); 102 } 103 104 public void clearWarnings() 105 throws SQLException 106 { 107 _stmt.clearWarnings(); 108 } 109 110 113 public void close() 114 throws SQLException 115 { 116 Statement stmt = _stmt; 117 _stmt = null; 118 119 if (stmt != null) { 120 _conn.closeStatement(stmt); 121 122 stmt.close(); 123 } 124 } 125 126 129 public ResultSet executeQuery(String sql) 130 throws SQLException 131 { 132 return _stmt.executeQuery(sql); 133 } 134 135 138 public int executeUpdate(String sql) 139 throws SQLException 140 { 141 return _stmt.executeUpdate(sql); 142 } 143 144 147 public int executeUpdate(String query, int resultType) 148 throws SQLException 149 { 150 return _stmt.executeUpdate(query, resultType); 151 } 152 153 156 public int executeUpdate(String query, int []columns) 157 throws SQLException 158 { 159 return _stmt.executeUpdate(query, columns); 160 } 161 162 165 public int executeUpdate(String query, String []columns) 166 throws SQLException 167 { 168 return _stmt.executeUpdate(query, columns); 169 } 170 171 174 public boolean execute(String sql) 175 throws SQLException 176 { 177 return _stmt.execute(sql); 178 } 179 180 183 public boolean execute(String query, int resultType) 184 throws SQLException 185 { 186 return _stmt.execute(query, resultType); 187 } 188 189 193 public boolean execute(String query, int []columns) 194 throws SQLException 195 { 196 return _stmt.execute(query, columns); 197 } 198 199 203 public boolean execute(String query, String []columns) 204 throws SQLException 205 { 206 return _stmt.execute(query, columns); 207 } 208 209 212 public int[]executeBatch() 213 throws SQLException 214 { 215 return _stmt.executeBatch(); 216 } 217 218 221 public java.sql.ResultSet getResultSet() 222 throws SQLException 223 { 224 return _stmt.getResultSet(); 225 } 226 227 230 public int getUpdateCount() 231 throws SQLException 232 { 233 return _stmt.getUpdateCount(); 234 } 235 236 239 public Connection getConnection() 240 throws SQLException 241 { 242 return _conn; 243 } 244 245 248 public int getFetchDirection() 249 throws SQLException 250 { 251 return _stmt.getFetchDirection(); 252 } 253 254 257 public void setFetchDirection(int direction) 258 throws SQLException 259 { 260 _isChanged = true; 261 262 _stmt.setFetchDirection(direction); 263 } 264 265 268 public int getFetchSize() 269 throws SQLException 270 { 271 return _stmt.getFetchSize(); 272 } 273 274 277 public void setFetchSize(int rows) 278 throws SQLException 279 { 280 _isChanged = true; 281 282 _stmt.setFetchSize(rows); 283 } 284 285 288 public int getMaxFieldSize() 289 throws SQLException 290 { 291 return _stmt.getMaxFieldSize(); 292 } 293 294 297 public void setMaxFieldSize(int max) 298 throws SQLException 299 { 300 _isChanged = true; 301 302 _stmt.setMaxFieldSize(max); 303 } 304 305 308 public int getMaxRows() 309 throws SQLException 310 { 311 return _stmt.getMaxRows(); 312 } 313 314 317 public void setMaxRows(int max) 318 throws SQLException 319 { 320 _isChanged = true; 321 322 _stmt.setMaxRows(max); 323 } 324 325 328 public boolean getMoreResults() 329 throws SQLException 330 { 331 return _stmt.getMoreResults(); 332 } 333 334 337 public int getQueryTimeout() 338 throws SQLException 339 { 340 return _stmt.getQueryTimeout(); 341 } 342 343 346 public void setQueryTimeout(int seconds) 347 throws SQLException 348 { 349 _isChanged = true; 350 351 _stmt.setQueryTimeout(seconds); 352 } 353 354 357 public int getResultSetConcurrency() 358 throws SQLException 359 { 360 return _stmt.getResultSetConcurrency(); 361 } 362 363 366 public int getResultSetType() 367 throws SQLException 368 { 369 return _stmt.getResultSetType(); 370 } 371 372 375 public SQLWarning getWarnings() 376 throws SQLException 377 { 378 return _stmt.getWarnings(); 379 } 380 381 384 public void setCursorName(String name) 385 throws SQLException 386 { 387 _isChanged = true; 388 389 _stmt.setCursorName(name); 390 } 391 392 395 public void setEscapeProcessing(boolean enable) 396 throws SQLException 397 { 398 _isChanged = true; 399 400 _stmt.setEscapeProcessing(enable); 401 } 402 403 406 public boolean getMoreResults(int count) 407 throws SQLException 408 { 409 return _stmt.getMoreResults(count); 410 } 411 412 415 public java.sql.ResultSet getGeneratedKeys() 416 throws SQLException 417 { 418 return _stmt.getGeneratedKeys(); 419 } 420 421 424 public int getResultSetHoldability() 425 throws SQLException 426 { 427 return _stmt.getResultSetHoldability(); 428 } 429 430 public String toString() 431 { 432 return "UserStatement[" + _stmt + "]"; 433 } 434 } 435 | Popular Tags |