166 */
167 private ResultSetMetaData callerMd;
168
169 /**
170 * The number of columns in the <code>CachedRowSet</code> object
171 * for which this <code>CachedRowSetWriter</code> object is the writer.
172 *
173 * @serial
174 */
175 private int callerColumnCount;
176
177 /**
178 * This <code>CachedRowSet<code> will hold the conflicting values
179 * retrieved from the db and hold it.
180 */
181 private CachedRowSetImpl crsResolve;
182
183 /**
184 * This <code>ArrayList<code> will hold the values of SyncResolver.*
185 */
186 private ArrayList status;
187
188 /**
189 * This will check whether the same field value has changed both
190 * in database and CachedRowSet.
191 */
192 private int iChangedValsInDbAndCRS;
193
194 /**
195 * This will hold the number of cols for which the values have
196 * changed only in database.
197 */
198 private int iChangedValsinDbOnly ;
199
200 private JdbcRowSetResourceBundle resBundle;
201
202 public CachedRowSetWriter() {
203 try {
204 resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
205 } catch(IOException ioe) {
206 throw new RuntimeException(ioe);
288
289 /*
290 // Fix 6200646.
291 // Don't change the connection or transaction properties. This will fail in a
292 // J2EE container.
293 if (con.getAutoCommit() == true) {
294 con.setAutoCommit(false);
295 }
296
297 con.setTransactionIsolation(crs.getTransactionIsolation());
298 */
299
300 initSQLStatements(crs);
301 int iColCount;
302
303 RowSetMetaDataImpl rsmdWrite = (RowSetMetaDataImpl)crs.getMetaData();
304 RowSetMetaDataImpl rsmdResolv = new RowSetMetaDataImpl();
305
306 iColCount = rsmdWrite.getColumnCount();
307 int sz= crs.size()+1;
308 status = new ArrayList(sz);
309
310 status.add(0,null);
311 rsmdResolv.setColumnCount(iColCount);
312
313 for(int i =1; i <= iColCount; i++) {
314 rsmdResolv.setColumnType(i, rsmdWrite.getColumnType(i));
315 rsmdResolv.setColumnName(i, rsmdWrite.getColumnName(i));
316 rsmdResolv.setNullable(i, ResultSetMetaData.columnNullableUnknown);
317 }
318 this.crsResolve.setMetaData(rsmdResolv);
319
320 // moved outside the insert inner loop
321 //pstmtIns = con.prepareStatement(insertCmd);
322
323 if (callerColumnCount < 1) {
324 // No data, so return success.
325 if (reader.getCloseConnection() == true)
326 con.close();
327 return true;
328 }
523 * If rs has only one row we are able to
524 * uniquely identify the row where update
525 * have to happen else if more than one
526 * row implies we cannot uniquely identify the row
527 * where we have to do updates.
528 * crs.setKeyColumns needs to be set to
529 * come out of this situation.
530 */
531
532 return true;
533 }
534
535 // don't close the rs
536 // we require the record in rs to be used.
537 // rs.close();
538 // pstmt.close();
539 rs.first();
540
541 // how many fields need to be updated
542 int colsNotChanged = 0;
543 Vector cols = new Vector();
544 String updateExec = updateCmd;
545 Object orig;
546 Object curr;
547 Object rsval;
548 boolean boolNull = true;
549 Object objVal = null;
550
551 // There's only one row and the cursor
552 // needs to be on that row.
553
554 boolean first = true;
555 boolean flag = true;
556
557 this.crsResolve.moveToInsertRow();
558
559 for (i = 1; i <= callerColumnCount; i++) {
560 orig = origVals.getObject(i);
561 curr = crs.getObject(i);
562 rsval = rs.getObject(i);
563 /*
564 * the following block creates equivalent objects
565 * that would have been created if this rs is populated
566 * into a CachedRowSet so that comparison of the column values
567 * from the ResultSet and CachedRowSet are possible
568 */
569 Map map = (crs.getTypeMap() == null)?con.getTypeMap():crs.getTypeMap();
570 if (rsval instanceof Struct) {
571
572 Struct s = (Struct)rsval;
573
574 // look up the class in the map
575 Class c = null;
576 c = (Class)map.get(s.getSQLTypeName());
577 if (c != null) {
578 // create new instance of the class
579 SQLData obj = null;
580 try {
581 obj = (SQLData)c.newInstance();
582 } catch (java.lang.InstantiationException ex) {
583 throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
584 ex.getMessage()));
585 } catch (java.lang.IllegalAccessException ex) {
586 throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
587 ex.getMessage()));
588 }
589 // get the attributes from the struct
|
166 */
167 private ResultSetMetaData callerMd;
168
169 /**
170 * The number of columns in the <code>CachedRowSet</code> object
171 * for which this <code>CachedRowSetWriter</code> object is the writer.
172 *
173 * @serial
174 */
175 private int callerColumnCount;
176
177 /**
178 * This <code>CachedRowSet<code> will hold the conflicting values
179 * retrieved from the db and hold it.
180 */
181 private CachedRowSetImpl crsResolve;
182
183 /**
184 * This <code>ArrayList<code> will hold the values of SyncResolver.*
185 */
186 private ArrayList<Integer> status;
187
188 /**
189 * This will check whether the same field value has changed both
190 * in database and CachedRowSet.
191 */
192 private int iChangedValsInDbAndCRS;
193
194 /**
195 * This will hold the number of cols for which the values have
196 * changed only in database.
197 */
198 private int iChangedValsinDbOnly ;
199
200 private JdbcRowSetResourceBundle resBundle;
201
202 public CachedRowSetWriter() {
203 try {
204 resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
205 } catch(IOException ioe) {
206 throw new RuntimeException(ioe);
288
289 /*
290 // Fix 6200646.
291 // Don't change the connection or transaction properties. This will fail in a
292 // J2EE container.
293 if (con.getAutoCommit() == true) {
294 con.setAutoCommit(false);
295 }
296
297 con.setTransactionIsolation(crs.getTransactionIsolation());
298 */
299
300 initSQLStatements(crs);
301 int iColCount;
302
303 RowSetMetaDataImpl rsmdWrite = (RowSetMetaDataImpl)crs.getMetaData();
304 RowSetMetaDataImpl rsmdResolv = new RowSetMetaDataImpl();
305
306 iColCount = rsmdWrite.getColumnCount();
307 int sz= crs.size()+1;
308 status = new ArrayList<Integer>(sz);
309
310 status.add(0,null);
311 rsmdResolv.setColumnCount(iColCount);
312
313 for(int i =1; i <= iColCount; i++) {
314 rsmdResolv.setColumnType(i, rsmdWrite.getColumnType(i));
315 rsmdResolv.setColumnName(i, rsmdWrite.getColumnName(i));
316 rsmdResolv.setNullable(i, ResultSetMetaData.columnNullableUnknown);
317 }
318 this.crsResolve.setMetaData(rsmdResolv);
319
320 // moved outside the insert inner loop
321 //pstmtIns = con.prepareStatement(insertCmd);
322
323 if (callerColumnCount < 1) {
324 // No data, so return success.
325 if (reader.getCloseConnection() == true)
326 con.close();
327 return true;
328 }
523 * If rs has only one row we are able to
524 * uniquely identify the row where update
525 * have to happen else if more than one
526 * row implies we cannot uniquely identify the row
527 * where we have to do updates.
528 * crs.setKeyColumns needs to be set to
529 * come out of this situation.
530 */
531
532 return true;
533 }
534
535 // don't close the rs
536 // we require the record in rs to be used.
537 // rs.close();
538 // pstmt.close();
539 rs.first();
540
541 // how many fields need to be updated
542 int colsNotChanged = 0;
543 Vector<Integer> cols = new Vector<>();
544 String updateExec = updateCmd;
545 Object orig;
546 Object curr;
547 Object rsval;
548 boolean boolNull = true;
549 Object objVal = null;
550
551 // There's only one row and the cursor
552 // needs to be on that row.
553
554 boolean first = true;
555 boolean flag = true;
556
557 this.crsResolve.moveToInsertRow();
558
559 for (i = 1; i <= callerColumnCount; i++) {
560 orig = origVals.getObject(i);
561 curr = crs.getObject(i);
562 rsval = rs.getObject(i);
563 /*
564 * the following block creates equivalent objects
565 * that would have been created if this rs is populated
566 * into a CachedRowSet so that comparison of the column values
567 * from the ResultSet and CachedRowSet are possible
568 */
569 Map<String, Class<?>> map = (crs.getTypeMap() == null)?con.getTypeMap():crs.getTypeMap();
570 if (rsval instanceof Struct) {
571
572 Struct s = (Struct)rsval;
573
574 // look up the class in the map
575 Class c = null;
576 c = (Class)map.get(s.getSQLTypeName());
577 if (c != null) {
578 // create new instance of the class
579 SQLData obj = null;
580 try {
581 obj = (SQLData)c.newInstance();
582 } catch (java.lang.InstantiationException ex) {
583 throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
584 ex.getMessage()));
585 } catch (java.lang.IllegalAccessException ex) {
586 throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
587 ex.getMessage()));
588 }
589 // get the attributes from the struct
|