1 7 package com.nilostep.xlsql.jdbc; 8 9 import com.nilostep.xlsql.sql.*; 10 import java.sql.*; 11 12 13 public class xlStatement implements Statement { 14 16 protected xlConnection xlCon; 17 private Statement dbStm; 18 22 protected xlStatement(xlConnection con, Statement stm) throws SQLException { 23 xlCon = con; 24 dbStm = stm; 25 } 26 27 29 33 public void addBatch(String sql) throws SQLException { 34 dbStm.addBatch(sql); 35 } 36 37 41 public void cancel() throws SQLException { 42 dbStm.cancel(); 43 } 44 45 49 public void clearBatch() throws SQLException { 50 dbStm.clearBatch(); 51 } 52 53 57 public void clearWarnings() throws SQLException { 58 dbStm.clearWarnings(); 59 } 60 61 65 public void close() throws SQLException { 66 dbStm.close(); 67 } 68 69 73 public boolean execute(String sql) throws SQLException { 74 boolean ret = true; 75 String [] sqlCommand = sql.split("[;]"); 76 for (int i=0; i < sqlCommand.length; i++) { 77 xlSqlCommand cmd = xlCon.xlsql.parseSql(sqlCommand[i]); 78 if (cmd.execAllowed()) { 79 ret = dbStm.execute(sqlCommand[i]); 81 cmd.execute(); 82 } 83 else { 84 throw new SQLException("xlSQL: execute not allowed"); 85 } 86 } 87 return ret; 88 } 89 90 94 public boolean execute(String sql, String [] columnNames) 95 throws SQLException { 96 throw new SQLException("not supported"); 97 } 98 99 103 public boolean execute(String sql, int autoGeneratedKeys) 104 throws SQLException { 105 throw new SQLException("not supported"); 106 } 107 108 112 public boolean execute(String sql, int[] columnIndexes) 113 throws SQLException { 114 throw new SQLException("not supported"); 115 } 116 117 121 public int[] executeBatch() throws SQLException { 122 throw new SQLException("not supported"); 123 } 124 125 129 public ResultSet executeQuery(String sql) throws SQLException { 130 ResultSet dbRs = dbStm.executeQuery(sql); 131 ResultSet rs = new xlResultSet(this, dbRs); 132 return rs; 133 } 134 135 139 public int executeUpdate(String sql) throws SQLException { 140 int ret = 0; 141 String [] sqlCommand = sql.split("[;]"); 142 for (int i=0; i < sqlCommand.length; i++) { 143 xlSqlCommand cmd = xlCon.xlsql.parseSql(sqlCommand[i]); 144 if (cmd.execAllowed()) { 145 ret = dbStm.executeUpdate(sqlCommand[i]); 147 cmd.execute(); 148 } 149 else { 150 throw new SQLException("xlSQL: execute not allowed"); 151 } 152 } 153 return ret; 154 } 155 156 160 public int executeUpdate(String sql, String [] columnNames) 161 throws SQLException { 162 throw new SQLException("not supported"); 163 } 164 165 169 public int executeUpdate(String sql, int autoGeneratedKeys) 170 throws SQLException { 171 throw new SQLException("not supported"); 172 } 173 174 178 public int executeUpdate(String sql, int[] columnIndexes) 179 throws SQLException { 180 throw new SQLException("not supported"); 181 } 182 183 187 public Connection getConnection() throws SQLException { 188 return xlCon; 189 } 190 191 195 public int getFetchDirection() throws SQLException { 196 return dbStm.getFetchDirection(); 197 } 198 199 203 public int getFetchSize() throws SQLException { 204 return dbStm.getFetchSize(); 205 } 206 207 211 public ResultSet getGeneratedKeys() throws SQLException { 212 return dbStm.getGeneratedKeys(); 213 } 214 215 219 public int getMaxFieldSize() throws SQLException { 220 return dbStm.getMaxFieldSize(); 221 } 222 223 227 public int getMaxRows() throws SQLException { 228 return dbStm.getMaxRows(); 229 } 230 231 235 public boolean getMoreResults() throws SQLException { 236 return dbStm.getMoreResults(); 237 } 238 239 243 public boolean getMoreResults(int current) throws SQLException { 244 return dbStm.getMoreResults(current); 245 } 246 247 251 public int getQueryTimeout() throws SQLException { 252 return dbStm.getQueryTimeout(); 253 } 254 255 259 public ResultSet getResultSet() throws SQLException { 260 ResultSet dbRs = dbStm.getResultSet(); 261 ResultSet rs = new xlResultSet(this, dbRs); 262 return rs; 263 } 264 265 269 public int getResultSetConcurrency() throws SQLException { 270 return dbStm.getResultSetConcurrency(); 271 } 272 273 277 public int getResultSetHoldability() throws SQLException { 278 return dbStm.getResultSetHoldability(); 279 } 280 281 285 public int getResultSetType() throws SQLException { 286 return dbStm.getResultSetType(); 287 } 288 289 293 public int getUpdateCount() throws SQLException { 294 return dbStm.getUpdateCount(); 295 } 296 297 301 public SQLWarning getWarnings() throws SQLException { 302 return dbStm.getWarnings(); 303 } 304 305 309 public void setCursorName(String name) throws SQLException { 310 dbStm.setCursorName(name); 311 } 312 313 317 public void setEscapeProcessing(boolean enable) throws SQLException { 318 dbStm.setEscapeProcessing(enable); 319 } 320 321 325 public void setFetchDirection(int direction) throws SQLException { 326 dbStm.setFetchDirection(direction); 327 } 328 329 333 public void setFetchSize(int rows) throws SQLException { 334 dbStm.setFetchSize(rows); 335 } 336 337 341 public void setMaxFieldSize(int max) throws SQLException { 342 dbStm.setMaxFieldSize(max); 343 } 344 345 349 public void setMaxRows(int max) throws SQLException { 350 dbStm.setMaxRows(max); 351 } 352 353 357 public void setQueryTimeout(int seconds) throws SQLException { 358 dbStm.setQueryTimeout(seconds); 359 } 360 361 } | Popular Tags |