1 21 22 package org.continuent.sequoia.common.sql; 23 24 import java.io.IOException ; 25 26 import org.continuent.sequoia.common.stream.DriverBufferedInputStream; 27 import org.continuent.sequoia.common.stream.DriverBufferedOutputStream; 28 29 36 public class Request 37 { 38 42 private String sqlQueryOrTemplate; 43 44 47 private String preparedStatementParameters = null; 48 49 53 54 private boolean isReadOnly = false; 55 56 60 private boolean isAutoCommit = true; 61 62 66 private int transactionIsolation; 67 68 74 private int timeoutInSeconds; 75 76 83 private boolean escapeProcessing = true; 84 85 89 private long id; 90 91 95 106 public Request(String sqlTemplate, String parameters, 107 boolean escapeProcessing, int timeoutInSeconds) 108 { 109 this.sqlQueryOrTemplate = sqlTemplate; 110 this.preparedStatementParameters = parameters; 111 this.escapeProcessing = escapeProcessing; 112 this.timeoutInSeconds = timeoutInSeconds; 113 } 114 115 119 126 127 public Request(DriverBufferedInputStream in) throws IOException 128 { 129 this.sqlQueryOrTemplate = in.readLongUTF(); 130 this.escapeProcessing = in.readBoolean(); 131 this.timeoutInSeconds = in.readInt(); 132 133 this.isAutoCommit = in.readBoolean(); 134 135 if (in.readBoolean()) 139 this.preparedStatementParameters = in.readLongUTF(); 140 141 } 143 144 152 153 public void sendToStream(DriverBufferedOutputStream out) throws IOException 154 { 155 out.writeLongUTF(sqlQueryOrTemplate); 156 out.writeBoolean(escapeProcessing); 157 out.writeInt(timeoutInSeconds); 158 159 out.writeBoolean(isAutoCommit); 160 161 if (preparedStatementParameters != null) 166 { 167 out.writeBoolean(true); 168 out.writeLongUTF(preparedStatementParameters); 169 } 170 else 171 out.writeBoolean(false); 172 } 173 174 178 183 public final boolean isEscapeProcessing() 184 { 185 return escapeProcessing; 186 } 187 188 193 public final void setEscapeProcessing(boolean escapeProcessing) 194 { 195 this.escapeProcessing = escapeProcessing; 196 } 197 198 203 public final boolean isAutoCommit() 204 { 205 return isAutoCommit; 206 } 207 208 213 public final void setIsAutoCommit(boolean isAutoCommit) 214 { 215 this.isAutoCommit = isAutoCommit; 216 } 217 218 223 public final boolean isReadOnly() 224 { 225 return isReadOnly; 226 } 227 228 233 public final void setIsReadOnly(boolean isReadOnly) 234 { 235 this.isReadOnly = isReadOnly; 236 } 237 238 243 public long getId() 244 { 245 return id; 246 } 247 248 253 public void setId(long id) 254 { 255 this.id = id; 256 } 257 258 263 public final String getSqlQueryOrTemplate() 264 { 265 return sqlQueryOrTemplate; 266 } 267 268 275 public String getSqlShortForm(int nbOfCharacters) 276 { 277 if ((nbOfCharacters == 0) || (sqlQueryOrTemplate.length() < nbOfCharacters)) 278 return sqlQueryOrTemplate; 279 else 280 return sqlQueryOrTemplate.substring(0, nbOfCharacters) + "..."; 281 } 282 283 288 public final String getPreparedStatementParameters() 289 { 290 return preparedStatementParameters; 291 } 292 293 298 public final int getTimeoutInSeconds() 299 { 300 return timeoutInSeconds; 301 } 302 303 308 public final void setTimeoutInSeconds(int timeoutInSeconds) 309 { 310 this.timeoutInSeconds = timeoutInSeconds; 311 } 312 313 318 public final int getTransactionIsolation() 319 { 320 return transactionIsolation; 321 } 322 323 328 public final void setTransactionIsolation(int transactionIsolation) 329 { 330 this.transactionIsolation = transactionIsolation; 331 } 332 333 } 334 | Popular Tags |