Package java.sql

Examples of java.sql.DatabaseMetaData


      closeConnection();
    }
   
    @Test public void testDatabaseMetaDataColumns1() throws Exception {
      Connection conn = getConnection(VDB, DQP_PROP_FILE);
      DatabaseMetaData metadata = conn.getMetaData();
      this.internalResultSet = metadata.getColumns(null, null, "%smalla", "%"); //$NON-NLS-1$ //$NON-NLS-2$
      assertResults(new String[] {
          "TABLE_CAT[string]    TABLE_SCHEM[string]    TABLE_NAME[string]    COLUMN_NAME[string]    DATA_TYPE[short]    TYPE_NAME[string]    COLUMN_SIZE[integer]    BUFFER_LENGTH[string]    DECIMAL_DIGITS[integer]    NUM_PREC_RADIX[integer]    NULLABLE[integer]    REMARKS[string]    COLUMN_DEF[string]    SQL_DATA_TYPE[string]    SQL_DATETIME_SUB[string]    CHAR_OCTET_LENGTH[integer]    ORDINAL_POSITION[integer]    IS_NULLABLE[string]    SCOPE_CATALOG[string]    SCOPE_SCHEMA[string]    SCOPE_TABLE[string]    SOURCE_DATA_TYPE[string]    IS_AUTOINCREMENT[string]", //$NON-NLS-1$
          "VDBLess    Derby    SMALLA    INTKEY    4    integer    10    null    0    10    0        null    null    null    0    1    YES    null    null    null    null    NO", //$NON-NLS-1$
          "VDBLess    Derby    SMALLA    STRINGKEY    12    string    4000    null    0    0    0        null    null    null    20    2    YES    null    null    null    null    NO", //$NON-NLS-1$
          "VDBLess    Derby    SMALLA    INTNUM    4    integer    10    null    0    10    1        null    null    null    0    3    NO    null    null    null    null    NO", //$NON-NLS-1$
View Full Code Here


      closeConnection();
    }
   
    @Test public void testDatabaseMetaDataPrimaryKeys() throws Exception {
      Connection conn = getConnection(VDB, DQP_PROP_FILE);
      DatabaseMetaData metadata = conn.getMetaData();
      //note - the use of null for the table name is a little against spec
      this.internalResultSet = metadata.getPrimaryKeys(null, null, null);
      assertResults(new String[] {
             "TABLE_CAT[string]    TABLE_SCHEM[string]    TABLE_NAME[string]    COLUMN_NAME[string]    KEY_SEQ[short]    PK_NAME[string]", //$NON-NLS-1$
             "VDBLess    Derby    FLIGHTS    FLIGHT_ID    1    SQL090709161814150", //$NON-NLS-1$
             "VDBLess    Derby    FLTAVAIL    FLIGHT_ID    1    FLTAVAIL_PK", //$NON-NLS-1$
           "VDBLess    Derby    SMALLA    INTKEY    1    SQL060110103634070", //$NON-NLS-1$
View Full Code Here

      closeConnection();
    }
   
    @Test public void testDatabaseMetaDataExportedKeys() throws Exception {
      Connection conn = getConnection(VDB, DQP_PROP_FILE);
      DatabaseMetaData metadata = conn.getMetaData();
      this.internalResultSet = metadata.getExportedKeys("VDBLess", "Derby", "FLIGHTS"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      assertResults(new String[] {
          "PKTABLE_CAT[string]    PKTABLE_SCHEM[string]    PKTABLE_NAME[string]    PKCOLUMN_NAME[string]    FKTABLE_CAT[string]    FKTABLE_SCHEM[string]    FKTABLE_NAME[string]    FKCOLUMN_NAME[string]    KEY_SEQ[short]    UPDATE_RULE[integer]    DELETE_RULE[integer]    FK_NAME[string]    PK_NAME[string]    DEFERRABILITY[integer]", //$NON-NLS-1$
                "VDBLess    Derby    FLIGHTS    FLIGHT_ID    VDBLess    Derby    FLTAVAIL    FLIGHT_ID    1    3    3    FLTS_FK    SQL090709161814150    5", //$NON-NLS-1$
          "VDBLess    Derby    FLIGHTS    SEGMENT_NUMBER    VDBLess    Derby    FLTAVAIL    SEGMENT_NUMBER    2    3    3    FLTS_FK    SQL090709161814150    5" //$NON-NLS-1$
      });
View Full Code Here

      closeConnection();
    }
   
    @Test public void testDatabaseMetaDataImportedKeys() throws Exception {
      Connection conn = getConnection(VDB, DQP_PROP_FILE);
      DatabaseMetaData metadata = conn.getMetaData();
      this.internalResultSet = metadata.getImportedKeys("VDBLess", "Derby", "FLTAVAIL"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      assertResults(new String[] {
          "PKTABLE_CAT[string]    PKTABLE_SCHEM[string]    PKTABLE_NAME[string]    PKCOLUMN_NAME[string]    FKTABLE_CAT[string]    FKTABLE_SCHEM[string]    FKTABLE_NAME[string]    FKCOLUMN_NAME[string]    KEY_SEQ[short]    UPDATE_RULE[integer]    DELETE_RULE[integer]    FK_NAME[string]    PK_NAME[string]    DEFERRABILITY[integer]", //$NON-NLS-1$
          "VDBLess    Derby    FLIGHTS    FLIGHT_ID    VDBLess    Derby    FLTAVAIL    FLIGHT_ID    1    3    3    FLTS_FK    SQL090709161814150    5", //$NON-NLS-1$
          "VDBLess    Derby    FLIGHTS    SEGMENT_NUMBER    VDBLess    Derby    FLTAVAIL    SEGMENT_NUMBER    2    3    3    FLTS_FK    SQL090709161814150    5" //$NON-NLS-1$
      });
      this.internalResultSet = metadata.getImportedKeys(null, "Derby", "SMALLBRIDGE"); //$NON-NLS-1$ //$NON-NLS-2$
      assertResults(new String[] {
          "PKTABLE_CAT[string]    PKTABLE_SCHEM[string]    PKTABLE_NAME[string]    PKCOLUMN_NAME[string]    FKTABLE_CAT[string]    FKTABLE_SCHEM[string]    FKTABLE_NAME[string]    FKCOLUMN_NAME[string]    KEY_SEQ[short]    UPDATE_RULE[integer]    DELETE_RULE[integer]    FK_NAME[string]    PK_NAME[string]    DEFERRABILITY[integer]", //$NON-NLS-1$
                "VDBLess    Derby    SMALLA    INTKEY    VDBLess    Derby    SMALLBRIDGE    AKEY    1    3    3    SMLA_FK    SQL060110103634070    5", //$NON-NLS-1$
                "VDBLess    Derby    SMALLB    INTKEY    VDBLess    Derby    SMALLBRIDGE    BKEY    1    3    3    SMLB_FK    SQL060110103635170    5", //$NON-NLS-1$
      });
View Full Code Here

      closeConnection();
    }
   
    @Test public void testDatabaseMetaDataIndexInfo() throws Exception {
      Connection conn = getConnection(VDB, DQP_PROP_FILE);
      DatabaseMetaData metadata = conn.getMetaData();
      //note - the use of null for the table name is a little against spec
      this.internalResultSet = metadata.getIndexInfo(null, null, null, false, true);
      assertResults(new String[] {
          "TABLE_CAT[string]    TABLE_SCHEM[string]    TABLE_NAME[string]    NON_UNIQUE[boolean]    INDEX_QUALIFIER[string]    INDEX_NAME[string]    TYPE[integer]    ORDINAL_POSITION[short]    COLUMN_NAME[string]    ASC_OR_DESC[string]    CARDINALITY[integer]    PAGES[integer]    FILTER_CONDITION[string]", //$NON-NLS-1$
        "VDBLess    Derby    FLIGHTS    false    null    ORIGINDEX    0    1    ORIG_AIRPORT    null    0    1    null", //$NON-NLS-1$
        "VDBLess    Derby    FLTAVAIL    false    null    SQL090709161840271    0    1    FLIGHT_ID    null    0    1    null", //$NON-NLS-1$
        "VDBLess    Derby    FLTAVAIL    false    null    SQL090709161840271    0    2    SEGMENT_NUMBER    null    0    1    null", //$NON-NLS-1$
View Full Code Here

      closeConnection();
    }
   
    @Test public void testDatabaseMetaDataProcedures() throws Exception {
      Connection conn = getConnection(VDB, DQP_PROP_FILE);
      DatabaseMetaData metadata = conn.getMetaData();
      this.internalResultSet = metadata.getProcedures(null, "Derby", "%JAR"); //$NON-NLS-1$ //$NON-NLS-2$
      assertResults(new String[] {
          "PROCEDURE_CAT[string]    PROCEDURE_SCHEM[string]    PROCEDURE_NAME[string]    RESERVED_1[string]    RESERVED_2[string]    RESERVED_3[string]    REMARKS[string]    PROCEDURE_TYPE[short]    SPECIFIC_NAME[string]", //$NON-NLS-1$
          "VDBLess    Derby    INSTALL_JAR    null    null    null    null    1    INSTALL_JAR", //$NON-NLS-1$
          "VDBLess    Derby    REMOVE_JAR    null    null    null    null    1    REMOVE_JAR", //$NON-NLS-1$
          "VDBLess    Derby    REPLACE_JAR    null    null    null    null    1    REPLACE_JAR", //$NON-NLS-1$
View Full Code Here

      closeConnection();
    }
   
    @Test public void testDatabaseMetaDataProcedureColumns() throws Exception {
      Connection conn = getConnection(VDB, DQP_PROP_FILE);
      DatabaseMetaData metadata = conn.getMetaData();
      this.internalResultSet = metadata.getProcedureColumns(null, "Derby", "SQLUDTS", null); //$NON-NLS-1$ //$NON-NLS-2$
      assertResults(new String[] {
          "PROCEDURE_CAT[string]    PROCEDURE_SCHEM[string]    PROCEDURE_NAME[string]    COLUMN_NAME[string]    COLUMN_TYPE[short]    DATA_TYPE[integer]    TYPE_NAME[string]    PRECISION[integer]    LENGTH[integer]    SCALE[short]    RADIX[integer]    NULLABLE[integer]    REMARKS[string]    COLUMN_DEF[string]    SQL_DATA_TYPE[string]    SQL_DATETIME_SUB[string]    CHAR_OCTET_LENGTH[string]    ORDINAL_POSITION[integer]    IS_NULLABLE[string]    SPECIFIC_NAME[string]", //$NON-NLS-1$
          "VDBLess    Derby    SQLUDTS    CATALOGNAME    1    12    string    128    256    0    0    1    null    null    null    null    null    1    YES    SQLUDTS", //$NON-NLS-1$
          "VDBLess    Derby    SQLUDTS    SCHEMAPATTERN    1    12    string    128    256    0    0    1    null    null    null    null    null    2    YES    SQLUDTS", //$NON-NLS-1$
          "VDBLess    Derby    SQLUDTS    TYPENAMEPATTERN    1    12    string    128    256    0    0    1    null    null    null    null    null    3    YES    SQLUDTS", //$NON-NLS-1$
View Full Code Here

      throw new IllegalStateException("Not connected, please connect first!");
   
    if (m_Debug) {
      System.err.println("Checking if table " + tableName + " exists...");
    }
    DatabaseMetaData dbmd = m_Connection.getMetaData();
    ResultSet rs;
    if (m_checkForUpperCaseNames) {
      rs = dbmd.getTables (null, null, tableName.toUpperCase(), null);
    } else if (m_checkForLowerCaseNames) {
      rs = dbmd.getTables (null, null, tableName.toLowerCase(), null);
    } else {
      rs = dbmd.getTables (null, null, tableName, null);
    }
    boolean tableExists = rs.next();
    if (rs.next()) {
      throw new Exception("This table seems to exist more than once!");
    }
View Full Code Here

  private boolean coding;

  public _Connection(Connection conn, boolean coding) {
    this.conn = conn;
    this.coding = coding;
    DatabaseMetaData dm = null;
    try{
      dm = conn.getMetaData();
      supportTransaction = dm.supportsTransactions();
      infs = conn.getClass().getInterfaces();
      if(infs==null || infs.length==0)
         infs = IC;
    }catch(Exception e){}
  }
View Full Code Here

        rs.next();
        assertEquals(Double.NaN, rs.getDouble(1));
        assertEquals(10.0, rs.getDouble(2));
        assertEquals(15.0, rs.getDouble(3));

        DatabaseMetaData meta = conn.getMetaData();
        rs = meta.getProcedureColumns(null, null, "MEAN2", null);
        assertTrue(rs.next());
        assertEquals("FUNCTIONS", rs.getString("PROCEDURE_CAT"));
        assertEquals("PUBLIC", rs.getString("PROCEDURE_SCHEM"));
        assertEquals("MEAN2", rs.getString("PROCEDURE_NAME"));
        assertEquals("P2", rs.getString("COLUMN_NAME"));
View Full Code Here

TOP

Related Classes of java.sql.DatabaseMetaData

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.