1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
|
/*
========== licence begin GPL
Copyright (C) 2002-2003 SAP AG
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
========== licence end
*/
package com.sap.dbtech.jdbcext;
import java.io.*;
import java.math.BigDecimal;
import java.sql.*;
import java.util.Calendar;
import java.util.Vector;
import java.util.ArrayList;
import java.util.Map;
import javax.sql.*;
import com.sap.dbtech.jdbcext.translators.*;
public abstract class AbstractRowSetSapDB
implements Serializable, Cloneable
{
protected String command = null;
protected String URL = null;
protected String dataSource = null;
protected transient String username = null;
protected transient String password = null;
protected int rowSetType = ResultSet.TYPE_SCROLL_SENSITIVE;
protected boolean showDeleted = false;
protected int queryTimeout = 0;
protected int maxRows = 0;
protected int maxFieldSize = 0;
protected int concurrency = java.sql.ResultSet.CONCUR_READ_ONLY;
protected boolean readOnly = true;
protected boolean escapeProcessing = true;
protected int isolation = Connection.TRANSACTION_READ_COMMITTED;
protected int fetchDir = ResultSet.FETCH_FORWARD;
protected int fetchSize = com.sap.dbtech.jdbc.ResultSetSapDB.DEFAULT_FETCHSIZE;
protected Map map = null;
protected ArrayList listeners = null;
protected Vector params = null;
public AbstractRowSetSapDB()
{
listeners = new ArrayList();
}
public void addRowSetListener(RowSetListener rlistener)
{
if(rlistener==null) {
return;
}
synchronized(this.listeners) {
int list_sz=this.listeners.size();
for(int i=0; i<list_sz; ++i) {
if(this.listeners.get(i)==rlistener) {
return;
}
}
listeners.add(rlistener);
}
}
public void clearParameters()
throws SQLException
{
params.clear();
}
public String getCommand()
{
return command;
}
public int getConcurrency()
throws SQLException
{
return concurrency;
}
public String getDataSourceName()
{
return dataSource;
}
public boolean getEscapeProcessing()
throws SQLException
{
return escapeProcessing;
}
public int getFetchDirection()
throws SQLException
{
return fetchDir;
}
public int getFetchSize()
throws SQLException
{
return fetchSize;
}
public int getMaxFieldSize()
throws SQLException
{
return maxFieldSize;
}
public int getMaxRows()
throws SQLException
{
return maxRows;
}
public Object[] getParams()
throws SQLException
{
return params.toArray();
}
public String getPassword()
{
return password;
}
public int getQueryTimeout()
throws SQLException
{
return queryTimeout;
}
public boolean getShowDeleted()
throws SQLException
{
return showDeleted;
}
public int getTransactionIsolation()
{
return isolation;
}
public int getType()
throws SQLException
{
return rowSetType;
}
public Map getTypeMap()
{
return map;
}
public String getUrl()
throws SQLException
{
return URL;
}
public String getUsername()
{
return username;
}
protected void initParams()
{
params = new Vector();
}
public boolean isReadOnly()
{
return readOnly;
}
protected void notifyCursorMoved()
{
if(!this.listeners.isEmpty())
{
RowSetEvent rowsetevent = new RowSetEvent((RowSet)this);
synchronized(this.listeners) {
int list_sz=this.listeners.size();
for(int i=0; i<list_sz; ++i) {
RowSetListener rl=(RowSetListener)this.listeners.get(i);
rl.cursorMoved(rowsetevent);
}
}
}
}
protected void notifyRowChanged()
{
if(!this.listeners.isEmpty())
{
RowSetEvent rowsetevent = new RowSetEvent((RowSet)this);
synchronized(this.listeners) {
int list_sz=this.listeners.size();
for(int i=0; i<list_sz; ++i) {
RowSetListener rl=(RowSetListener)this.listeners.get(i);
rl.rowChanged(rowsetevent);
}
}
}
}
protected void notifyRowSetChanged()
{
if(!this.listeners.isEmpty())
{
RowSetEvent rowsetevent = new RowSetEvent((RowSet)this);
synchronized(this.listeners) {
int list_sz=this.listeners.size();
for(int i=0; i<list_sz; ++i) {
RowSetListener rl=(RowSetListener)this.listeners.get(i);
rl.rowSetChanged(rowsetevent);
}
}
}
}
public void removeRowSetListener(RowSetListener rowsetlistener)
{
if(this.listeners==null) {
return;
}
synchronized(this.listeners) {
int list_sz=this.listeners.size();
for(int i=0; i<list_sz; ++i) {
if(this.listeners.get(i)==rowsetlistener) {
this.listeners.remove(i);
return;
}
}
}
}
public void setArray(int i, Array array)
throws SQLException
{
params.add(new ArrayTranslator(i,array));
}
public void setAsciiStream(int i, InputStream inputstream, int j)
throws SQLException
{
params.add(new AsciiStreamTranslator(i,inputstream,j));
}
public void setBigDecimal(int i, BigDecimal bigdecimal)
throws SQLException
{
params.add(new BigDecimalTranslator(i,bigdecimal));
}
public void setBinaryStream(int i, InputStream inputstream, int j)
throws SQLException
{
params.add(new BinaryStreamTranslator(i,inputstream,j));
}
public void setBlob(int i, Blob blob)
throws SQLException
{
params.add(new BlobTranslator(i,blob));
}
public void setBoolean(int i, boolean flag)
throws SQLException
{
params.add(new BooleanTranslator(i,flag));
}
public void setByte(int i, byte byte0)
throws SQLException
{
params.add(new ByteTranslator(i,byte0));
}
public void setBytes(int i, byte abyte0[])
throws SQLException
{
params.add(new BytesTranslator(i,abyte0));
}
public void setCharacterStream(int i, Reader reader, int j)
throws SQLException
{
params.add(new CharacterStreamTranslator(i,reader,j));
}
public void setClob(int i, Clob clob)
throws SQLException
{
params.add(new ClobTranslator(i,clob));
}
public void setCommand(String s)
throws SQLException
{
command = s;
params.clear();
}
public void setConcurrency(int i)
{
concurrency = i;
}
public void setDataSourceName(String s)
{
if(s == null)
dataSource = null;
else
dataSource = new String(s);
URL = null;
}
public void setDate(int i, Date date)
throws SQLException
{
params.add(new DateTranslator(i,date));
}
public void setDate(int i, Date date, Calendar calendar)
throws SQLException
{
params.add(new DateTranslator(i,date,calendar));
}
public void setDouble(int i, double d)
throws SQLException
{
params.add(new DoubleTranslator(i,d));
}
public void setEscapeProcessing(boolean flag)
throws SQLException
{
escapeProcessing = flag;
}
public void setFetchDirection(int i)
throws SQLException
{
fetchDir = i;
}
public void setFetchSize(int i)
throws SQLException
{
fetchSize = i;
}
public void setFloat(int i, float f)
throws SQLException
{
params.add(new FloatTranslator(i,f));
}
public void setInt(int i, int j)
throws SQLException
{
params.add(new IntTranslator(i,j));
}
public void setLong(int i, long l)
throws SQLException
{
params.add(new LongTranslator(i,l));
}
public void setMaxFieldSize(int i)
throws SQLException
{
maxFieldSize = i;
}
public void setMaxRows(int i)
throws SQLException
{
maxRows = i;
}
public void setNull(int i, int j)
throws SQLException
{
params.add(new NullTranslator(i));
}
public void setNull(int i, int j, String s)
throws SQLException
{
params.add(new NullTranslator(i));
}
public void setObject(int i, Object obj)
throws SQLException
{
params.add(new ObjectTranslator(i,obj));
}
public void setObject(int i, Object obj, int j)
throws SQLException
{
params.add(new ObjectTranslator(i,obj,j));
}
public void setObject(int i, Object obj, int j, int k)
throws SQLException
{
params.add(new ObjectTranslator(i,obj,j,k));
}
public void setPassword(String s)
{
password = s;
}
public void setQueryTimeout(int i)
throws SQLException
{
queryTimeout = i;
}
public void setReadOnly(boolean flag)
{
readOnly = flag;
}
public void setRef(int i, Ref ref)
throws SQLException
{
params.add(new RefTranslator(i,ref));
}
public void setShort(int i, short word0)
throws SQLException
{
params.add(new ShortTranslator(i,word0));
}
public void setString(int i, String s)
throws SQLException
{
params.add(new StringTranslator(i,s));
}
public void setTime(int i, Time time)
throws SQLException
{
params.add(new TimeTranslator(i,time));
}
public void setTime(int i, Time time, Calendar calendar)
throws SQLException
{
params.add(new TimeTranslator(i,time,calendar));
}
public void setTimestamp(int i, Timestamp timestamp)
throws SQLException
{
params.add(new TimestampTranslator(i,timestamp));
}
public void setTimestamp(int i, Timestamp timestamp, Calendar calendar)
throws SQLException
{
params.add(new TimestampTranslator(i,timestamp,calendar));
}
public void setTransactionIsolation(int i)
{
isolation = i;
}
public void setType(int i)
{
rowSetType = i;
}
public void setTypeMap(Map map1)
{
map = map1;
}
public void setUnicodeStream(int i, InputStream inputstream, int j)
throws SQLException
{
params.add(new UnicodeStreamTranslator(i,inputstream,j));
}
public void setUrl(String s)
throws SQLException
{
if(s == null)
URL = null;
else
URL = s;
dataSource = null;
}
public void setUsername(String s)
{
username = new String(s);
}
}
|