protected void initMetaData(RowSetMetaData paramRowSetMetaData, ResultSetMetaData paramResultSetMetaData) throws SQLException { int i = paramResultSetMetaData.getColumnCount(); paramRowSetMetaData.setColumnCount(i); for (int j = 1; j <= i; j++) { paramRowSetMetaData.setAutoIncrement(j, paramResultSetMetaData.isAutoIncrement(j)); paramRowSetMetaData.setCaseSensitive(j, paramResultSetMetaData.isCaseSensitive(j)); paramRowSetMetaData.setCurrency(j, paramResultSetMetaData.isCurrency(j)); paramRowSetMetaData.setNullable(j, paramResultSetMetaData.isNullable(j)); paramRowSetMetaData.setSigned(j, paramResultSetMetaData.isSigned(j)); paramRowSetMetaData.setSearchable(j, paramResultSetMetaData.isSearchable(j)); paramRowSetMetaData.setColumnDisplaySize(j, paramResultSetMetaData.getColumnDisplaySize(j)); paramRowSetMetaData.setColumnLabel(j, paramResultSetMetaData.getColumnLabel(j)); paramRowSetMetaData.setColumnName(j, paramResultSetMetaData.getColumnName(j)); paramRowSetMetaData.setSchemaName(j, paramResultSetMetaData.getSchemaName(j)); paramRowSetMetaData.setPrecision(j, paramResultSetMetaData.getPrecision(j)); paramRowSetMetaData.setScale(j, paramResultSetMetaData.getScale(j)); paramRowSetMetaData.setTableName(j, paramResultSetMetaData.getTableName(j)); paramRowSetMetaData.setCatalogName(j, paramResultSetMetaData.getCatalogName(j)); paramRowSetMetaData.setColumnType(j, paramResultSetMetaData.getColumnType(j)); paramRowSetMetaData.setColumnTypeName(j, paramResultSetMetaData.getColumnTypeName(j)); } }
protected void doCopyMetaData(RowSetMetaData targetRsmd, int targetIndex, ResultSetMetaData srcRsmd, int srcIndex) throws SQLException { targetRsmd.setAutoIncrement(targetIndex, srcRsmd .isAutoIncrement(srcIndex)); targetRsmd.setCaseSensitive(targetIndex, srcRsmd .isCaseSensitive(srcIndex)); targetRsmd .setCatalogName(targetIndex, srcRsmd.getCatalogName(srcIndex)); targetRsmd.setColumnDisplaySize(targetIndex, srcRsmd .getColumnDisplaySize(srcIndex)); targetRsmd .setColumnLabel(targetIndex, srcRsmd.getColumnLabel(srcIndex)); targetRsmd.setColumnName(targetIndex, srcRsmd.getColumnName(srcIndex)); targetRsmd.setColumnType(targetIndex, srcRsmd.getColumnType(srcIndex)); targetRsmd.setColumnTypeName(targetIndex, srcRsmd .getColumnTypeName(srcIndex)); targetRsmd.setCurrency(targetIndex, srcRsmd.isCurrency(srcIndex)); targetRsmd.setNullable(targetIndex, srcRsmd.isNullable(srcIndex)); targetRsmd.setPrecision(targetIndex, srcRsmd.getPrecision(srcIndex)); targetRsmd.setScale(targetIndex, srcRsmd.getScale(srcIndex)); targetRsmd.setSchemaName(targetIndex, srcRsmd.getSchemaName(srcIndex)); targetRsmd.setSearchable(targetIndex, srcRsmd.isSearchable(srcIndex)); targetRsmd.setSigned(targetIndex, srcRsmd.isSigned(srcIndex)); targetRsmd.setTableName(targetIndex, srcRsmd.getTableName(srcIndex)); }
public void testNextPreviousConflict() throws Exception { RowSetMetaData metadata = new RowSetMetaDataImpl(); metadata.setColumnCount(DEFAULT_COLUMN_COUNT); SyncResolverImpl resolver = new SyncResolverImpl(metadata); resolver.addConflictRow( new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 1, SyncResolver.INSERT_ROW_CONFLICT); resolver.addConflictRow( new CachedRow(new Object[DEFAULT_COLUMN_COUNT]), 2, SyncResolver.INSERT_ROW_CONFLICT); assertTrue(resolver.nextConflict()); assertTrue(resolver.nextConflict()); assertFalse(resolver.nextConflict()); assertFalse(resolver.nextConflict()); assertTrue(resolver.previousConflict()); assertTrue(resolver.previousConflict()); assertFalse(resolver.previousConflict()); assertFalse(resolver.previousConflict()); }
@SuppressWarnings("unchecked") @Test public void test99() throws Exception { RowSetMetaData rsmd1 = rsmd; ResultSetMetaData rsmd2 = rsmd; Class clzz = rsmd.getClass(); assertTrue(rsmd1.isWrapperFor(clzz)); assertTrue(rsmd2.isWrapperFor(clzz)); RowSetMetaDataImpl rsmdi = (RowSetMetaDataImpl) rsmd2.unwrap(clzz); // False should be returned assertFalse(rsmd1.isWrapperFor(this.getClass())); assertFalse(rsmd2.isWrapperFor(this.getClass())); }
public void populate(ResultSet rs) throws PargresException { try { RowSetMetaData meta = new PargresRowSetMetaData(rs.getMetaData()); //DAR UMA OLHADA NISSO! //this.beforeFirst(); //this.setMetaData(meta); /*while(rs.next()) { this.moveToInsertRow(); for(int i = 1; i <= meta.getColumnCount(); i++) { //Object o = rs.getObject(i); this.setString(i,"1"); //if(o != null) // this.setObject(i,rs.getObject(i)); } this.insertRow(); }*/ this.beforeFirst(); super.populate(new FixItResultSet(rs, meta)); //if(!super.isBeforeFirst()) beforeFirst(); //rs.beforeFirst(); } catch (Exception e) { e.printStackTrace(); System.err.println(e); throw new PargresException(e.getMessage()); } }
/** * @tests {@link javax.sql.RowSetInternal#setMetaData(javax.sql.RowSetMetaData)} */ @TestTargetNew( level = TestLevel.NOT_FEASIBLE, notes = "", method = "setMetaData", args = {javax.sql.RowSetMetaData.class} ) public void testSetMetaData() { fail("Not yet implemented"); }
protected RowSetMetaData copyMetaData(ResultSetMetaData metaData) throws SQLException { RowSetMetaDataImpl rowSetMetaData = new RowSetMetaDataImpl(); rowSetMetaData.setColumnCount(metaData.getColumnCount()); for (int columnIndex = 1; columnIndex <= metaData.getColumnCount(); columnIndex++) { rowSetMetaData.setAutoIncrement(columnIndex, metaData .isAutoIncrement(columnIndex)); doCopyMetaData(rowSetMetaData, columnIndex, metaData, columnIndex); } return rowSetMetaData; }
private void composeMetaData(ResultSetMetaData rsmd, int matchColumn) throws SQLException { if (getMetaData() == null) { if (rsmd instanceof RowSetMetaData) { setMetaData((RowSetMetaData) rsmd); } else { setMetaData(copyMetaData(rsmd)); } } else { int colCount = getMetaData().getColumnCount() + rsmd.getColumnCount() - 1; RowSetMetaData rowSetMetaData = new RowSetMetaDataImpl(); rowSetMetaData.setColumnCount(colCount); for (int i = 1; i <= getMetaData().getColumnCount(); i++) { doCopyMetaData(rowSetMetaData, i, getMetaData(), i); if (i == matchColIndexs.get(0).intValue()) { rowSetMetaData.setColumnName(i, MERGED_COLUMN_NAME); } } int index = 0; for (int j = 1; j <= rsmd.getColumnCount(); j++) { if (j == matchColumn) { continue; } index++; doCopyMetaData(rowSetMetaData, getMetaData().getColumnCount() + index, rsmd, j); } setMetaData(rowSetMetaData); } }
@Override public void setMetaData(RowSetMetaData md) throws SQLException { throw new UnsupportedOperationException("Not supported yet."); }
protected void doPopulate(ResultSet rs, boolean isPaging) throws SQLException { boolean oldIsNotifyListener = isNotifyListener; isNotifyListener = false; meta = copyMetaData(rs.getMetaData()); columnCount = meta.getColumnCount(); // initial columnTypes columnTypes = new Class[columnCount]; for (int i = 1; i <= columnTypes.length; ++i) { columnTypes[i - 1] = TYPE_MAPPING.get(Integer.valueOf(meta .getColumnType(i))); } try { cursorName = rs.getCursorName(); } catch (SQLException e) { cursorName = null; // ignore } if (rs.getStatement() != null && rs.getStatement().getConnection() != null) { setTypeMap(rs.getStatement().getConnection().getTypeMap()); } /* * this method not support paging, so before readData set pageSize and * maxRowsto 0 and restore previous values after readData */ CachedRowSetReader crsReader = (CachedRowSetReader) syncProvider .getRowSetReader(); crsReader.setResultSet(rs); if (!isPaging) { int prePageSize = getPageSize(); setPageSize(0); int preMaxRows = getMaxRows(); setMaxRows(0); crsReader.readData(this); setPageSize(prePageSize); setMaxRows(preMaxRows); } else { crsReader.readData(this); } setTableName(rs.getMetaData().getTableName(1)); originalResultSet = new CachedRowSetImpl(); crsReader.setResultSet(this); crsReader.readData(originalResultSet); originalResultSet.setMetaData((RowSetMetaData) (getMetaData())); // recovery the states beforeFirst(); isNotifyListener = true; if (oldIsNotifyListener) { notifyRowSetChanged(); } }
public void setMetaData(RowSetMetaData md) throws SQLException { meta = md; }
public void testCopySchema() throws Exception { // the original's addtribute and meta data crset.setCommand("testCommand"); crset.setConcurrency(ResultSet.CONCUR_UPDATABLE); crset.setDataSourceName("testDataSource"); crset.setFetchDirection(ResultSet.FETCH_UNKNOWN); crset.setPageSize(20); crset.setMaxRows(20); crset.setTableName("USER_INFO"); /* * NOTICE: spec say copy must not has any content, but when run on RI, * if call next() before call createCopySchema(), the copy can get the * current row's data */ /* * NOTICE: when run on RI, if add the listener first, then it will go * wrong when call createCopySchema().It's said that clone failed. */ // Listener listener = new Listener(); // crset.addRowSetListener(listener); RowSetMetaData rsmd = (RowSetMetaData) crset.getMetaData(); // the copy CachedRowSet crsetCopySchema = crset.createCopySchema(); RowSetMetaData rsmdCopySchema = (RowSetMetaData) crsetCopySchema .getMetaData(); // compare the meta data between the duplicate and the original assertNotSame(crset.getMetaData(), crsetCopySchema.getMetaData()); assertNotSame(crset.getOriginal(), crsetCopySchema.getOriginal()); assertEquals("USER_INFO", crset.getTableName()); assertEquals("USER_INFO", rsmdCopySchema.getTableName(1)); assertEquals(DEFAULT_COLUMN_COUNT, rsmdCopySchema.getColumnCount()); assertEquals(rsmd.getColumnName(1), rsmdCopySchema.getColumnName(1)); // check the primary key // TODO: RI doesn't evalute the keyColumns. The value of // crset.getKeyColumns() is null. if ("true".equals(System.getProperty("Testing Harmony"))) { assertNotNull(crset.getKeyColumns()); assertEquals(0, crset.getKeyColumns().length); } else { assertNull(crset.getKeyColumns()); } // check the attributes in the duplicate. These are supposed to be the // same as the original assertFalse(crsetCopySchema.next()); assertEquals("testCommand", crsetCopySchema.getCommand()); assertEquals(ResultSet.CONCUR_UPDATABLE, crsetCopySchema .getConcurrency()); assertEquals("testDataSource", crsetCopySchema.getDataSourceName()); assertEquals(ResultSet.FETCH_UNKNOWN, crsetCopySchema .getFetchDirection()); assertEquals(20, crsetCopySchema.getPageSize()); assertEquals(20, crsetCopySchema.getMaxRows()); // fill the duplicate CachedRowSet with data, check the listener Listener listener = new Listener(); crsetCopySchema.addRowSetListener(listener); assertNull(listener.getTag()); rs = st.executeQuery("select * from USER_INFO"); crsetCopySchema.populate(rs); assertEquals("rowSetChanged", listener.getTag()); listener.clear(); // the move of the original's cursor shouldn't affect the duplicate crset.next(); assertNull(listener.getTag()); }