java.sql.ResultSet#getRowId ( )源码实例Demo

下面列出了java.sql.ResultSet#getRowId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: spliceengine   文件: RowIdIT.java
@Test
public void testRowIdForJoin() throws Exception {

    ResultSet rs  = methodWatcher.executeQuery(
            String.format("select a.rowid, a.i, b.rowid, b.i from %s a, %s b where a.i=b.i",
                    this.getTableReference(TABLE1_NAME), this.getTableReference(TABLE2_NAME)));

    while (rs.next()) {
        RowId rowId = rs.getRowId(1);
        String s = rs.getString(1);
        Assert.assertTrue(s.compareToIgnoreCase(rowId.toString()) == 0);

        rowId = rs.getRowId(3);
        s = rs.getString(3);
        Assert.assertTrue(s.compareToIgnoreCase(rowId.toString()) == 0);
    }
}
 
源代码2 项目: spliceengine   文件: RowIdIT.java
@Test
@Ignore("DB-3169")
public void testCoveringIndex() throws Exception {
    ResultSet rs  = methodWatcher.executeQuery(
            String.format("select rowid, i, j from %s --SPLICE-PROPERTIES index=ti \n where i=1", this.getTableReference(TABLE3_NAME)));
    Assert.assertTrue(rs.next());
    RowId rowId1 = rs.getRowId(1);

    rs  = methodWatcher.executeQuery(
            String.format("select rowid, i from %s --SPLICE-PROPERTIES index=ti \n where i=1", this.getTableReference(TABLE3_NAME)));
    Assert.assertTrue(rs.next());
    RowId rowId2 = rs.getRowId(1);

    Assert.assertEquals(rowId1.toString(), rowId2.toString());

    rs  = methodWatcher.executeQuery(
            String.format("select rowid, i from %s --SPLICE-PROPERTIES index=null \n where i=1", this.getTableReference(TABLE3_NAME)));
    Assert.assertTrue(rs.next());
    RowId rowId3 = rs.getRowId(1);

    Assert.assertEquals(rowId1.toString(), rowId3.toString());
}
 
源代码3 项目: aceql-http   文件: ResultSetWriter.java
/**
    * Format the column as a RowId
    *
    * @param resultSet
    * @param columnIndex
    * @return
    * @throws SQLException
    * @throws IOException
    */
   private String formatRowIdColumn(ResultSet resultSet, int columnIndex) throws SQLException, IOException {
RowId rowId = resultSet.getRowId(columnIndex);

if (rowId == null) {
    return NULL;
}

String sessionId = request.getParameter(HttpParameter.SESSION_ID);
String connectionId = request.getParameter(HttpParameter.CONNECTION_ID);

ConnectionStore connectionStore = new ConnectionStore(username, sessionId, connectionId);
Connection connection = connectionStore.get();

if (connection == null) {
    throw new SQLException(SqlReturnCode.SESSION_INVALIDATED);
}

connectionStore.put(rowId);

return rowId.toString();
// RowIdHttp rowIdHttp = new RowIdHttp(rowId.hashCode(),
// rowId.getBytes());
//
// RowIdTransporter rowIdTransporter = new RowIdTransporter();
// String base64 = rowIdTransporter.toBase64(rowIdHttp);
// return base64;
   }
 
源代码4 项目: Zebra   文件: ShardResultSetMerger.java
public List<RowData> popResultSet(ResultSet rs, MergeContext mergeContext) throws SQLException {
	ArrayList<RowData> rows = new ArrayList<RowData>();
	Map<String, SQLObjectImpl> selectItemMap = resultSetColumnWapper(rs, mergeContext);
	while (rs.next()) {
		RowData row = new RowData(rs);

		for (Entry<String, SQLObjectImpl> col : selectItemMap.entrySet()) {
			String columnName = col.getKey();
			int columnIndex = rs.findColumn(columnName);
			Object value = rs.getObject(columnIndex);
			boolean wasNull = rs.wasNull();
			RowId rowId = null;
			try {
				rowId = rs.getRowId(columnIndex);
			} catch (Throwable e) {
				// ignore
			}

			ColumnData columnData = new ColumnData(columnIndex, columnName, value,
					value == null ? null : value.getClass(), rowId, wasNull);
			row.addColumn(columnData);
		}

		rows.add(row);
	}

	return rows;
}
 
源代码5 项目: spliceengine   文件: RowIdIT.java
@Test
public void testRowIdForOneTable() throws Exception {

    ResultSet rs  = methodWatcher.executeQuery(
            String.format("select rowid, i from %s", this.getTableReference(TABLE1_NAME)));

    while (rs.next()) {
        RowId rowId = rs.getRowId("rowid");
        String s = rs.getString(1);
        Assert.assertTrue(s.compareToIgnoreCase(rowId.toString()) == 0);
    }
}
 
源代码6 项目: spliceengine   文件: RowIdIT.java
@Test
public void testUpdateWithSubquery() throws Exception {

    ResultSet rs  = methodWatcher.executeQuery(
            String.format("select rowid, i from %s where i = 0", this.getTableReference(TABLE1_NAME)));

    RowId rowId1 = null;
    while (rs.next()) {
        rowId1 = rs.getRowId("rowid");
    }
    rs.close();

    methodWatcher.executeUpdate(
            String.format("update %s set i=1000 where rowid = (select rowid from %s where i = 0)",
                    this.getTableReference(TABLE1_NAME), this.getTableReference(TABLE1_NAME)));

    rs  = methodWatcher.executeQuery(
            String.format("select rowid, i from %s where i = 1000", this.getTableReference(TABLE1_NAME)));
    RowId rowId2 = null;
    while (rs.next()) {
        rowId2 = rs.getRowId("rowid");
        int i = rs.getInt("i");

        Assert.assertEquals(rowId1, rowId2);
        Assert.assertEquals(i, 1000);
    }
}
 
源代码7 项目: Tomcat8-Source-Read   文件: Jdbc41Bridge.java
/**
 * Delegates to {@link ResultSet#getObject(int, Class)} without throwing a {@link AbstractMethodError}.
 * <p>
 * If the JDBC driver does not implement {@link ResultSet#getObject(int, Class)}, then return 0.
 * </p>
 *
 * @param <T>
 *            See {@link ResultSet#getObject(int, Class)}
 * @param resultSet
 *            See {@link ResultSet#getObject(int, Class)}
 * @param columnIndex
 *            See {@link ResultSet#getObject(int, Class)}
 * @param type
 *            See {@link ResultSet#getObject(int, Class)}
 * @return See {@link ResultSet#getObject(int, Class)}
 * @throws SQLException
 *             See {@link ResultSet#getObject(int, Class)}
 * @see ResultSet#getObject(int, Class)
 */
@SuppressWarnings("unchecked")
public static <T> T getObject(final ResultSet resultSet, final int columnIndex, final Class<T> type)
        throws SQLException {
    try {
        return resultSet.getObject(columnIndex, type);
    } catch (final AbstractMethodError e) {
        if (type == String.class) {
            return (T) resultSet.getString(columnIndex);
        }
        // Numbers
        if (type == Integer.class) {
            return (T) Integer.valueOf(resultSet.getInt(columnIndex));
        }
        if (type == Long.class) {
            return (T) Long.valueOf(resultSet.getLong(columnIndex));
        }
        if (type == Double.class) {
            return (T) Double.valueOf(resultSet.getDouble(columnIndex));
        }
        if (type == Float.class) {
            return (T) Float.valueOf(resultSet.getFloat(columnIndex));
        }
        if (type == Short.class) {
            return (T) Short.valueOf(resultSet.getShort(columnIndex));
        }
        if (type == BigDecimal.class) {
            return (T) resultSet.getBigDecimal(columnIndex);
        }
        if (type == Byte.class) {
            return (T) Byte.valueOf(resultSet.getByte(columnIndex));
        }
        // Dates
        if (type == Date.class) {
            return (T) resultSet.getDate(columnIndex);
        }
        if (type == Time.class) {
            return (T) resultSet.getTime(columnIndex);
        }
        if (type == Timestamp.class) {
            return (T) resultSet.getTimestamp(columnIndex);
        }
        // Streams
        if (type == InputStream.class) {
            return (T) resultSet.getBinaryStream(columnIndex);
        }
        if (type == Reader.class) {
            return (T) resultSet.getCharacterStream(columnIndex);
        }
        // Other
        if (type == Object.class) {
            return (T) resultSet.getObject(columnIndex);
        }
        if (type == Boolean.class) {
            return (T) Boolean.valueOf(resultSet.getBoolean(columnIndex));
        }
        if (type == Array.class) {
            return (T) resultSet.getArray(columnIndex);
        }
        if (type == Blob.class) {
            return (T) resultSet.getBlob(columnIndex);
        }
        if (type == Clob.class) {
            return (T) resultSet.getClob(columnIndex);
        }
        if (type == Ref.class) {
            return (T) resultSet.getRef(columnIndex);
        }
        if (type == RowId.class) {
            return (T) resultSet.getRowId(columnIndex);
        }
        if (type == SQLXML.class) {
            return (T) resultSet.getSQLXML(columnIndex);
        }
        if (type == URL.class) {
            return (T) resultSet.getURL(columnIndex);
        }
        throw new SQLFeatureNotSupportedException(
                String.format("resultSet=%s, columnIndex=%,d, type=%s", resultSet, Integer.valueOf(columnIndex), type));
    }
}
 
源代码8 项目: Tomcat8-Source-Read   文件: Jdbc41Bridge.java
/**
 * Delegates to {@link ResultSet#getObject(String, Class)} without throwing a {@link AbstractMethodError}.
 *
 * @param <T>
 *            See {@link ResultSet#getObject(String, Class)}
 * @param resultSet
 *            See {@link ResultSet#getObject(String, Class)}
 * @param columnLabel
 *            See {@link ResultSet#getObject(String, Class)}
 * @param type
 *            See {@link ResultSet#getObject(String, Class)}
 * @return See {@link ResultSet#getObject(String, Class)}
 * @throws SQLException
 *             See {@link ResultSet#getObject(String, Class)}
 * @see ResultSet#getObject(int, Class)
 */
@SuppressWarnings("unchecked")
public static <T> T getObject(final ResultSet resultSet, final String columnLabel, final Class<T> type)
        throws SQLException {
    try {
        return resultSet.getObject(columnLabel, type);
    } catch (final AbstractMethodError e) {
        // Numbers
        if (type == Integer.class) {
            return (T) Integer.valueOf(resultSet.getInt(columnLabel));
        }
        if (type == Long.class) {
            return (T) Long.valueOf(resultSet.getLong(columnLabel));
        }
        if (type == Double.class) {
            return (T) Double.valueOf(resultSet.getDouble(columnLabel));
        }
        if (type == Float.class) {
            return (T) Float.valueOf(resultSet.getFloat(columnLabel));
        }
        if (type == Short.class) {
            return (T) Short.valueOf(resultSet.getShort(columnLabel));
        }
        if (type == BigDecimal.class) {
            return (T) resultSet.getBigDecimal(columnLabel);
        }
        if (type == Byte.class) {
            return (T) Byte.valueOf(resultSet.getByte(columnLabel));
        }
        // Dates
        if (type == Date.class) {
            return (T) resultSet.getDate(columnLabel);
        }
        if (type == Time.class) {
            return (T) resultSet.getTime(columnLabel);
        }
        if (type == Timestamp.class) {
            return (T) resultSet.getTimestamp(columnLabel);
        }
        // Streams
        if (type == InputStream.class) {
            return (T) resultSet.getBinaryStream(columnLabel);
        }
        if (type == Reader.class) {
            return (T) resultSet.getCharacterStream(columnLabel);
        }
        // Other
        if (type == Object.class) {
            return (T) resultSet.getObject(columnLabel);
        }
        if (type == Boolean.class) {
            return (T) Boolean.valueOf(resultSet.getBoolean(columnLabel));
        }
        if (type == Array.class) {
            return (T) resultSet.getArray(columnLabel);
        }
        if (type == Blob.class) {
            return (T) resultSet.getBlob(columnLabel);
        }
        if (type == Clob.class) {
            return (T) resultSet.getClob(columnLabel);
        }
        if (type == Ref.class) {
            return (T) resultSet.getRef(columnLabel);
        }
        if (type == RowId.class) {
            return (T) resultSet.getRowId(columnLabel);
        }
        if (type == SQLXML.class) {
            return (T) resultSet.getSQLXML(columnLabel);
        }
        if (type == URL.class) {
            return (T) resultSet.getURL(columnLabel);
        }
        throw new SQLFeatureNotSupportedException(
                String.format("resultSet=%s, columnLabel=%s, type=%s", resultSet, columnLabel, type));
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetRowIdForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getRowId(1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetRowIdForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getRowId("label");
    }
}
 
源代码11 项目: scipio-erp   文件: JdbcValueHandler.java
@Override
public java.sql.RowId getValue(ResultSet rs, int columnIndex) throws SQLException {
    return rs.getRowId(columnIndex);
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetRowIdForColumnIndex() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getRowId(1);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertGetRowIdForColumnLabel() throws SQLException {
    for (ResultSet each : resultSets) {
        each.getRowId("label");
    }
}
 
源代码14 项目: SimpleFlatMapper   文件: RowIdResultSetGetter.java
public RowId get(final ResultSet target) throws SQLException {
	return target.getRowId(column);
}
 
源代码15 项目: commons-dbcp   文件: Jdbc41Bridge.java
/**
 * Delegates to {@link ResultSet#getObject(int, Class)} without throwing an {@link AbstractMethodError}.
 * <p>
 * If the JDBC driver does not implement {@link ResultSet#getObject(int, Class)}, then return 0.
 * </p>
 *
 * @param <T>
 *            See {@link ResultSet#getObject(int, Class)}
 * @param resultSet
 *            See {@link ResultSet#getObject(int, Class)}
 * @param columnIndex
 *            See {@link ResultSet#getObject(int, Class)}
 * @param type
 *            See {@link ResultSet#getObject(int, Class)}
 * @return See {@link ResultSet#getObject(int, Class)}
 * @throws SQLException
 *             See {@link ResultSet#getObject(int, Class)}
 * @see ResultSet#getObject(int, Class)
 */
@SuppressWarnings("unchecked")
public static <T> T getObject(final ResultSet resultSet, final int columnIndex, final Class<T> type)
        throws SQLException {
    try {
        return resultSet.getObject(columnIndex, type);
    } catch (final AbstractMethodError e) {
        if (type == String.class) {
            return (T) resultSet.getString(columnIndex);
        }
        // Numbers
        if (type == Integer.class) {
            return (T) Integer.valueOf(resultSet.getInt(columnIndex));
        }
        if (type == Long.class) {
            return (T) Long.valueOf(resultSet.getLong(columnIndex));
        }
        if (type == Double.class) {
            return (T) Double.valueOf(resultSet.getDouble(columnIndex));
        }
        if (type == Float.class) {
            return (T) Float.valueOf(resultSet.getFloat(columnIndex));
        }
        if (type == Short.class) {
            return (T) Short.valueOf(resultSet.getShort(columnIndex));
        }
        if (type == BigDecimal.class) {
            return (T) resultSet.getBigDecimal(columnIndex);
        }
        if (type == Byte.class) {
            return (T) Byte.valueOf(resultSet.getByte(columnIndex));
        }
        // Dates
        if (type == Date.class) {
            return (T) resultSet.getDate(columnIndex);
        }
        if (type == Time.class) {
            return (T) resultSet.getTime(columnIndex);
        }
        if (type == Timestamp.class) {
            return (T) resultSet.getTimestamp(columnIndex);
        }
        // Streams
        if (type == InputStream.class) {
            return (T) resultSet.getBinaryStream(columnIndex);
        }
        if (type == Reader.class) {
            return (T) resultSet.getCharacterStream(columnIndex);
        }
        // Other
        if (type == Object.class) {
            return (T) resultSet.getObject(columnIndex);
        }
        if (type == Boolean.class) {
            return (T) Boolean.valueOf(resultSet.getBoolean(columnIndex));
        }
        if (type == Array.class) {
            return (T) resultSet.getArray(columnIndex);
        }
        if (type == Blob.class) {
            return (T) resultSet.getBlob(columnIndex);
        }
        if (type == Clob.class) {
            return (T) resultSet.getClob(columnIndex);
        }
        if (type == Ref.class) {
            return (T) resultSet.getRef(columnIndex);
        }
        if (type == RowId.class) {
            return (T) resultSet.getRowId(columnIndex);
        }
        if (type == SQLXML.class) {
            return (T) resultSet.getSQLXML(columnIndex);
        }
        if (type == URL.class) {
            return (T) resultSet.getURL(columnIndex);
        }
        throw new SQLFeatureNotSupportedException(
                String.format("resultSet=%s, columnIndex=%,d, type=%s", resultSet, columnIndex, type));
    }
}
 
源代码16 项目: commons-dbcp   文件: Jdbc41Bridge.java
/**
 * Delegates to {@link ResultSet#getObject(String, Class)} without throwing an {@link AbstractMethodError}.
 *
 * @param <T>
 *            See {@link ResultSet#getObject(String, Class)}
 * @param resultSet
 *            See {@link ResultSet#getObject(String, Class)}
 * @param columnLabel
 *            See {@link ResultSet#getObject(String, Class)}
 * @param type
 *            See {@link ResultSet#getObject(String, Class)}
 * @return See {@link ResultSet#getObject(String, Class)}
 * @throws SQLException
 *             See {@link ResultSet#getObject(String, Class)}
 * @see ResultSet#getObject(int, Class)
 */
@SuppressWarnings("unchecked")
public static <T> T getObject(final ResultSet resultSet, final String columnLabel, final Class<T> type)
        throws SQLException {
    try {
        return resultSet.getObject(columnLabel, type);
    } catch (final AbstractMethodError e) {
        // Numbers
        if (type == Integer.class) {
            return (T) Integer.valueOf(resultSet.getInt(columnLabel));
        }
        if (type == Long.class) {
            return (T) Long.valueOf(resultSet.getLong(columnLabel));
        }
        if (type == Double.class) {
            return (T) Double.valueOf(resultSet.getDouble(columnLabel));
        }
        if (type == Float.class) {
            return (T) Float.valueOf(resultSet.getFloat(columnLabel));
        }
        if (type == Short.class) {
            return (T) Short.valueOf(resultSet.getShort(columnLabel));
        }
        if (type == BigDecimal.class) {
            return (T) resultSet.getBigDecimal(columnLabel);
        }
        if (type == Byte.class) {
            return (T) Byte.valueOf(resultSet.getByte(columnLabel));
        }
        // Dates
        if (type == Date.class) {
            return (T) resultSet.getDate(columnLabel);
        }
        if (type == Time.class) {
            return (T) resultSet.getTime(columnLabel);
        }
        if (type == Timestamp.class) {
            return (T) resultSet.getTimestamp(columnLabel);
        }
        // Streams
        if (type == InputStream.class) {
            return (T) resultSet.getBinaryStream(columnLabel);
        }
        if (type == Reader.class) {
            return (T) resultSet.getCharacterStream(columnLabel);
        }
        // Other
        if (type == Object.class) {
            return (T) resultSet.getObject(columnLabel);
        }
        if (type == Boolean.class) {
            return (T) Boolean.valueOf(resultSet.getBoolean(columnLabel));
        }
        if (type == Array.class) {
            return (T) resultSet.getArray(columnLabel);
        }
        if (type == Blob.class) {
            return (T) resultSet.getBlob(columnLabel);
        }
        if (type == Clob.class) {
            return (T) resultSet.getClob(columnLabel);
        }
        if (type == Ref.class) {
            return (T) resultSet.getRef(columnLabel);
        }
        if (type == RowId.class) {
            return (T) resultSet.getRowId(columnLabel);
        }
        if (type == SQLXML.class) {
            return (T) resultSet.getSQLXML(columnLabel);
        }
        if (type == URL.class) {
            return (T) resultSet.getURL(columnLabel);
        }
        throw new SQLFeatureNotSupportedException(
                String.format("resultSet=%s, columnLabel=%s, type=%s", resultSet, columnLabel, type));
    }
}