Java Code Examples for java.sql.Ref

The following examples show how to use java.sql.Ref. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test(enabled = true)
public void test09() throws Exception {
    Ref ref = new StubRef(sqlType, hero);
    Object[] values = {ref};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Ref ref2 = sqli.readRef();
    assertTrue(ref.getObject().equals(ref2.getObject()));
    assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName()));
}
 
Example 2
Source Project: Tomcat8-Source-Read   Source File: DelegatingCallableStatement.java    License: MIT License 5 votes vote down vote up
@Override
public Ref getRef(final String parameterName) throws SQLException {
    checkOpen();
    try {
        return getDelegateCallableStatement().getRef(parameterName);
    } catch (final SQLException e) {
        handleException(e);
        return null;
    }
}
 
Example 3
Source Project: Tomcat8-Source-Read   Source File: DelegatingResultSet.java    License: MIT License 5 votes vote down vote up
@Override
public Ref getRef(final int i) throws SQLException {
    try {
        return resultSet.getRef(i);
    } catch (final SQLException e) {
        handleException(e);
        return null;
    }
}
 
Example 4
Source Project: Tomcat8-Source-Read   Source File: DelegatingResultSet.java    License: MIT License 5 votes vote down vote up
@Override
public Ref getRef(final String colName) throws SQLException {
    try {
        return resultSet.getRef(colName);
    } catch (final SQLException e) {
        handleException(e);
        return null;
    }
}
 
Example 5
Source Project: Tomcat8-Source-Read   Source File: DelegatingResultSet.java    License: MIT License 5 votes vote down vote up
@Override
public void updateRef(final int columnIndex, final Ref x) throws SQLException {
    try {
        resultSet.updateRef(columnIndex, x);
    } catch (final SQLException e) {
        handleException(e);
    }
}
 
Example 6
Source Project: Tomcat8-Source-Read   Source File: DelegatingResultSet.java    License: MIT License 5 votes vote down vote up
@Override
public void updateRef(final String columnName, final Ref x) throws SQLException {
    try {
        resultSet.updateRef(columnName, x);
    } catch (final SQLException e) {
        handleException(e);
    }
}
 
Example 7
@Test(enabled = true)
public void test07() throws Exception {
    Ref ref = new StubRef(sqlType, hero);
    outImpl.writeRef(ref);
    SerialRef sr = (SerialRef) results.get(0);
    assertTrue(hero.equals(sr.getObject()));
}
 
Example 8
protected void createDataTypesRows(RowSet crs) throws SQLException {

        Integer aInteger = 100;
        String aChar = "Oswald Cobblepot";
        Long aLong = Long.MAX_VALUE;
        Short aShort = Short.MAX_VALUE;
        Double aDouble = Double.MAX_VALUE;
        BigDecimal aBigDecimal = BigDecimal.ONE;
        Boolean aBoolean = false;
        Float aFloat = Float.MAX_VALUE;
        Byte aByte = Byte.MAX_VALUE;
        Date aDate = Date.valueOf(LocalDate.now());
        Time aTime = Time.valueOf(LocalTime.now());
        Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now());
        Array aArray = new StubArray("INTEGER", new Object[1]);
        Ref aRef = new SerialRef(new StubRef("INTEGER", query));
        byte[] bytes = new byte[10];
        crs.moveToInsertRow();
        crs.updateInt(1, aInteger);
        crs.updateString(2, aChar);
        crs.updateString(3, aChar);
        crs.updateLong(4, aLong);
        crs.updateBoolean(5, aBoolean);
        crs.updateShort(6, aShort);
        crs.updateDouble(7, aDouble);
        crs.updateBigDecimal(8, aBigDecimal);
        crs.updateFloat(9, aFloat);
        crs.updateByte(10, aByte);
        crs.updateDate(11, aDate);
        crs.updateTime(12, aTime);
        crs.updateTimestamp(13, aTimeStamp);
        crs.updateBytes(14, bytes);
        crs.updateArray(15, aArray);
        crs.updateRef(16, aRef);
        crs.updateDouble(17, aDouble);
        crs.insertRow();
        crs.moveToCurrentRow();

    }
 
Example 9
protected void createDataTypesRows(RowSet crs) throws SQLException {

        Integer aInteger = 100;
        String aChar = "Oswald Cobblepot";
        Long aLong = Long.MAX_VALUE;
        Short aShort = Short.MAX_VALUE;
        Double aDouble = Double.MAX_VALUE;
        BigDecimal aBigDecimal = BigDecimal.ONE;
        Boolean aBoolean = false;
        Float aFloat = Float.MAX_VALUE;
        Byte aByte = Byte.MAX_VALUE;
        Date aDate = Date.valueOf(LocalDate.now());
        Time aTime = Time.valueOf(LocalTime.now());
        Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now());
        Array aArray = new StubArray("INTEGER", new Object[1]);
        Ref aRef = new SerialRef(new StubRef("INTEGER", query));
        byte[] bytes = new byte[10];
        crs.moveToInsertRow();
        crs.updateInt(1, aInteger);
        crs.updateString(2, aChar);
        crs.updateString(3, aChar);
        crs.updateLong(4, aLong);
        crs.updateBoolean(5, aBoolean);
        crs.updateShort(6, aShort);
        crs.updateDouble(7, aDouble);
        crs.updateBigDecimal(8, aBigDecimal);
        crs.updateFloat(9, aFloat);
        crs.updateByte(10, aByte);
        crs.updateDate(11, aDate);
        crs.updateTime(12, aTime);
        crs.updateTimestamp(13, aTimeStamp);
        crs.updateBytes(14, bytes);
        crs.updateArray(15, aArray);
        crs.updateRef(16, aRef);
        crs.updateDouble(17, aDouble);
        crs.insertRow();
        crs.moveToCurrentRow();

    }
 
Example 10
@Test(enabled = true)
public void test07() throws Exception {
    Ref ref = new StubRef(sqlType, hero);
    outImpl.writeRef(ref);
    SerialRef sr = (SerialRef) results.get(0);
    assertTrue(hero.equals(sr.getObject()));
}
 
Example 11
@Override
public void updateRef(int columnIndex, Ref x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 12
Source Project: Tomcat8-Source-Read   Source File: Jdbc41Bridge.java    License: MIT License 4 votes vote down vote up
/**
 * 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));
    }
}
 
Example 13
@Override
public void updateRef(int columnIndex, Ref x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 14
@Override
public Ref getRef(String columnLabel) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 15
Source Project: Tomcat8-Source-Read   Source File: Statement.java    License: MIT License 4 votes vote down vote up
@Override
public Ref getRef(String parameterName) throws SQLException {
    // TODO Auto-generated method stub
    return null;
}
 
Example 16
Source Project: Tomcat8-Source-Read   Source File: Statement.java    License: MIT License 4 votes vote down vote up
@Override
public void setRef(int parameterIndex, Ref x) throws SQLException {
    // TODO Auto-generated method stub

}
 
Example 17
Source Project: TencentKona-8   Source File: StubBaseRowSet.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public Ref getRef(int columnIndex) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 18
Source Project: Tomcat8-Source-Read   Source File: ResultSet.java    License: MIT License 4 votes vote down vote up
@Override
public Ref getRef(String columnLabel) throws SQLException {
    // TODO Auto-generated method stub
    return null;
}
 
Example 19
@Override
public void updateRef(String columnLabel, Ref x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 20
Source Project: Tomcat8-Source-Read   Source File: ResultSet.java    License: MIT License 4 votes vote down vote up
@Override
public void updateRef(String columnLabel, Ref x) throws SQLException {
    // TODO Auto-generated method stub

}
 
Example 21
Source Project: micro-integrator   Source File: TResultSet.java    License: Apache License 2.0 4 votes vote down vote up
public Ref getRef(int columnIndex) throws SQLException {
    determineResultSetState();
    throw new SQLFeatureNotSupportedException("Data type is not supported");
}
 
Example 22
@Override
public Ref getRef(int columnIndex) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 23
@Override
public Ref getRef(int columnIndex) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 24
@Override
public void setRef(int i, Ref x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 25
@Override
public Ref getRef(String columnLabel) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 26
@Override
public Ref getRef(int columnIndex) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 27
@Override
public void setRef(int i, Ref x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 28
@Override
public final void updateRef(final int columnIndex, final Ref x) throws SQLException {
    throw new SQLFeatureNotSupportedException("updateXXX");
}
 
Example 29
@Override
public void updateRef(int columnIndex, Ref x) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example 30
@Override
public final void setRef(final int parameterIndex, final Ref x) throws SQLException {
    throw new SQLFeatureNotSupportedException("setRef");
}