Package java.sql

Examples of java.sql.Array


        stat.execute("CREATE ALIAS ARRAY FOR \"" + getClass().getName() + ".getArray\"");
        rs = stat.executeQuery("CALL ARRAY()");
        assertEquals(1, rs.getMetaData().getColumnCount());
        rs.next();
        Array a = rs.getArray(1);
        Object[] array = (Object[]) a.getArray();
        assertEquals(2, array.length);
        assertEquals(0, ((Integer) array[0]).intValue());
        assertEquals("Hello", (String) array[1]);
        ResultSet rs2 = a.getResultSet();
        rs2.next();
        assertEquals(1, rs2.getInt(1));
        assertEquals(0, rs2.getInt(2));
        rs2.next();
        assertEquals(2, rs2.getInt(1));
View Full Code Here


        rs.next();
        assertEquals(1, rs.getInt(1));
        Object[] list = (Object[]) rs.getObject(2);
        assertEquals(1, ((Integer) list[0]).intValue());
        assertEquals(2, ((Integer) list[1]).intValue());
        Array array = rs.getArray(2);
        Object[] list2 = (Object[]) array.getArray();
        assertEquals(1, ((Integer) list2[0]).intValue());
        assertEquals(2, ((Integer) list2[1]).intValue());
        list2 = (Object[]) array.getArray(2, 1);
        assertEquals(2, ((Integer) list2[0]).intValue());
        rs.next();
        assertEquals(2, rs.getInt(1));
        list = (Object[]) rs.getObject(2);
        assertEquals(11, ((Integer) list[0]).intValue());
        assertEquals(12, ((Integer) list[1]).intValue());
        array = rs.getArray(2);
        list2 = (Object[]) array.getArray();
        assertEquals(11, ((Integer) list2[0]).intValue());
        assertEquals(12, ((Integer) list2[1]).intValue());
        list2 = (Object[]) array.getArray(2, 1);
        assertEquals(12, ((Integer) list2[0]).intValue());
        assertFalse(rs.next());
        stat.execute("DROP TABLE TEST");
    }
View Full Code Here

                byte[] buff = rs.getBytes(columnIndex);
                v = buff == null ? (Value) ValueNull.INSTANCE : ValueJavaObject.getNoCopy(buff);
                break;
            }
            case Value.ARRAY: {
                Array array = rs.getArray(columnIndex);
                if (array == null) {
                    return ValueNull.INSTANCE;
                }
                Object[] list = (Object[]) array.getArray();
                if (list == null) {
                    return ValueNull.INSTANCE;
                }
                int len = list.length;
                Value[] values = new Value[len];
View Full Code Here

      for(int column=1; column <= rsmd.getColumnCount(); column++)
      {
        System.out.println(column + ": " + rsmd.getColumnName(column) + " --> " + rs.getObject(column).getClass().getName());
        if(rs.getObject(column) instanceof Array)
        {
          Array arr = rs.getArray(column);
          System.out.println("\t" + arr.getBaseTypeName());
          ResultSet rs2 = arr.getResultSet();
          while(rs2.next())
          {
            System.out.println("\t" + rs2.getObject(1));
            Struct struct = (Struct) rs2.getObject(2);
            System.out.println(Arrays.toString(struct.getAttributes()));
View Full Code Here

          assertNull(f.name(), avroField);
          break;
        case ARRAY:
          GenericArray<GenericRecord> avroArray = (GenericArray<GenericRecord>)avroField;
          Schema elementSchema = fieldSchema.getElementType();
          Array array = (Array)databaseFieldValue;
          ResultSet arrayResultSet = array.getResultSet();
          int i = 0;

          while (arrayResultSet.next())
          {
            // Get the underlying structure from the database. Oracle returns the structure in the
View Full Code Here

                s += " ->";
            }

            switch(getter) {
                case 0: {o = rs.getObject(col); break;}
                case 1: {Array v=rs.getArray(col);o=v;break;}
                case 2: {InputStream v=rs.getAsciiStream(col);o=v;break;}
                case 3: {BigDecimal v=rs.getBigDecimal(col);o=v;break;}
                case 4: {InputStream v=rs.getBinaryStream(col);o=v;break;}
                case 5: {Blob v=rs.getBlob(col);o=v;break;}
                case 6: {boolean v=rs.getBoolean(col);o=new Boolean(v);break;}
                case 7: {byte v=rs.getByte(col);o=new Byte(v);break;}
                case 8: {byte[] v=rs.getBytes(col);o=v;break;}
                case 9: {Reader v=rs.getCharacterStream(col);o=v;break;}
                case 10:{Clob v=rs.getClob(col);o=v;break;}
                case 11:{Date v=rs.getDate(col);o=v; break;}
                case 12:{double v=rs.getDouble(col);o=new Double(v);break;}
                case 13:{float v=rs.getFloat(col);o=new Float(v);break;}
                case 14:{int v=rs.getInt(col);o=new Integer(v);break;}
                case 15:{long v=rs.getLong(col);o=new Long(v);break;}
                case 16:{Ref v=rs.getRef(col);o=v;break;}
                case 17:{short v=rs.getShort(col);o=new Short(v);break;}
                case 18:{String v=rs.getString(col);o=v;break;}
                case 19:{Time v=rs.getTime(col);o=v;break;}
                case 20:{Timestamp v=rs.getTimestamp(col);o=v;break;}
//        case 21:{URL v=rs.getURL(col);o=v;break;}
                default: return null;
            }
            // fixup if it contains classname (remove "random" part after @)
            String v = o.toString();
            if (v.indexOf('@') != -1) { // non standard java object.
                s += "Object'   \t: "+prettyType(o);
            } else {
                // default stringifier...
                s += "'"+v+"'    \t: "+o.getClass().getName();
            }
View Full Code Here

                    v = o == null ? ValueNull.INSTANCE : ValueJavaObject.getNoCopy(o, null);
                }
                break;
            }
            case Value.ARRAY: {
                Array array = rs.getArray(columnIndex);
                if (array == null) {
                    return ValueNull.INSTANCE;
                }
                Object[] list = (Object[]) array.getArray();
                if (list == null) {
                    return ValueNull.INSTANCE;
                }
                int len = list.length;
                Value[] values = new Value[len];
View Full Code Here

    if (dbFieldName == null)
    {
      throw new EventCreationException("array field is missing required metadata dbFieldName. "
                                       + schema.getName());
    }
    Array array;
    try
    {
      array = rs.getArray(dbFieldName);
    }
    catch (SQLException e)
View Full Code Here

            PreparedStatement ps      = connection.prepareStatement(dml2);
            Object[]          objects = new Object[] {
                "1", 3, 9
            };
            Array array = connection.createArrayOf("INTEGER", objects);

            ps.setArray(1, array);
            ps.execute();
        } catch (SQLException e) {
            e.printStackTrace();
View Full Code Here

            while ((numRead = r.read(text, 0, 1024)) != -1) {
              result.append(text, 0, numRead);
            }
            return new Text(result.toString());
          case Types.ARRAY:
            Array array = data.getArray(field);
            return writeArray(array);
          default: // All other types can be handled as strings
            Object o = data.getObject(field);
            if (o == null) return new Text("");               
            return new Text(o.toString());
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.