Package java.sql

Examples of java.sql.Struct


          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()));
          }
          rs2.close();
        }
      }
    }
View Full Code Here


          while (arrayResultSet.next())
          {
            // Get the underlying structure from the database. Oracle returns the structure in the
            // second column of the array's ResultSet
            Struct struct = (Struct) arrayResultSet.getObject(2);
            Object[] attributes = struct.getAttributes();

            GenericRecord avroElement = avroArray.get(i++);

            // Iterate over the fields in the JSON array of fields.
            // We can read the structure elements only by position, not by field name, so we
View Full Code Here

          GenericRecord elemRecord = new GenericData.Record(elementSchema);
          avroArray.add(elemRecord);

          // Get the underlying structure from the database. Oracle returns the structure in the
          // second column of the array's ResultSet
          Struct struct = (Struct) arrayResultSet.getObject(2);
          putOracleRecord(elemRecord, elementSchema, struct);
        }
      }
      finally
      {
View Full Code Here

     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readObject()}
     */
    public void testReadObject() throws SQLException {
        Object[] structAttributes = { "hello", Boolean.TRUE, "abc",
                Integer.valueOf(99) };
        Struct struct = new MockStruct(structAttributes,
                "harmonytests.MockSQLData");
        Struct struct2 = new MockStruct(structAttributes, "not stored name");
        HashMap<String, Class<?>> types = new HashMap<String, Class<?>>();
        types.put("harmonytests.MockSQLData", MockSQLData.class);
        Object[] attributes = new Object[] { struct, struct2, null, "xyz" };
        SQLInputImpl impl = new SQLInputImpl(attributes, types);
        Object obj = impl.readObject();
View Full Code Here

    Map<String, Object> structMap = new HashMap<String, Object>();
    Map<String, PropertyDescriptor> propertyDescriptors;
    OracleStructDescriptor structDescriptor;
    ResultSetMetaData metaData;
    int attributeCount;
    Struct structValue;

    structDescriptor = new OracleStructDescriptor(structName, connection);
    metaData = structDescriptor.getMetaData();

    attributeCount = structDescriptor.getLength();
View Full Code Here

    /**
     * @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeStruct(java.sql.Struct)}
     */
    public void test_writeStructLjava_sql_Struct() throws SQLException {
        Struct struct = new MockStruct(new Object[] {}, "mockStruct1");
        impl.writeStruct(struct);
        assertEquals(1, attr.size());
        assertTrue(attr.get(0) instanceof SerialStruct);
        SerialStruct ss = (SerialStruct) attr.get(0);
        assertEquals(0, ss.getAttributes().length);
View Full Code Here

                    .get("NCL"), rs.getString(10));
                assertEquals("NVarChar did not match for row " + id, fields
                    .get("NVC"), rs.getString(11));
                assertEquals("RowId did not match for row " + id, fields
                    .get("R"), new String(rs.getRowId(12).getBytes()));
                Struct url = (Struct) rs.getObject(13); // TODO: Find a fix for
                                                        // this workaround
                String urlString = (String) url.getAttributes()[0];
                if (url.getSQLTypeName().equals("SYS.HTTPURITYPE")) {
                  urlString = "http://" + urlString;
                } else if (url.getSQLTypeName().equals("SYS.DBURITYPE")) {
                  urlString = "/ORADB" + urlString;
                }
                assertEquals("UriType did not match for row " + id, fields
                    .get("U"), urlString);
                assertEquals("Interval Year to Month did not match for row "
View Full Code Here

        test(expectedArray[c], actualArray[c]);
      }
    }
    else if (expected instanceof Struct) {

      Struct expectedStruct = (Struct) expected;
      Object[] expectedAttrs = expectedStruct.getAttributes();

      Struct actualStruct = (Struct) actual;
      Object[] actualAttrs = actualStruct.getAttributes();

      assertEquals("Record Length", expectedAttrs.length, actualAttrs.length);
      for (int c = 0; c < expectedAttrs.length; ++c) {
        test(expectedAttrs[c], actualAttrs[c]);
      }
    }
    else if (expected instanceof Record) {

      Record expectedStruct = (Record) expected;
      Object[] expectedAttrs = expectedStruct.getValues();

      Record actualStruct = (Record) actual;
      Object[] actualAttrs = actualStruct.getValues();

      assertEquals("Record Length", expectedAttrs.length, actualAttrs.length);
      for (int c = 0; c < expectedAttrs.length; ++c) {
        test(expectedAttrs[c], actualAttrs[c]);
      }
View Full Code Here

      Object[] attributeVals;

      if (val instanceof Struct) {

        Struct struct = (Struct) val;
        attributeVals = struct.getAttributes();
      }
      else if (SQLData.class.isInstance(val)) {

        PGSQLOutputImpl out = new PGSQLOutputImpl(connection, compType);
View Full Code Here

      Object[] attributeVals;

      if (val instanceof Struct) {

        Struct struct = (Struct) val;
        attributeVals = struct.getAttributes();
      }
      else if (val instanceof Record) {

        Record record = (Record) val;
        attributeVals = record.getValues();
View Full Code Here

TOP

Related Classes of java.sql.Struct

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.