當前位置: 首頁>>代碼示例>>Java>>正文


Java Struct類代碼示例

本文整理匯總了Java中java.sql.Struct的典型用法代碼示例。如果您正苦於以下問題:Java Struct類的具體用法?Java Struct怎麽用?Java Struct使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Struct類屬於java.sql包,在下文中一共展示了Struct類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getObject

import java.sql.Struct; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
    if (type == null) {
        throw SQLError.createSQLException("Type parameter can not be null", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
    }

    if (type.equals(Struct.class)) {
        throw new SQLFeatureNotSupportedException();
    } else if (type.equals(RowId.class)) {
        return (T) getRowId(columnIndex);
    } else if (type.equals(NClob.class)) {
        return (T) getNClob(columnIndex);
    } else if (type.equals(SQLXML.class)) {
        return (T) getSQLXML(columnIndex);
    }

    return super.getObject(columnIndex, type);
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:19,代碼來源:JDBC4ResultSet.java

示例2: buildJdbcJavaClassMappings

import java.sql.Struct; //導入依賴的package包/類
private static ConcurrentHashMap<Class, Integer> buildJdbcJavaClassMappings() {
	ConcurrentHashMap<Class, Integer> jdbcJavaClassMappings = new ConcurrentHashMap<Class, Integer>();

	// these mappings are the ones outlined specifically in the spec
	jdbcJavaClassMappings.put( String.class, Types.VARCHAR );
	jdbcJavaClassMappings.put( BigDecimal.class, Types.NUMERIC );
	jdbcJavaClassMappings.put( Boolean.class, Types.BIT );
	jdbcJavaClassMappings.put( Integer.class, Types.INTEGER );
	jdbcJavaClassMappings.put( Long.class, Types.BIGINT );
	jdbcJavaClassMappings.put( Float.class, Types.REAL );
	jdbcJavaClassMappings.put( Double.class, Types.DOUBLE );
	jdbcJavaClassMappings.put( byte[].class, Types.LONGVARBINARY );
	jdbcJavaClassMappings.put( java.sql.Date.class, Types.DATE );
	jdbcJavaClassMappings.put( Time.class, Types.TIME );
	jdbcJavaClassMappings.put( Timestamp.class, Types.TIMESTAMP );
	jdbcJavaClassMappings.put( Blob.class, Types.BLOB );
	jdbcJavaClassMappings.put( Clob.class, Types.CLOB );
	jdbcJavaClassMappings.put( Array.class, Types.ARRAY );
	jdbcJavaClassMappings.put( Struct.class, Types.STRUCT );
	jdbcJavaClassMappings.put( Ref.class, Types.REF );
	jdbcJavaClassMappings.put( Class.class, Types.JAVA_OBJECT );

	// additional "common sense" registrations
	jdbcJavaClassMappings.put( Character.class, Types.CHAR );
	jdbcJavaClassMappings.put( char[].class, Types.VARCHAR );
	jdbcJavaClassMappings.put( Character[].class, Types.VARCHAR );
	jdbcJavaClassMappings.put( Byte[].class, Types.LONGVARBINARY );
	jdbcJavaClassMappings.put( java.util.Date.class, Types.TIMESTAMP );
	jdbcJavaClassMappings.put( Calendar.class, Types.TIMESTAMP );

	return jdbcJavaClassMappings;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:JdbcTypeJavaClassMappings.java

示例3: getStruct

import java.sql.Struct; //導入依賴的package包/類
@Override public Struct getStruct() throws SQLException {
  final Object o = super.getObject();
  if (o == null) {
    return null;
  } else if (o instanceof StructImpl) {
    return (StructImpl) o;
  } else if (o instanceof List) {
    return new StructImpl((List) o);
  } else {
    final List<Object> list = new ArrayList<>();
    for (Accessor fieldAccessor : fieldAccessors) {
      try {
        list.add(fieldAccessor.getObject());
      } catch (SQLException e) {
        throw new RuntimeException(e);
      }
    }
    return new StructImpl(list);
  }
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:21,代碼來源:AbstractCursor.java

示例4: treatReturn

import java.sql.Struct; //導入依賴的package包/類
/**
 * Tratar o retorno vido do java
 * @param result
 * @param returnType
 * @return 
 */
@SuppressWarnings("CallToPrintStackTrace")
private static Object treatReturn (Object result, int returnType)
{
    Object currectObject = result;
    try
    {
        if (returnType == ARRAY && result instanceof Array)
        {
            Array r = (Array) result;
            currectObject = new ArrayList<> (Arrays.asList((Object [])r.getArray()));
        }
        else if (Types.STRUCT == returnType)
        {
            System.out.println("dbdkj");
            currectObject = ((Struct) result).getAttributes();
        }
    }catch(Exception ex)
    {
        ex.printStackTrace();
    }
    if(currectObject != null)
        
        System.out.println("RETURN = class{"+currectObject.getClass().getName()+"} | toString = "+currectObject.toString()+"\n");
    return currectObject;
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:32,代碼來源:Call.java

示例5: createStruct

import java.sql.Struct; //導入依賴的package包/類
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
    checkClosed();

    try {
        return ((java.sql.Connection) this.mc).createStruct(typeName, attributes);
    } catch (SQLException sqlException) {
        checkAndFireConnectionError(sqlException);
    }

    return null; // never reached, but compiler can't tell
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:12,代碼來源:JDBC4ConnectionWrapper.java

示例6: createStruct

import java.sql.Struct; //導入依賴的package包/類
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
{
	try
	{
		return realConnection.createStruct(typeName, attributes);
	}
	catch(SQLException s)
	{
		String methodCall = "createStruct(" + typeName + ", " + attributes + ")";
		reportException(methodCall, s, null);
		throw s;
	}
}
 
開發者ID:skeychen,項目名稱:dswork.jdbc,代碼行數:14,代碼來源:ConnectionSpy.java

示例7: test08

import java.sql.Struct; //導入依賴的package包/類
@Test(enabled = true)
public void test08() throws Exception {
    Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
        "Batman"};
    Struct s = new StubStruct(sqlType, attributes);
    outImpl.writeStruct(s);
    SerialStruct ss = (SerialStruct) results.get(0);
    assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes()));
    assertTrue(sqlType.equals(ss.getSQLTypeName()));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:SQLOutputImplTests.java

示例8: test11

import java.sql.Struct; //導入依賴的package包/類
@Test()
public void test11() throws Exception {
    Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
        "Batman"};
    map.put(sqlType, Class.forName("util.SuperHero"));
    Struct struct = new StubStruct(sqlType, attributes);
    Object[] values = {struct};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();

    assertTrue(hero.equals(o));

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:SQLInputImplTests.java

示例9: getObject

import java.sql.Struct; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override public <T> T getObject(Class<T> clz) throws SQLException {
  // getStruct() is not exposed on Accessor, only AccessorImpl. getObject(Class) is exposed,
  // so we can make it do the right thing (call getStruct()).
  if (clz.equals(Struct.class)) {
    return (T) getStruct();
  }
  return super.getObject(clz);
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:10,代碼來源:AbstractCursor.java

示例10: createStruct

import java.sql.Struct; //導入依賴的package包/類
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
  throwIfClosed();
  try {
    return super.createStruct(typeName, attributes);
  }
  catch (UnsupportedOperationException e) {
    throw new SQLFeatureNotSupportedException(e.getMessage(), e);
  }
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:11,代碼來源:DremioConnectionImpl.java

示例11: createStruct

import java.sql.Struct; //導入依賴的package包/類
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
{
	return checkClosedAndThrowUnsupportedException();
}
 
開發者ID:olavloite,項目名稱:spanner-jdbc,代碼行數:6,代碼來源:AbstractCloudSpannerConnection.java

示例12: createStruct

import java.sql.Struct; //導入依賴的package包/類
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
{
    checkClosed();
    throw SQLError.noSupport();
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:7,代碼來源:JDBC4Connection.java

示例13: createStruct

import java.sql.Struct; //導入依賴的package包/類
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
    return con.createStruct(typeName, attributes);
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:5,代碼來源:FilteredConnection.java

示例14: createStruct

import java.sql.Struct; //導入依賴的package包/類
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
    return conn.createStruct(typeName, attributes);
}
 
開發者ID:kumarshantanu,項目名稱:preflex,代碼行數:5,代碼來源:ConnectionWrapper.java

示例15: createStruct

import java.sql.Struct; //導入依賴的package包/類
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
    return connection.createStruct(typeName, attributes);
}
 
開發者ID:StefaniniInspiring,項目名稱:pugtsdb,代碼行數:5,代碼來源:PugConnection.java


注:本文中的java.sql.Struct類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。