public ResultSet getNodesList() throws SQLException, RemoteException { PargresRowSet rs = new PargresRowSet(); RowSetMetaDataImpl meta = new RowSetMetaDataImpl(); meta.setColumnCount(1); meta.setColumnName(1, "DUMMY"); meta.setColumnType(1, Types.VARCHAR); rs.setMetaData(meta); int i = 0; for (Node node : nodes) { String item = i + ":" + node.getAddress().toString(); if(i != nodes.size() - 1) item += ";"; i++; rs.moveToInsertRow(); rs.updateString(1, item); rs.insertRow(); rs.moveToCurrentRow(); } return rs; }
public ResultSet listVirtualPartitionedTable() throws SQLException, RemoteException { int i = 0; PargresRowSet rs = new PargresRowSet(); RowSetMetaDataImpl meta = new RowSetMetaDataImpl(); meta.setColumnCount(1); meta.setColumnName(1, "DUMMY"); meta.setColumnType(1, Types.VARCHAR); rs.setMetaData(meta); for(org.pargres.commons.Range range : getMetaData().getRangeList()) { String list = i+" - "+(String)range.getTableName()+"\t: "+(String)range.getField()+ "\t[cardinality = "+range.getCardinality()+", " + "range init = "+range.getRangeInit()+", " + "range end = "+range.getRangeEnd()+"]\n"; i++; rs.moveToInsertRow(); rs.updateString(1, list); rs.insertRow(); rs.moveToCurrentRow(); } return rs; }
/** * Returns the column number of the column with the given name in this * <code>CachedRowSetImpl</code> object. This method throws an * <code>SQLException</code> if the given name is not the name of one of the * columns in this rowset. * * @param name * a <code>String</code> object that is the name of a column in * this <code>CachedRowSetImpl</code> object * @throws SQLException * if the given name does not match the name of one of the * columns in this rowset */ private int getColIdxByName(String name) throws SQLException { RowSetMD = (RowSetMetaDataImpl) this.getMetaData(); int cols = RowSetMD.getColumnCount(); for (int i = 1; i <= cols; ++i) { String colName = RowSetMD.getColumnName(i); if (colName != null) if (name.equalsIgnoreCase(colName)) return (i); else continue; } throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalcolnm").toString()); }
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())); }
private void initCoffeeHousesMetaData(CachedRowSet crs) throws SQLException { RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); /* * CREATE TABLE COFFEE_HOUSES( * STORE_ID Integer NOT NULL, * CITY VARCHAR(32), * COFFEE INTEGER NOT NULL, * MERCH INTEGER NOT NULL, * TOTAL INTEGER NOT NULL, * PRIMARY KEY (STORE_ID)) */ rsmd.setColumnCount(COFFEE_HOUSES_COLUMN_NAMES.length); for(int i = 1; i <= COFFEE_HOUSES_COLUMN_NAMES.length; i++){ rsmd.setColumnName(i, COFFEE_HOUSES_COLUMN_NAMES[i-1]); rsmd.setColumnLabel(i, rsmd.getColumnName(i)); } rsmd.setColumnType(1, Types.INTEGER); rsmd.setColumnType(2, Types.VARCHAR); rsmd.setColumnType(3, Types.INTEGER); rsmd.setColumnType(4, Types.INTEGER); rsmd.setColumnType(5, Types.INTEGER); crs.setMetaData(rsmd); crs.setTableName(COFFEE_HOUSES_TABLE); }
protected void initCoffeesMetaData(CachedRowSet crs) throws SQLException { RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); /* * CREATE TABLE COFFEES ( * COF_ID INTEGER NOT NULL, * COF_NAME VARCHAR(32) NOT NULL, * SUP_ID INTEGER NOT NULL, * PRICE NUMBERIC(10,2 NOT NULL, * SALES INTEGER NOT NULL, * TOTAL INTEGER NOT NULL, * PRIMARY KEY (COF_ID), * FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS (SUP_ID) ) */ rsmd.setColumnCount(COFFEES_COLUMN_NAMES.length); for(int i = 1; i <= COFFEES_COLUMN_NAMES.length; i++){ rsmd.setColumnName(i, COFFEES_COLUMN_NAMES[i-1]); rsmd.setColumnLabel(i, rsmd.getColumnName(i)); } rsmd.setColumnType(1, Types.INTEGER); rsmd.setColumnType(2, Types.VARCHAR); rsmd.setColumnType(3, Types.INTEGER); rsmd.setColumnType(4, Types.NUMERIC); rsmd.setPrecision(4, 10); rsmd.setScale(4, 2); rsmd.setColumnType(5, Types.INTEGER); rsmd.setColumnType(6, Types.INTEGER); crs.setMetaData(rsmd); crs.setTableName(COFFEES_TABLE); }
protected void initDataTypesMetaData(CachedRowSet crs) throws SQLException { RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); rsmd.setColumnCount(DATATYPES_COLUMN_NAMES.length); for (int i = 1; i <= DATATYPES_COLUMN_NAMES.length; i++) { rsmd.setColumnName(i, DATATYPES_COLUMN_NAMES[i - 1]); rsmd.setColumnLabel(i, rsmd.getColumnName(i)); } rsmd.setColumnType(1, Types.INTEGER); rsmd.setColumnType(2, Types.CHAR); rsmd.setColumnType(3, Types.VARCHAR); rsmd.setColumnType(4, Types.BIGINT); rsmd.setColumnType(5, Types.BOOLEAN); rsmd.setColumnType(6, Types.SMALLINT); rsmd.setColumnType(7, Types.DOUBLE); rsmd.setColumnType(8, Types.DECIMAL); rsmd.setColumnType(9, Types.REAL); rsmd.setColumnType(10, Types.TINYINT); rsmd.setColumnType(11, Types.DATE); rsmd.setColumnType(12, Types.TIME); rsmd.setColumnType(13, Types.TIMESTAMP); rsmd.setColumnType(14, Types.VARBINARY); rsmd.setColumnType(15, Types.ARRAY); rsmd.setColumnType(16, Types.REF); rsmd.setColumnType(17, Types.FLOAT); crs.setMetaData(rsmd); }
private void initSuppliersMetaData(CachedRowSet crs) throws SQLException { RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); /* * CREATE TABLE SUPPLIERS ( * SUP_ID INTEGER NOT NULL, * SUP_NAME VARCHAR(32) NOT NULL, * STREET VARCHAR(32) NOT NULL, * CITY VARCHAR(32) NOT NULL, * STATE CHAR(2) NOT NULL, * ZIP CHAR(5) NOT NULL, * PRIMARY KEY (SUP_ID)) */ rsmd.setColumnCount(6); rsmd.setColumnName(1, "SUP_ID"); rsmd.setColumnName(2, "SUP_NAME"); rsmd.setColumnName(3, "STREET"); rsmd.setColumnName(4, "CITY"); rsmd.setColumnName(5, "STATE"); rsmd.setColumnName(6, "ZIP"); rsmd.setColumnType(1, Types.INTEGER); rsmd.setColumnType(2, Types.VARCHAR); rsmd.setColumnType(3, Types.VARCHAR); rsmd.setColumnType(4, Types.VARCHAR); rsmd.setColumnType(5, Types.CHAR); rsmd.setColumnType(6, Types.CHAR); crs.setMetaData(rsmd); crs.setTableName(SUPPLIERS_TABLE); }
public HelloRowSet() throws SQLException { super(); RowSetMetaDataImpl meta = new RowSetMetaDataImpl(); meta.setColumnCount(1); meta.setColumnName(1, "DUMMY"); meta.setColumnType(1, Types.VARCHAR); this.setMetaData(meta); this.moveToInsertRow(); this.updateString(1, JdbcUtil.TEST_QUERY_RESPONSE); this.insertRow(); this.moveToCurrentRow(); }
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); } }
public void assertDeserialized(Serializable initial, Serializable deserialized) { try { RowSetMetaDataImpl initialImpl = (RowSetMetaDataImpl) initial; RowSetMetaDataImpl deserializedImpl = (RowSetMetaDataImpl) deserialized; Assert.assertEquals(initialImpl.getColumnCount(), deserializedImpl.getColumnCount()); Assert.assertEquals(initialImpl.getColumnType(1), deserializedImpl.getColumnType(1)); } catch (SQLException e) { fail(); } }
/** * @tests serialization/deserialization. */ public void test_serialization_self() throws Exception { RowSetMetaDataImpl impl = new RowSetMetaDataImpl(); impl.setColumnCount(1); impl.setColumnType(1, Types.CHAR); SerializationTest.verifySelf(impl, ROWSET_METADATA_COMPARATOR); }
/** * @tests serialization/deserialization compatibility with RI. */ public void test_serialization_compatibility() throws Exception { RowSetMetaDataImpl impl = new RowSetMetaDataImpl(); impl.setColumnCount(2); impl.setColumnType(1, Types.ARRAY); impl.setColumnType(2, Types.BIGINT); SerializationTest.verifyGolden(this, impl, ROWSET_METADATA_COMPARATOR); }
/** * @test {@link javax.sql.rowset.RowSetMetaDataImpl#unWrap(Class<T>)} */ public void test_unWrap_CClass() throws Exception { Object o = metaDataImpl.unwrap(Integer.class); assertNotNull(o); assertTrue(o instanceof RowSetMetaDataImpl); o = metaDataImpl.unwrap(Comparable.class); assertNotNull(o); assertTrue(o instanceof RowSetMetaDataImpl); o = metaDataImpl.unwrap(null); assertNotNull(o); assertTrue(o instanceof RowSetMetaDataImpl); }