Examples of DatabaseMetaData


Examples of java.sql.DatabaseMetaData

   public void dumpMetaData() {
      Connection conn = null;
      try {
         if (this.isShutdown) connect(false, false);
         conn = getConnection();
         DatabaseMetaData metaData = conn.getMetaData();

         log.info("--------------- DUMP OF METADATA FOR THE DB START---------------------");
         String driverName = metaData.getDriverName();
         String productName = metaData.getDatabaseProductName();
         log.info("Driver name          :'" + driverName +"', product name: '" + productName + "'");
         log.info("max binary length    : " + metaData.getMaxBinaryLiteralLength());
         log.info("max char lit. length : " + metaData.getMaxCharLiteralLength());
         log.info("max column length    : " + metaData.getMaxColumnNameLength());
         log.info("max cols. in table   : " + metaData.getMaxColumnsInTable());
         log.info("max connections      : " + metaData.getMaxConnections());
         log.info("max statement length : " + metaData.getMaxStatementLength());
         log.info("max nr. of statements: " + metaData.getMaxStatements());
         log.info("max tablename length : " + metaData.getMaxTableNameLength());
         log.info("url                  : " + metaData.getURL());
         log.info("support for trans.   : " + metaData.supportsTransactions());
         log.info("support transactions : " + getIsolationLevel(conn));
         log.info("--------------- DUMP OF METADATA FOR THE DB END  ---------------------");

      }
      catch (XmlBlasterException ex) {
View Full Code Here

Examples of java.sql.DatabaseMetaData

      if (pool == null)
         throw new Exception("DbMetaHelper constructor: the pool is null");
      Connection conn = null;
      try {
         conn = pool.reserve();
         DatabaseMetaData meta = conn.getMetaData();
        
         this.maxProcLength = meta.getMaxProcedureNameLength();
        
         if (meta.storesLowerCaseIdentifiers())
            this.caseSense = CASE_LOWER;
         else if (meta.storesUpperCaseIdentifiers())
            this.caseSense = CASE_UPPER;
         else if (meta.storesMixedCaseIdentifiers())
            this.caseSense = CASE_MIXED;
         else
            throw new Exception("DbMetaHelper constructor: can not determine which case the identifiers are stored");
         String tmp = meta.getDatabaseProductName();
         if (tmp != null)
            this.productName = tmp.trim().toUpperCase();
         else
            this.productName = "";
      }
View Full Code Here

Examples of java.sql.DatabaseMetaData

      Connection conn = null;
      ResultSet rs = null;
      int count = 0;
      try {
         conn = pool.reserve();
         DatabaseMetaData meta = conn.getMetaData();
         if (catalog != null)
            catalog = getIdentifier(catalog.trim());
         if (schema != null)
            schema = getIdentifier(schema.trim());
         if (table != null)
            table = getIdentifier(table.trim());
         TreeMap map = new TreeMap();
         rs = meta.getColumns(catalog, schema, table, null);
         while (rs.next()) {
            int pos = rs.getInt("ORDINAL_POSITION");
            String name = rs.getString("COLUMN_NAME");
            // should already be in the correct order according to
            // javadoc but to be really sure we order it too
View Full Code Here

Examples of java.sql.DatabaseMetaData

      Connection conn = null;
      boolean success = true;
      try {
         conn = pool.reserve();
         conn.setAutoCommit(true);
         DatabaseMetaData dbmd = conn.getMetaData();
         maxStatementLength = dbmd.getMaxStatementLength();
         if (maxStatementLength < 1) {
            maxStatementLength = info.getInt("queue.persistent.maxStatementLength", 2048);
            if (first) {
               log.info("The maximum SQL statement length is not defined in JDBC meta data, we set it to " + this.maxStatementLength);
               first = false;
            }
         }

         if (!dbmd.supportsTransactions()) {
            String dbName = dbmd.getDatabaseProductName();
            log.severe("the database '" + dbName + "' does not support transactions, unpredicted results may happen");
         }

         if (!dbmd.supportsBatchUpdates()) {
            String dbName = dbmd.getDatabaseProductName();
            supportsBatch = false;
            log.fine("the database '" + dbName + "' does not support batch mode. No problem I will work whitout it");
         }
        
         // zero means not limit (to be sure we also check negative Values
         boolean logWarn = false;
         int defaultMaxNumStatements = dbmd.getMaxStatements();
         if (defaultMaxNumStatements < 1) {
            defaultMaxNumStatements = 50;
            logWarn = true;
         }
         // -queue.persistent.maxNumStatements 50
         maxNumStatements = info.getInt("maxNumStatements", defaultMaxNumStatements);
         log.info("The maximum Number of statements for this database instance are '" + this.maxNumStatements + "'");
         if (logWarn && info.getInt("maxNumStatements",-1)==-1)
            log.warning("The maxStatements returned fromt the database metadata is '0', will set the default to 50 unless you explicitly set '-maxNumStatements <num>'");

         // -queue.persistent.maxSelectLimit -1 (off)
         maxSelectLimit = info.getInt("maxSelectLimit", -1);
         if (this.maxSelectLimit > 0)
            log.info("The maximum results returned by a select is set to '" + maxSelectLimit + "' (MSSQLerver only)");

         timeout = (int)(info.getLong("queue.persistent.queryTimeout", 0L) / 1000L);
         dbAdmin = info.getBoolean("dbAdmin", true);
        
         // the property settings specific to this plugin type / version
        
         String prefix = "queue.jdbc";
         storeFactory = new XBStoreFactory(prefix);
         meatFactory = new XBMeatFactory(prefix);
         refFactory = new XBRefFactory(prefix);
         storeFactory.init(info);
         meatFactory.init(info);
         refFactory.init(info);
         storeFactory.create(conn);
         meatFactory.create(conn);
         refFactory.create(conn);
         isConnected = true;
         log.info("Using DB " + dbmd.getDatabaseProductName() + " " + dbmd.getDatabaseProductVersion() + " " + dbmd.getDriverName());
      }
      catch (XmlBlasterException ex) {
         success = false;
         throw ex;
      }
View Full Code Here

Examples of java.sql.DatabaseMetaData

   public void dumpMetaData() {
      Connection conn = null;
      boolean success = false;
      try {
         conn = pool.reserve();
         DatabaseMetaData metaData = conn.getMetaData();

         log.info("--------------- DUMP OF METADATA FOR THE DB START---------------------");
         String driverName = metaData.getDriverName();
         String productName = metaData.getDatabaseProductName();
         log.info("Driver name          :'" + driverName +"', product name: '" + productName + "'");
         log.info("max binary length    : " + metaData.getMaxBinaryLiteralLength());
         log.info("max char lit. length : " + metaData.getMaxCharLiteralLength());
         log.info("max column length    : " + metaData.getMaxColumnNameLength());
         log.info("max cols. in table   : " + metaData.getMaxColumnsInTable());
         log.info("max connections      : " + metaData.getMaxConnections());
         log.info("max statement length : " + metaData.getMaxStatementLength());
         log.info("max nr. of statements: " + metaData.getMaxStatements());
         log.info("max tablename length : " + metaData.getMaxTableNameLength());
         log.info("url                  : " + metaData.getURL());
         log.info("support for trans.   : " + metaData.supportsTransactions());
         log.info("support transactions : " + getIsolationLevel(conn));
         log.info("--------------- DUMP OF METADATA FOR THE DB END  ---------------------");
         success = true;
      }
      catch (Exception ex) {
View Full Code Here

Examples of java.sql.DatabaseMetaData

        Connection connection,
        CorePackage corePackage,
        org.omg.uml.modelmanagement.UmlPackage modelPackage)
        throws SQLException
    {
        DatabaseMetaData metadata = connection.getMetaData();
        ResultSet tableRs = metadata.getTables(
                null,
                this.schema,
                null,
                new String[] {"TABLE"});
View Full Code Here

Examples of java.sql.DatabaseMetaData

   */
  public String getPath(Connection oConn) throws SQLException {
    Statement oStmt;
    ResultSet oRSet;
    CallableStatement oCall;
    DatabaseMetaData oMDat;
    String sPath;
    String sDBMS;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin Category.getPath([Connection])" );
View Full Code Here

Examples of java.sql.DatabaseMetaData

    throws ClassNotFoundException, SQLException, NullPointerException,
           AccessControlException,UnsatisfiedLinkError,NumberFormatException {

    int i;
    Connection oConn;
    DatabaseMetaData oMData;
    Statement oAcct = null;
    ResultSet oRSet;
    String TableTypes[] = new String[1];
    DBTable oTable;
    String sCatalog;
    String sSchema;
    String sTableName;
    Iterator oTableIterator;
    String[] aExclude;

    oTableMap = new HashMap<String,DBTable>(255);
    oGlobalTableMap = oTableMap ;

    if (DebugFile.trace)
      {
      DebugFile.writeln("hipergate package build " + DBBind.VERSION);
      DebugFile.envinfo();

      DebugFile.writeln("Begin DBBind.initialize("+sProfile+")");
      DebugFile.incIdent();
      }

      sProfileName = sProfile;

      // ****************
      // Load JDBC driver
      loadDriver(oProfEnvProps);

      if (DebugFile.trace) DebugFile.writeln("Load Driver " + oProfEnvProps.getProperty("driver") + " : OK\n" );

      if (DebugFile.trace) DebugFile.writeln("Trying to connect to " + oProfEnvProps.getProperty("dburl") + " with user " + oProfEnvProps.getProperty("dbuser"));

      // **********************************************************
      // Get database connection parameters from file hipergate.cnf

      // New for v2.2 *
      try {
        DriverManager.setLoginTimeout(Integer.parseInt(oProfEnvProps.getProperty("logintimeout", "20")));
      } catch (Exception x) {
        if (DebugFile.trace) DebugFile.writeln("DriverManager.setLoginTimeout() "+x.getClass().getName()+" "+x.getMessage());
      }
      // **************

      try {
        oConn = DriverManager.getConnection(oProfEnvProps.getProperty("dburl"),
                                            oProfEnvProps.getProperty("dbuser"),
                                            oProfEnvProps.getProperty("dbpassword"));
      }
      catch (SQLException e) {
        if (DebugFile.trace) DebugFile.writeln("DriverManager.getConnection("+oProfEnvProps.getProperty("dburl")+","+oProfEnvProps.getProperty("dbuser")+", ...) SQLException [" + e.getSQLState() + "]:" + String.valueOf(e.getErrorCode()) + " " + e.getMessage());
        oConnectXcpt = new SQLException("DriverManager.getConnection("+oProfEnvProps.getProperty("dburl")+","+oProfEnvProps.getProperty("dbuser")+", ...) "+e.getMessage(), e.getSQLState(), e.getErrorCode());
        throw (SQLException) oConnectXcpt;
      }

      if (DebugFile.trace) {
        DebugFile.writeln("Database Connection to " + oProfEnvProps.getProperty("dburl") + " : OK\n" );
        DebugFile.writeln("Calling Connection.getMetaData()");
      }

      oMData = oConn.getMetaData();

      if (DebugFile.trace) DebugFile.writeln("Calling DatabaseMetaData.getDatabaseProductName()");

      sDatabaseProductName = oMData.getDatabaseProductName();

      if (DebugFile.trace) {
        DebugFile.writeln("Database is \"" + sDatabaseProductName + "\"");
        DebugFile.writeln("Product version " + oMData.getDatabaseProductVersion());
        DebugFile.writeln(oMData.getDriverName() + " " + oMData.getDriverVersion());
        DebugFile.writeln("Max connections " + String.valueOf(oMData.getMaxConnections()));
        DebugFile.writeln("Max statements " + String.valueOf(oMData.getMaxStatements()));
      }

      if (sDatabaseProductName.equals(DBMSNAME_POSTGRESQL))
        iDatabaseProductId = DBMS_POSTGRESQL;
      else if (sDatabaseProductName.equals(DBMSNAME_MSSQL))
        iDatabaseProductId = DBMS_MSSQL;
      else if (sDatabaseProductName.equals(DBMSNAME_ORACLE))
        iDatabaseProductId = DBMS_ORACLE;
      else if (sDatabaseProductName.equals(DBMSNAME_MYSQL))
        iDatabaseProductId = DBMS_MYSQL;
      else if (sDatabaseProductName.equals(DBMSNAME_ACCESS))
        iDatabaseProductId = DBMS_ACCESS;
      else if (sDatabaseProductName.equals(DBMSNAME_SQLITE))
        iDatabaseProductId = DBMS_SQLITE;
      else if (sDatabaseProductName.equals("StelsDBF JDBC driver") ||
               sDatabaseProductName.equals("HXTT DBF"))
        iDatabaseProductId = DBMS_XBASE;
      else
        iDatabaseProductId = DBMS_GENERIC;

      Functions.setForDBMS(sDatabaseProductName);

      // **********************
      // Cache database catalog

      sCatalog = oConn.getCatalog();

      if (DebugFile.trace) DebugFile.writeln("Catalog is \"" + sCatalog + "\"");

      if (DebugFile.trace) DebugFile.writeln("Gather metadata : OK" );

      sSchema = oProfEnvProps.getProperty("schema", "");

      if (DebugFile.trace) DebugFile.writeln("Schema is \"" + sSchema + "\"");

      i = 0;

      TableTypes[0] = "TABLE";

      if (DBMS_ORACLE==iDatabaseProductId) {
        aExclude = new String[]{ "AUDIT_ACTIONS", "STMT_AUDIT_OPTION_MAP", "DUAL",
        "PSTUBTBL", "USER_CS_SRS", "USER_TRANSFORM_MAP", "CS_SRS", "HELP",
        "SDO_ANGLE_UNITS", "SDO_AREA_UNITS", "SDO_DIST_UNITS", "SDO_DATUMS",
        "SDO_CMT_CBK_DML_TABLE", "SDO_CMT_CBK_FN_TABLE", "SDO_CMT_CBK_DML_TABLE",
        "SDO_PROJECTIONS", "SDO_ELLIPSOIDS", "SDO_GEOR_XMLSCHEMA_TABLE",
        "SDO_GR_MOSAIC_0", "SDO_GR_MOSAIC_1", "SDO_GR_MOSAIC_2", "SDO_GR_MOSAIC_3",
        "SDO_TOPO_RELATION_DATA", "SDO_TOPO_TRANSACT_DATA", "SDO_TXN_IDX_DELETES",
        "DO_TXN_IDX_EXP_UPD_RGN", "SDO_TXN_IDX_INSERTS", "SDO_CS_SRS", "IMPDP_STATS",
        "OLAP_SESSION_CUBES", "OLAP_SESSION_DIMS", "OLAPI_HISTORY",
        "OLAPI_IFACE_OBJECT_HISTORY", "OLAPI_IFACE_OP_HISTORY", "OLAPI_MEMORY_HEAP_HISTORY",
        "OLAPI_MEMORY_OP_HISTORY", "OLAPI_SESSION_HISTORY", "OLAPTABLEVELS","OLAPTABLEVELTUPLES",
        "OLAP_OLEDB_FUNCTIONS_PVT", "OLAP_OLEDB_KEYWORDS", "OLAP_OLEDB_MDPROPS","OLAP_OLEDB_MDPROPVALS",
        "OGIS_SPATIAL_REFERENCE_SYSTEMS", "SYSTEM_PRIVILEGE_MAP", "TABLE_PRIVILEGE_MAP" };

        if (DebugFile.trace) {
          ResultSet oSchemas = null;
          try {
            int iSchemaCount = 0;
            oSchemas = oMData.getSchemas();
            while (oSchemas.next()) {
              DebugFile.writeln("schema name = " + oSchemas.getString(1));
              iSchemaCount++;
            }
            oSchemas.close();
            oSchemas = null;
            if (0==iSchemaCount) DebugFile.writeln("no schemas found");
          }
          catch (Exception sqle) {
            try { if (null!=oSchemas) oSchemas.close();} catch (Exception ignore) {}
            DebugFile.writeln("SQLException at DatabaseMetaData.getSchemas() " + sqle.getMessage());
          }
          DebugFile.writeln("DatabaseMetaData.getTables(" + sCatalog + ", null, %, {TABLE})");
        }

        oRSet = oMData.getTables(sCatalog, null, "%", TableTypes);

        while (oRSet.next()) {

          if (oRSet.getString(3).indexOf('$')<0 && !in(oRSet.getString(3).toUpperCase(), aExclude)) {
            oTable = new DBTable(sCatalog, sSchema, oRSet.getString(3), ++i);

            sTableName = oTable.getName().toLowerCase();

            if (oTableMap.containsKey(sTableName))
              oTableMap.remove(sTableName);

            oTableMap.put(sTableName, oTable);

            if (DebugFile.trace)
              DebugFile.writeln("Reading table " + oTable.getName());
          }
          else if (DebugFile.trace)
            DebugFile.writeln("Skipping table " + oRSet.getString(3));
       } // wend

      }
      else  {
        if (DBMS_POSTGRESQL==iDatabaseProductId)
          aExclude = new String[]{ "sql_languages", "sql_features",
                                   "sql_implementation_info", "sql_packages",
                                   "sql_sizing", "sql_sizing_profiles",
                                   "pg_ts_cfg", "pg_logdir_ls",
                                   "pg_ts_cfgmap", "pg_ts_dict", "pg_ts_parses",
                                   "pg_ts_parser", "pg_reload_conf" };
        else if (DBMS_MSSQL==iDatabaseProductId)
          aExclude = new String[]{ "syscolumns", "syscomments", "sysdepends",
                                   "sysfilegroups", "sysfiles" , "sysfiles1",
                                   "sysforeignkeys", "sysfulltextcatalogs",
                                   "sysfulltextnotify", "sysindexes",
                                   "sysindexkeys", "sysmembers", "sysobjects",
                                   "syspermissions", "sysproperties",
                                   "sysprotects", "sysreferences", "systypes",
                                   "sysusers" };
        else
          aExclude = null;

        if (DebugFile.trace)
          DebugFile.writeln("DatabaseMetaData.getTables(" + sCatalog + ", " + sSchema + ", %, {TABLE})");

    if ((DBMS_ACCESS==iDatabaseProductId)) {
      oAcct = oConn.createStatement();
      oRSet = oAcct.executeQuery("SELECT NULL,NULL,Name FROM MSysObjects WHERE Type=1 AND Flags<>-2147483648");
    } else {
          oRSet = oMData.getTables(sCatalog, sSchema, "%", TableTypes);
    }

        // For each table, keep its name in a memory map

        if (sSchema.length()>0) {
View Full Code Here

Examples of java.sql.DatabaseMetaData

    if (null==oJDBCConn) throw new NullPointerException("Connection parameter may not be null");

    oConn = oJDBCConn;

    DatabaseMetaData oMDat = oConn.getMetaData();
    String sDatabaseProductName = oMDat.getDatabaseProductName();

    if (sDatabaseProductName.equals("Microsoft SQL Server")) {
      sDbms = "mssql";
      iDbms = DBMS_MSSQL;
    }
    else if (sDatabaseProductName.equals("PostgreSQL")) {
      sDbms = "postgresql";
      iDbms = DBMS_POSTGRESQL;
    }
    else if (sDatabaseProductName.equals("Oracle")) {
      sDbms = "oracle";
      iDbms = DBMS_ORACLE;
    }
    else if (sDatabaseProductName.startsWith("DB2")) {
      sDbms = "db2";
      iDbms = DBMS_DB2;
    }
    else if (sDatabaseProductName.startsWith("MySQL")) {
      sDbms = "mysql";
      iDbms = DBMS_MYSQL;
    }
    else {
      sDbms = oMDat.getDatabaseProductName().toLowerCase();
      iDbms = 0;
    }
    oMDat = null;

    if (0==iDbms) {
View Full Code Here

Examples of java.sql.DatabaseMetaData

    }
    else {
      con = ds.getConnection(user, password);
    }
    try {
      DatabaseMetaData metaData = con.getMetaData();
      RdbmsConnectionFactory factory = newFactory(metaData);
      factory.setSail(this);
      if (user == null || url.startsWith("jdbc:")) {
        factory.setDataSource(ds);
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.