1 7 package com.nilostep.xlsql.jdbc; 8 9 import java.sql.*; 10 import com.nilostep.xlsql.sql.*; 11 12 public class xlPreparedStatement extends xlStatement implements PreparedStatement { 13 14 private String psql; 15 private PreparedStatement dbPstm; 16 17 19 23 protected xlPreparedStatement(xlConnection con, PreparedStatement pstm, 24 String sql) throws SQLException { 25 super(con,pstm); 26 dbPstm = pstm; 27 psql = sql; 28 } 29 30 32 36 public void addBatch() throws SQLException { 37 dbPstm.addBatch(); 38 } 39 40 44 public void clearParameters() throws SQLException { 45 dbPstm.clearParameters(); 46 } 47 48 52 public boolean execute() throws SQLException { 53 boolean ret; 54 xlSqlCommand cmd = xlCon.xlsql.parseSql(psql); 55 if (cmd.execAllowed()) { 56 ret = dbPstm.execute(); 58 cmd.execute(); 59 } 60 else { 61 throw new SQLException("xlSQL: execute not allowed"); 62 } 63 return ret; 64 } 65 66 70 public boolean execute(String sql, int autoGeneratedKeys) 71 throws SQLException { 72 boolean ret; 73 xlSqlCommand cmd = xlCon.xlsql.parseSql(sql); 74 if (cmd.execAllowed()) { 75 ret = dbPstm.execute(sql); 77 cmd.execute(); 78 } 79 else { 80 throw new SQLException("xlSQL: execute not allowed"); 81 } 82 return ret; 83 } 84 85 89 public ResultSet executeQuery() throws SQLException { 90 ResultSet ret = dbPstm.executeQuery(); 91 return ret; 92 } 93 94 98 public int executeUpdate() throws SQLException { 99 int ret; 100 xlSqlCommand cmd = xlCon.xlsql.parseSql(psql); 101 if (cmd.execAllowed()) { 102 ret = dbPstm.executeUpdate(psql); 104 cmd.execute(); 105 } 106 else { 107 throw new SQLException("xlSQL: execute not allowed"); 108 } 109 return ret; 110 } 111 112 116 public ResultSetMetaData getMetaData() throws SQLException { 117 return dbPstm.getMetaData(); 118 } 119 120 124 public ParameterMetaData getParameterMetaData() throws SQLException { 125 ParameterMetaData dbPsMeta = dbPstm.getParameterMetaData(); 126 ParameterMetaData psMeta = new xlParameterMetaData(this, dbPsMeta); 127 return psMeta; 128 } 129 130 134 public void setArray(int i, Array x) throws SQLException { 135 dbPstm.setArray(i, x); 136 } 137 138 142 public void setAsciiStream(int parameterIndex, java.io.InputStream x, 143 int length) throws SQLException { 144 dbPstm.setAsciiStream(parameterIndex, x, length); 145 } 146 147 151 public void setBigDecimal(int parameterIndex, java.math.BigDecimal x) 152 throws SQLException { 153 dbPstm.setBigDecimal(parameterIndex, x); 154 } 155 156 160 public void setBinaryStream(int parameterIndex, java.io.InputStream x, 161 int length) throws SQLException { 162 dbPstm.setBinaryStream(parameterIndex, x, length); 163 } 164 165 169 public void setBlob(int i, Blob x) throws SQLException { 170 dbPstm.setBlob(i, x); 171 } 172 173 177 public void setBoolean(int parameterIndex, boolean x) 178 throws SQLException { 179 dbPstm.setBoolean(parameterIndex, x); 180 } 181 182 186 public void setByte(int parameterIndex, byte x) throws SQLException { 187 dbPstm.setByte(parameterIndex, x); 188 } 189 190 194 public void setBytes(int parameterIndex, byte[] x) 195 throws SQLException { 196 dbPstm.setBytes(parameterIndex, x); 197 } 198 199 203 public void setCharacterStream(int parameterIndex, java.io.Reader reader, 204 int length) throws SQLException { 205 dbPstm.setCharacterStream(parameterIndex, reader, length); 206 } 207 208 212 public void setClob(int i, Clob x) throws SQLException { 213 dbPstm.setClob(i, x); 214 } 215 216 220 public void setCursorName(String name) throws SQLException { 221 dbPstm.setCursorName(name); 222 } 223 224 228 public void setDate(int parameterIndex, java.sql.Date x) 229 throws SQLException { 230 dbPstm.setDate(parameterIndex, x); 231 } 232 233 237 public void setDate(int parameterIndex, java.sql.Date x, 238 java.util.Calendar cal) throws SQLException { 239 dbPstm.setDate(parameterIndex, x, cal); 240 } 241 242 246 public void setDouble(int parameterIndex, double x) 247 throws SQLException { 248 dbPstm.setDouble(parameterIndex, x); 249 } 250 251 255 public void setFloat(int parameterIndex, float x) throws SQLException { 256 dbPstm.setFloat(parameterIndex, x); 257 } 258 259 263 public void setInt(int parameterIndex, int x) throws SQLException { 264 dbPstm.setInt(parameterIndex, x); 265 } 266 267 271 public void setLong(int parameterIndex, long x) throws SQLException { 272 dbPstm.setLong(parameterIndex, x); 273 } 274 275 279 public void setNull(int parameterIndex, int sqlType) 280 throws SQLException { 281 dbPstm.setNull(parameterIndex, sqlType); 282 } 283 284 288 public void setNull(int paramIndex, int sqlType, String typeName) 289 throws SQLException { 290 dbPstm.setNull(paramIndex, sqlType, typeName); 291 } 292 293 297 public void setObject(int parameterIndex, Object x) 298 throws SQLException { 299 dbPstm.setObject(parameterIndex, x); 300 } 301 302 306 public void setObject(int parameterIndex, Object x, int targetSqlType) 307 throws SQLException { 308 dbPstm.setObject(parameterIndex, x, targetSqlType); 309 } 310 311 315 public void setObject(int parameterIndex, Object x, int targetSqlType, 316 int scale) throws SQLException { 317 dbPstm.setObject(parameterIndex, x, targetSqlType); 318 } 319 320 324 public void setRef(int i, Ref x) throws SQLException { 325 dbPstm.setRef(i, x); 326 } 327 328 332 public void setShort(int parameterIndex, short x) throws SQLException { 333 dbPstm.setShort(parameterIndex, x); 334 } 335 336 340 public void setString(int parameterIndex, String x) 341 throws SQLException { 342 dbPstm.setString(parameterIndex, x); 343 } 344 345 349 public void setTime(int parameterIndex, java.sql.Time x) 350 throws SQLException { 351 dbPstm.setTime(parameterIndex, x); 352 } 353 354 358 public void setTime(int parameterIndex, java.sql.Time x, 359 java.util.Calendar cal) throws SQLException { 360 dbPstm.setTime(parameterIndex, x, cal); 361 } 362 363 367 public void setTimestamp(int parameterIndex, java.sql.Timestamp x) 368 throws SQLException { 369 dbPstm.setTimestamp(parameterIndex, x); 370 } 371 372 376 public void setTimestamp(int parameterIndex, java.sql.Timestamp x, 377 java.util.Calendar cal) throws SQLException { 378 dbPstm.setTimestamp(parameterIndex, x, cal); 379 } 380 381 385 public void setURL(int parameterIndex, java.net.URL x) 386 throws SQLException { 387 dbPstm.setURL(parameterIndex, x); 388 } 389 390 394 public void setUnicodeStream(int parameterIndex, java.io.InputStream x, 395 int length) throws SQLException { 396 dbPstm.setUnicodeStream(parameterIndex, x, length); 397 } 398 } | Popular Tags |