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


Java Array.getArray方法代碼示例

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


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

示例1: formatArrayColumn

import java.sql.Array; //導入方法依賴的package包/類
/**
    * Format the column as an java.sqlArray
    * 
    * @param resultSet
    * @param columnIndex
    * @return
    * @throws SQLException
    * @throws IOException
    */
   private String formatArrayColumn(ResultSet resultSet, int columnIndex)
    throws SQLException, IOException {
Array array = resultSet.getArray(columnIndex);

Object[] objects = (Object[]) array.getArray();
String arrayStr = "{";
for (int i = 0; i < objects.length; i++) {
    arrayStr += objects[i] + ",";
}

if (arrayStr.contains(",")) {
    arrayStr = StringUtils.substringBeforeLast(arrayStr, ",");
}

arrayStr += "}";
return arrayStr;

/*
 * ArrayHttp arrayHttp = new ArrayHttp(array); ArrayTransporter
 * arrayTransporter = new ArrayTransporter(); String base64 =
 * arrayTransporter.toBase64(arrayHttp); return base64;
 */
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:33,代碼來源:ResultSetWriter.java

示例2: nullSafeGet

import java.sql.Array; //導入方法依賴的package包/類
@Override
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
        throws HibernateException, SQLException {
    Array array = rs.getArray(names[0]);
    if (array == null) {
        return null;
    }
    Long[] javaArray = (Long[]) array.getArray();
    ArrayList<Long> result = new ArrayList<>();
    Collections.addAll(result, javaArray); //do not use Arrays.asList(), that method returns a fake ArrayList
    return result;
}
 
開發者ID:napstr,項目名稱:SqlSauce,代碼行數:13,代碼來源:ArrayListLongUserType.java

示例3: testArrayWithOffsets

import java.sql.Array; //導入方法依賴的package包/類
@Test public void testArrayWithOffsets() throws Exception {
  // Define the struct type we're creating
  ScalarType intType = ColumnMetaData.scalar(Types.INTEGER, "INTEGER", Rep.INTEGER);
  ArrayImpl.Factory factory = new ArrayFactoryImpl(Unsafe.localCalendar().getTimeZone());
  // Create some arrays from the structs
  Array array1 = factory.createArray(intType, Arrays.<Object>asList(1, 2));
  Array array3 = factory.createArray(intType, Arrays.<Object>asList(4, 5, 6));

  Object[] data = (Object[]) array1.getArray(2, 1);
  assertEquals(1, data.length);
  assertEquals(2, data[0]);
  data = (Object[]) array3.getArray(1, 1);
  assertEquals(1, data.length);
  assertEquals(4, data[0]);
  data = (Object[]) array3.getArray(2, 2);
  assertEquals(2, data.length);
  assertEquals(5, data[0]);
  assertEquals(6, data[1]);
  data = (Object[]) array3.getArray(1, 3);
  assertEquals(3, data.length);
  assertEquals(4, data[0]);
  assertEquals(5, data[1]);
  assertEquals(6, data[2]);
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:25,代碼來源:ArrayImplTest.java

示例4: fromSqlArray

import java.sql.Array; //導入方法依賴的package包/類
public Event fromSqlArray ( final Array array ) throws SQLException, ParseException
{
    final DateFormat isoDateFormat = new SimpleDateFormat ( isoDatePatterrn );
    final EventBuilder eb = Event.create ();
    final String[] fields = (String[])array.getArray ();
    for ( int i = 0; i < fields.length; i += 2 )
    {
        final String key = fields[i];
        final String value = fields[i + 1];

        if ( key.equals ( "id" ) )
        {
            eb.id ( UUID.fromString ( value ) );
        }
        else if ( key.equals ( "sourceTimestamp" ) )
        {
            eb.sourceTimestamp ( isoDateFormat.parse ( value ) );
        }
        else if ( key.equals ( "entryTimestamp" ) )
        {
            eb.entryTimestamp ( isoDateFormat.parse ( value ) );
        }
        else
        {
            eb.attribute ( key, VariantEditor.toVariant ( value ) );
        }
    }
    return eb.build ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:30,代碼來源:EventConverter.java

示例5: convertAccessTypes

import java.sql.Array; //導入方法依賴的package包/類
public static Set<Access> convertAccessTypes(ResultSet rs, String fieldName) throws SQLException {
	Array accessTypeArray = rs.getArray(fieldName);
	if (accessTypeArray != null) {
		Integer[] accessTypeIds = (Integer[]) accessTypeArray.getArray();
		int[] accessTypeIds2 = new int[accessTypeIds.length];
		for (int i=0; i<accessTypeIds.length; i++) {
			accessTypeIds2[i] = accessTypeIds[i];
		}
		return Access.getAccessTypes(accessTypeIds2);
	} else {
		return null;
	}
}
 
開發者ID:graphium-project,項目名稱:graphium,代碼行數:14,代碼來源:RowMapperUtils.java

示例6: getArray

import java.sql.Array; //導入方法依賴的package包/類
private Object[] getArray(Array array) {

        if (array == null) {
            return null;
        }

        try {
            return (Object[]) array.getArray();
        } catch (Exception e) {
        }

        return null;
    }
 
開發者ID:ling49043171,項目名稱:mark-framework,代碼行數:14,代碼來源:ArrayTypeHandler.java

示例7: getArray

import java.sql.Array; //導入方法依賴的package包/類
@Override
public <T> T[] getArray(String columnName, Class<T> arrayElement) throws WrapperAccessException {
    try {
        Array arr = rs.getArray(columnName);
        if (arr != null) {
            @SuppressWarnings("unchecked")
            T[] ret = (T[]) arr.getArray();
            return ret;
        }
        return null;
    } catch (SQLException ex) {
        throw new WrapperAccessException(ex.getLocalizedMessage(), ex);
    }
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:15,代碼來源:SQLResultSetWrapper.java

示例8: getNullableResult

import java.sql.Array; //導入方法依賴的package包/類
@Override
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
	Array array = rs.getArray(columnName);
	return array == null ? null : array.getArray();
}
 
開發者ID:xsonorg,項目名稱:tangyuan2,代碼行數:6,代碼來源:ArrayTypeHandler.java

示例9: readData

import java.sql.Array; //導入方法依賴的package包/類
public List<O2MSyncEventLog> readData(Array oraArray) throws SQLException {
	List<O2MSyncEventLog> eventLogList = null;
	Object[] eventLogArr = (Object[]) oraArray.getArray();
	if (eventLogArr != null && eventLogArr.length > 0) {
		eventLogList = new ArrayList<O2MSyncEventLog>();
		O2MSyncEventLog eventLog = null;
		for (int i = 0; i < eventLogArr.length; i++) {
			eventLog = new O2MSyncEventLog();
			STRUCT attrArrStruct = (STRUCT) eventLogArr[i];
			Object [] attrArr = attrArrStruct.getAttributes();
			eventLog.setLogId(new ObjectId());
			eventLog.setEventId(String.valueOf(attrArr[0]).trim());
			eventLog.setOperation(String.valueOf(attrArr[1]));
			java.sql.Timestamp crOn = (java.sql.Timestamp) attrArr[2];
			if (crOn != null) {
				eventLog.setCrOn(new Date(crOn.getTime()));
			} else {
				eventLog.setCrOn(new Date());
			}
			ARRAY oraFilters = (ARRAY) attrArr[6];
			Object[] filterStructArr = (Object[]) oraFilters.getOracleArray();
			if (filterStructArr != null && filterStructArr.length > 0) {
				List<O2MSyncEventInfo> filterList = new ArrayList<O2MSyncEventInfo>();
				O2MSyncEventInfo filter = null;
				for (int j = 0 ; j < filterStructArr.length; j++) {
					STRUCT filterAttrArrStruct = (STRUCT) filterStructArr[j];
					Object[] filterAttrArr = filterAttrArrStruct.getAttributes();
					filter = new O2MSyncEventInfo();
					filter.setTableName(String.valueOf(filterAttrArr[0]).trim());
					filter.setColumnName(String.valueOf(filterAttrArr[1]).trim());
					filter.setColumnValue(String.valueOf(filterAttrArr[2]));
					filterList.add(filter);
				}
				eventLog.setEventFilters(filterList);
			}
			eventLogList.add(eventLog);
		}
	}
	return eventLogList;
}
 
開發者ID:gagoyal01,項目名稱:mongodb-rdbms-sync,代碼行數:41,代碼來源:O2MSyncDataLoader.java

示例10: extractUsingArray

import java.sql.Array; //導入方法依賴的package包/類
/**
 * Converts an Array into a List using {@link Array#getArray()}. This implementation assumes
 * a non-nested array. Use {link {@link #extractUsingResultSet(Array, Calendar)} if nested
 * arrays may be possible.
 */
static List<?> extractUsingArray(Array array, Calendar calendar) throws SQLException {
  // No option but to guess as to what the type actually is...
  Object o = array.getArray();
  if (o instanceof List) {
    return (List<?>) o;
  }
  // Assume that it's a Java array.
  return AvaticaUtils.primitiveList(o);
}
 
開發者ID:apache,項目名稱:calcite-avatica,代碼行數:15,代碼來源:JdbcResultSet.java

示例11: setArray

import java.sql.Array; //導入方法依賴的package包/類
/**
 * <!-- start generic documentation -->
 * Sets the designated parameter to the given <code>java.sql.Array</code> object.
 * The driver converts this to an SQL <code>ARRAY</code> value when it
 * sends it to the database.
 * <!-- end generic documentation -->
 *
 * <!-- start release-specific documentation -->
 * <div class="ReleaseSpecificDocumentation">
 * <h3>HSQLDB-Specific Information:</h3> <p>
 *
 * From version 2.0, HSQLDB supports the SQL ARRAY type.
 *
 * </div>
 * <!-- end release-specific documentation -->
 *
 * @param parameterIndex the first parameter is 1, the second is 2, ...
 * @param x an <code>Array</code> object that maps an SQL <code>ARRAY</code> value
 * @exception SQLException if a database access error occurs or
 * this method is called on a closed <code>PreparedStatement</code>
 * @throws SQLFeatureNotSupportedException  if the JDBC driver does not support this method
 * @since JDK 1.2 (JDK 1.1.x developers: read the overview for
 *   JDBCParameterMetaData)
 */
public synchronized void setArray(int parameterIndex,
                                  Array x) throws SQLException {

    checkParameterIndex(parameterIndex);

    Type type = this.parameterMetaData.columnTypes[parameterIndex - 1];

    if (!type.isArrayType()) {
        throw JDBCUtil.sqlException(ErrorCode.X_42561);
    }

    if (x == null) {
        setParameter(parameterIndex, null);

        return;
    }

    Object[] data = null;

    if (x instanceof JDBCArray) {
        data = ((JDBCArray) x).getArrayInternal();
    } else {
        Object object = x.getArray();

        if (object instanceof Object[]) {
            Type     baseType = type.collectionBaseType();
            Object[] array    = (Object[]) object;

            data = new Object[array.length];

            for (int i = 0; i < data.length; i++) {
                data[i] = baseType.convertJavaToSQL(session, array[i]);
            }
        } else {

            // if foreign data is not Object[]
            throw JDBCUtil.notSupported();
        }
    }
    parameterValues[parameterIndex - 1] = data;
    parameterSet[parameterIndex - 1]    = Boolean.TRUE;
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:67,代碼來源:JDBCPreparedStatement.java

示例12: ArrayHttp

import java.sql.Array; //導入方法依賴的package包/類
public ArrayHttp(Array array) throws SQLException {
baseTypeName = array.getBaseTypeName();
baseType = array.getBaseType();
arrayElements = array.getArray();
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:6,代碼來源:ArrayHttp.java

示例13: setArray

import java.sql.Array; //導入方法依賴的package包/類
/**
 * <!-- start generic documentation -->
 * Sets the designated parameter to the given <code>java.sql.Array</code> object.
 * The driver converts this to an SQL <code>ARRAY</code> value when it
 * sends it to the database.
 * <!-- end generic documentation -->
 *
 * <!-- start release-specific documentation -->
 * <div class="ReleaseSpecificDocumentation">
 * <h3>HSQLDB-Specific Information:</h3> <p>
 *
 * From version 2.0, HSQLDB supports the SQL ARRAY type.
 *
 * </div>
 * <!-- end release-specific documentation -->
 *
 * @param parameterIndex the first parameter is 1, the second is 2, ...
 * @param x an <code>Array</code> object that maps an SQL <code>ARRAY</code> value
 * @exception SQLException if a database access error occurs or
 * this method is called on a closed <code>PreparedStatement</code>
 * @throws SQLFeatureNotSupportedException  if the JDBC driver does not support this method
 * @since JDK 1.2 (JDK 1.1.x developers: read the overview for
 *   JDBCParameterMetaData)
 */
public synchronized void setArray(int parameterIndex,
                                  Array x) throws SQLException {

    checkParameterIndex(parameterIndex);

    Type type = this.parameterMetaData.columnTypes[parameterIndex - 1];

    if (!type.isArrayType()) {
        throw JDBCUtil.sqlException(ErrorCode.X_42561);
    }

    if (x == null) {
        setParameter(parameterIndex, null);

        return;
    }

    Object[] data = null;

    if (x instanceof JDBCArray) {
        data = (Object[]) ((JDBCArray) x).getArrayInternal();
    } else {
        Object object = x.getArray();

        if (object instanceof Object[]) {
            Type     baseType = type.collectionBaseType();
            Object[] array    = (Object[]) object;

            data = new Object[array.length];

            for (int i = 0; i < data.length; i++) {
                data[i] = baseType.convertJavaToSQL(session, array[i]);
            }
        } else {

            // if foreign data is not Object[]
            throw JDBCUtil.notSupported();
        }
    }
    parameterValues[parameterIndex - 1] = data;
    parameterSet[parameterIndex - 1]    = Boolean.TRUE;
}
 
開發者ID:Julien35,項目名稱:dev-courses,代碼行數:67,代碼來源:JDBCPreparedStatement.java


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