Package java.sql

Examples of java.sql.Array


        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
        conn = DriverManager.getConnection(getUrl(), props);
        stmt = conn.prepareStatement("UPSERT INTO t_same_size VALUES(?,?,?)");
        stmt.setString(1, "a");
        String[] s = new String[] {"abc","def", "ghi","jkl"};
        Array array = conn.createArrayOf("VARCHAR", s);
        stmt.setArray(2, array);
        s = new String[] {"abc","def", "ghi","jkl"};
        array = conn.createArrayOf("VARCHAR", s);
        stmt.setArray(3, array);
        stmt.execute();
View Full Code Here


        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
        conn = DriverManager.getConnection(getUrl(), props);
        stmt = conn.prepareStatement("UPSERT INTO t VALUES(?,?,?)");
        stmt.setString(1, "a");
        String[] s = new String[] { "abc", "def", "ghi", "jkll" };
        Array array = conn.createArrayOf("VARCHAR", s);
        stmt.setArray(2, array);
        s = new String[] { "abc", "def", "ghi", "jklm" };
        array = conn.createArrayOf("VARCHAR", s);
        stmt.setArray(3, array);
        stmt.execute();
View Full Code Here

        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
        conn = DriverManager.getConnection(getUrl(), props);
        stmt = conn.prepareStatement("UPSERT INTO t VALUES(?,?,?)");
        stmt.setString(1, "a");
        String[] s = new String[] { "abc", "def", "ghi", "jkll", null, null, "xxx" };
        Array array = conn.createArrayOf("VARCHAR", s);
        stmt.setArray(2, array);
        s = new String[] { "abc", "def", "ghi", "jkll", null, null, null, "xxx" };
        array = conn.createArrayOf("VARCHAR", s);
        stmt.setArray(3, array);
        stmt.execute();
View Full Code Here

        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
        conn = DriverManager.getConnection(getUrl(), props);
        stmt = conn.prepareStatement("UPSERT INTO t VALUES(?,?,?)");
        stmt.setString(1, "a");
        String[] s = new String[] { "abc", "def", "ghi", "jkll", null, null, "xxx" };
        Array array = conn.createArrayOf("VARCHAR", s);
        stmt.setArray(2, array);
        s = new String[] { "abc", "def", "ghi", "jkll", null, null, null, "xxx" };
        array = conn.createArrayOf("VARCHAR", s);
        stmt.setArray(3, array);
        stmt.execute();
View Full Code Here

        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
        conn = DriverManager.getConnection(getUrl(), props);
        try {
            PreparedStatement stmt = conn.prepareStatement("select ?[2] from system.\"catalog\" limit 1");
            Array array = conn.createArrayOf("CHAR", new String[] {"a","b","c"});
            stmt.setArray(1, array);
            ResultSet rs = stmt.executeQuery();
            assertTrue(rs.next());
            assertEquals("b", rs.getString(1));
            assertFalse(rs.next());
View Full Code Here

            // Need to support primitive
            Double[] doubleArr =  new Double[2];
            doubleArr[0] = 64.87;
            doubleArr[1] = 89.96;
            //doubleArr[2] = 9.9;
            Array array = conn.createArrayOf("DOUBLE", doubleArr);
            stmt.setArray(4, array);
           
            // create character array
            String[] charArr =  new String[2];
            charArr[0] = "a";
View Full Code Here

    public Array resultSet_getArray(ResultSetProxy resultSet, int columnIndex) throws SQLException {
        if (this.pos < filterSize) {
            return nextFilter().resultSet_getArray(this, resultSet, columnIndex);
        }

        Array rawArray = resultSet.getResultSetRaw().getArray(columnIndex);

        return rawArray;
    }
View Full Code Here

    /**
     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readArray()}
     */
    public void testReadArray() throws SQLException {
        Array array = new MockArray();
        Object[] attributes = new Object[] { array };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals(array, impl.readArray());

View Full Code Here

  }

  protected Array createArray(Connection connection, String arrayName, Object value) throws SQLException {
    OracleArrayDescriptor arrayDescriptor;
    Struct[] structs;
    Array arrayValue;
    int size;

    if (value instanceof Collection<?> == false) {
      throw new UnsupportedOperationException("An array can only be created from a collection");
    }
View Full Code Here

    return convertedValue;
  }

  public <T> Set<T> getArray(Connection connection, Object value, Class<T> targetClass) throws SQLException {
    Set<T> results = new LinkedHashSet<T>();
    Array arrayValue;
    ResultSet resultSet;

    if (value instanceof Array) {
      arrayValue = (Array) value;

      resultSet = arrayValue.getResultSet();
      while (resultSet.next()) {
        Object object = resultSet.getObject(1);
        object = resultSet.getObject(2);
        if (object instanceof Struct) {
          results.add(populateStruct(connection, (Struct) object, targetClass, arrayValue.getBaseTypeName()));
        }
      }
    }

    return results;
View Full Code Here

TOP

Related Classes of java.sql.Array

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.