Java 类java.sql.SQLData 实例源码

项目:NICON    文件:Call.java   
/**
 * Essa funcoa serve para invocar uma funcao da base de dados que retorna um 
 *      Tipo costumisada e que esta mapeado com java
 * @param functionName
 * @param SQLType
 * @param javaClass
 * @param parans
 * @return 
 */
@SuppressWarnings("CallToPrintStackTrace")
public static SQLData callMapFunction (String functionName, String SQLType, Class javaClass, Object ... parans)
{
    if(!EstadoConnexao.isValid) return null;
    try 
    {
        Connection  con = new Conexao().getCon();
        Object result;

        // Criar as interoganocoes necessaria para a invocacao da funcao ex (?, ?, ?, ...) || nada
        String interogations = (parans != null && parans.length>0)? createInterogation(parans.length): "";

        //Associa ao call e o nome da funcao 
        String sql = "{? = call "+functionName+interogations+"}";

        con.getTypeMap().put(SQLType, javaClass);
        try (CallableStatement call = mapParamsType(con, sql, 2, parans)) 
        {
            call.registerOutParameter(1, Types.STRUCT, SQLType);
            call.execute();
            result = Call.treatReturn(call.getObject(1), VARCHAR);
        }
        return  (SQLData) result;

        }catch(Exception ex)
        {
            ex.printStackTrace();
        }
    return null;

}
项目:pljava    文件:Commands.java   
/**
 * Defines the mapping between an SQL type and a Java class.
 * 
 * @param sqlTypeName The name of the SQL type. The name can be
 *            qualified with a schema (namespace). If the schema is omitted,
 *            it will be resolved according to the current setting of the
 *            {@code search_path}.
 * @param javaClassName The name of the class. The class must be found in
 *            the classpath in effect for the current schema
 * @throws SQLException if the type or class cannot be found, or if the
 *            invoking user does not own the type.
 */
@Function(schema="sqlj", name="add_type_mapping", security=DEFINER)
public static void addTypeMapping(String sqlTypeName, String javaClassName)
throws SQLException
{
    PreparedStatement stmt = null;
    try
    {
        ClassLoader loader = Loader.getCurrentLoader();
        Class cls = loader.loadClass(javaClassName);
        if(!SQLData.class.isAssignableFrom(cls))
            throw new SQLException("Class " + javaClassName
                + " does not implement java.sql.SQLData");

        sqlTypeName = getFullSqlNameOwned(sqlTypeName);
        stmt = SQLUtils
            .getDefaultConnection()
            .prepareStatement(
                "INSERT INTO sqlj.typemap_entry(javaName, sqlName) VALUES(?,?)");
        stmt.setString(1, javaClassName);
        stmt.setString(2, sqlTypeName);
        stmt.executeUpdate();
    }
    catch(ClassNotFoundException e)
    {
        throw new SQLException(
            "No such class: " + javaClassName, "46103", e);
    }
    finally
    {
        SQLUtils.close(stmt);
    }
    Loader.clearSchemaLoaders();
}
项目:NICON    文件:Call.java   
/**
 * Essa funcoa serve para invocar uma funcao da base de dados que retorna um 
 *      Tipo costumisada e que esta mapeado com java
 * @param functionName
 * @param SQLType
 * @param javaClass
 * @param parans
 * @return 
 */
@SuppressWarnings("CallToPrintStackTrace")
public static SQLData callMapFunction (String functionName, String SQLType, Class javaClass, Object ... parans)
{
    if(!EstadoConnexao.isValid) return null;
    try 
    {
        Connection  con = new Conexao().getCon();
        Object result;

        // Criar as interoganocoes necessaria para a invocacao da funcao ex (?, ?, ?, ...) || nada
        String interogations = (parans != null && parans.length>0)? createInterogation(parans.length): "";

        //Associa ao call e o nome da funcao 
        String sql = "{? = call "+functionName+interogations+"}";

        con.getTypeMap().put(SQLType, javaClass);
        try (CallableStatement call = mapParamsType(con, sql, 2, parans)) 
        {
            call.registerOutParameter(1, Types.STRUCT, SQLType);
            call.execute();
            result = Call.treatReturn(call.getObject(1), VARCHAR);
        }
        return  (SQLData) result;

        }catch(Exception ex)
        {
            ex.printStackTrace();
        }
    return null;

}
项目:In-the-Box-Fork    文件:SQLOutputTest.java   
/**
 * Test method for {@link java.sql.SQLOutput#writeObject(java.sql.SQLData)}.
 */
@TestTargetNew(
  level = TestLevel.NOT_FEASIBLE,
  notes = "",
  method = "writeObject",
  args = {SQLData.class}
  )
public void testWriteObject() {
    fail("Not yet implemented");
}
项目:SimpleFlatMapper    文件:PreparedStatementIndexedSetterFactory.java   
@SuppressWarnings("unchecked")
protected  <T> IndexedSetter<PreparedStatement, T> getIndexedSetter(Type propertyType, PropertyMapping<?, ?, JdbcColumnKey, ? extends ColumnDefinition<JdbcColumnKey, ?>> arg) {
    IndexedSetter<PreparedStatement, T> setter = null;

    if (TypeHelper.isEnum(propertyType)) {
        switch (arg.getColumnKey().getSqlType()) {
            case Types.NUMERIC:
            case Types.BIGINT:
            case Types.INTEGER:
            case Types.DECIMAL:
            case Types.DOUBLE:
            case Types.FLOAT:
            case Types.SMALLINT:
            case Types.REAL:
            case Types.TINYINT:
               setter = (IndexedSetter<PreparedStatement, T>) new OrdinalEnumPreparedStatementIndexSetter();
                break;
            default:
                setter = (IndexedSetter<PreparedStatement, T>) new StringEnumPreparedStatementIndexSetter();
        }
    }

    if (setter == null) {
        Factory setterFactory = this.factoryPerClass.get(TypeHelper.toClass(propertyType));
        if (setterFactory != null) {
            setter = setterFactory.<T>getIndexedSetter(arg.getColumnKey());
        }
    }

    if (setter == null && TypeHelper.isAssignable(SQLData.class, propertyType)) {
        setter = (IndexedSetter<PreparedStatement, T>) new ObjectPreparedStatementIndexSetter();
    }

    return setter;
}
项目:cn1    文件:SQLOutputImpl.java   
/**
 * {@inheritDoc}
 * 
 * @see java.sql.SQLOutput#writeObject(SQLData)
 */
@SuppressWarnings("unchecked")
public void writeObject(SQLData theObject) throws SQLException {
    if (theObject == null) {
        attributes.addElement(null);
    } else {
        attributes
                .addElement(new SerialStruct(theObject, new HashMap(map)));
    }
}
项目:freeVM    文件:SQLOutputImpl.java   
/**
 * {@inheritDoc}
 * 
 * @see java.sql.SQLOutput#writeObject(SQLData)
 */
@SuppressWarnings("unchecked")
public void writeObject(SQLData theObject) throws SQLException {
    if (theObject == null) {
        attributes.addElement(null);
    } else {
        attributes
                .addElement(new SerialStruct(theObject, new HashMap(map)));
    }
}
项目:pljava    文件:DDRProcessor.java   
DDRProcessorImpl( ProcessingEnvironment processingEnv)
{
    elmu = processingEnv.getElementUtils();
    filr = processingEnv.getFiler();
    loca = processingEnv.getLocale();
    msgr = processingEnv.getMessager();
    opts = processingEnv.getOptions();
    srcv = processingEnv.getSourceVersion();
    typu = processingEnv.getTypeUtils();

    tmpr = new TypeMapper();

    String optv;

    optv = opts.get( "ddr.name.trusted");
    if ( null != optv )
        nameTrusted = optv;
    else
        nameTrusted = "java";

    optv = opts.get( "ddr.name.untrusted");
    if ( null != optv )
        nameUntrusted = optv;
    else
        nameUntrusted = "javaU";

    optv = opts.get( "ddr.implementor");
    if ( null != optv )
        defaultImplementor = "-".equals( optv) ? null : optv;
    else
        defaultImplementor = "PostgreSQL";

    optv = opts.get( "ddr.output");
    if ( null != optv )
        output = optv;
    else
        output = "pljava.ddr";

    TY_ITERATOR = typu.getDeclaredType(
        elmu.getTypeElement( java.util.Iterator.class.getName()));
    TY_OBJECT = typu.getDeclaredType(
        elmu.getTypeElement( Object.class.getName()));
    TY_RESULTSET = typu.getDeclaredType(
        elmu.getTypeElement( java.sql.ResultSet.class.getName()));
    TY_RESULTSETPROVIDER = typu.getDeclaredType(
        elmu.getTypeElement( ResultSetProvider.class.getName()));
    TY_RESULTSETHANDLE = typu.getDeclaredType(
        elmu.getTypeElement( ResultSetHandle.class.getName()));
    TY_SQLDATA = typu.getDeclaredType(
        elmu.getTypeElement( SQLData.class.getName()));
    TY_SQLINPUT = typu.getDeclaredType(
        elmu.getTypeElement( SQLInput.class.getName()));
    TY_SQLOUTPUT = typu.getDeclaredType(
        elmu.getTypeElement( SQLOutput.class.getName()));
    TY_STRING = typu.getDeclaredType(
        elmu.getTypeElement( String.class.getName()));
    TY_TRIGGERDATA = typu.getDeclaredType(
        elmu.getTypeElement( TriggerData.class.getName()));
    TY_VOID = typu.getNoType( TypeKind.VOID);

    AN_FUNCTION    = elmu.getTypeElement( Function.class.getName());
    AN_SQLACTION   = elmu.getTypeElement( SQLAction.class.getName());
    AN_SQLACTIONS  = elmu.getTypeElement( SQLActions.class.getName());
    AN_SQLTYPE     = elmu.getTypeElement( SQLType.class.getName());
    AN_TRIGGER     = elmu.getTypeElement( Trigger.class.getName());
    AN_BASEUDT     = elmu.getTypeElement( BaseUDT.class.getName());
    AN_MAPPEDUDT   = elmu.getTypeElement( MappedUDT.class.getName());
}
项目:pljava    文件:SQLOutputToTuple.java   
public void writeObject(SQLData value) throws SQLException
{
    this.writeValue(value);
}
项目:pljava    文件:SQLOutputToChunk.java   
@Override
public void writeObject(SQLData value) throws SQLException
{
    throw unsupportedOperationException("writeObject");
}
项目:freeVM    文件:SerialStruct.java   
public SerialStruct(SQLData in, Map<String, Class<?>> map)
        throws SerialException, NotImplementedException {
    throw new NotImplementedException();
}
项目:freeVM    文件:SQLOutputImpl.java   
public void writeObject(SQLData theObject) throws SQLException,
        NotImplementedException {
    throw new NotImplementedException();

}