Search in sources :

Example 6 with Ref

use of java.sql.Ref in project robovm by robovm.

the class OldPreparedStatementTest method testSetRef.

public void testSetRef() {
    ResultSet res = null;
    PreparedStatement ps = null;
    Ref mock = new MockRef();
    try {
        String neverExecutedQuery = "select TBlob from type;";
        ps = conn.prepareStatement(neverExecutedQuery);
        ps.setRef(1, mock);
        fail("Exception expected not supported");
    } catch (SQLException e) {
    //ok
    }
}
Also used : Ref(java.sql.Ref) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 7 with Ref

use of java.sql.Ref in project druid by alibaba.

the class ResultSetProxyImpl method getRef.

@Override
public Ref getRef(String columnLabel) throws SQLException {
    FilterChainImpl chain = createChain();
    Ref value = chain.resultSet_getRef(this, columnLabel);
    recycleFilterChain(chain);
    return value;
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) Ref(java.sql.Ref)

Example 8 with Ref

use of java.sql.Ref in project druid by alibaba.

the class ResultSetProxyImpl method getRef.

@Override
public Ref getRef(int columnIndex) throws SQLException {
    FilterChainImpl chain = createChain();
    Ref value = chain.resultSet_getRef(this, columnIndex);
    recycleFilterChain(chain);
    return value;
}
Also used : FilterChainImpl(com.alibaba.druid.filter.FilterChainImpl) Ref(java.sql.Ref)

Example 9 with Ref

use of java.sql.Ref in project dbeaver by serge-rider.

the class JDBCReferenceValueHandler method getValueFromObject.

@Override
public JDBCReference getValueFromObject(@NotNull DBCSession session, @NotNull DBSTypedObject type, Object object, boolean copy) throws DBCException {
    String typeName;
    try {
        if (object instanceof Ref) {
            typeName = ((Ref) object).getBaseTypeName();
        } else {
            typeName = type.getTypeName();
        }
    } catch (SQLException e) {
        throw new DBCException(e, session.getDataSource());
    }
    DBSDataType dataType = null;
    try {
        dataType = DBUtils.resolveDataType(session.getProgressMonitor(), session.getDataSource(), typeName);
    } catch (DBException e) {
        log.error("Error resolving data type '" + typeName + "'", e);
    }
    if (dataType == null) {
        dataType = new JDBCDataType(session.getDataSource().getContainer(), Types.REF, typeName, "Synthetic struct type for reference '" + typeName + "'", false, false, 0, 0, 0);
    }
    if (object == null) {
        return new JDBCReference(dataType, null);
    } else if (object instanceof JDBCReference) {
        return (JDBCReference) object;
    } else if (object instanceof Ref) {
        return new JDBCReference(dataType, (Ref) object);
    } else {
        throw new DBCException("Unsupported struct type: " + object.getClass().getName());
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) JDBCDataType(org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCDataType) Ref(java.sql.Ref) SQLException(java.sql.SQLException) DBSDataType(org.jkiss.dbeaver.model.struct.DBSDataType) DBCException(org.jkiss.dbeaver.model.exec.DBCException) JDBCReference(org.jkiss.dbeaver.model.impl.jdbc.data.JDBCReference)

Aggregations

Ref (java.sql.Ref)9 StubRef (util.StubRef)4 SQLException (java.sql.SQLException)3 SerialRef (javax.sql.rowset.serial.SerialRef)3 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)2 Array (java.sql.Array)2 ResultSet (java.sql.ResultSet)2 Test (org.testng.annotations.Test)2 BaseTest (util.BaseTest)2 StubArray (util.StubArray)2 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 StringBufferInputStream (java.io.StringBufferInputStream)1 StringReader (java.io.StringReader)1 BigDecimal (java.math.BigDecimal)1 Blob (java.sql.Blob)1 Clob (java.sql.Clob)1 Date (java.sql.Date)1 PreparedStatement (java.sql.PreparedStatement)1 Time (java.sql.Time)1