Package net.sourceforge.squirrel_sql.fw.sql

Examples of net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData


   * @throws Exception
   */
  private String fixIdentifierCase(ISession session, String identifier) throws Exception
  {
    String result = null;
    final SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();

    if (md.storesUpperCaseIdentifiers())
    {
      result = identifier.toUpperCase();
    }
    else
    {
View Full Code Here


    */
   private boolean initFromDB()
      throws SQLException
   {
      DatabaseMetaData metaData = _session.getSQLConnection().getConnection().getMetaData();
      SQLDatabaseMetaData md = _session.getSQLConnection().getSQLMetaData();
      Hashtable<String, ConstraintData> dbConstraintInfosByConstraintName = new Hashtable<String, ConstraintData>();
      Vector<ColumnInfo> colInfosBuf = new Vector<ColumnInfo>();
      if (s_log.isDebugEnabled()) {
          s_log.debug("initFromDB: _catalog="+_catalog+" _schema="+_schema+
                      " _tableName="+_tableName);
      }

         
      TableColumnInfo[] infos = md.getColumnInfo(_catalog, _schema, _tableName);
      for (int i = 0; i < infos.length; i++) {
         TableColumnInfo info = infos[i];
         String columnName = info.getColumnName();
         String columnType = info.getTypeName();
         int columnSize = info.getColumnSize();
         int decimalDigits = info.getDecimalDigits();
         boolean nullable = "YES".equalsIgnoreCase(info.isNullable());

         ColumnInfo colInfo = new ColumnInfo(columnName,
                                             columnType,
                                             columnSize,
                                             decimalDigits,
                                             nullable);
         colInfosBuf.add(colInfo);
        
      }
     
      _colInfos = colInfosBuf.toArray(new ColumnInfo[colInfosBuf.size()]);

      if(0 == _colInfos.length)
      {
         // Table was deleted from DB
         return false;
      }

      try {
          PrimaryKeyInfo[] pkinfos =
              md.getPrimaryKey(_catalog, _schema, _tableName);
          for (int i = 0; i < pkinfos.length; i++) {
             PrimaryKeyInfo info = pkinfos[i];
             for (int c = 0; c < _colInfos.length; c++)
             {
                if(_colInfos[c].getName().equals(info.getColumnName()))
View Full Code Here

  public List<ObjectTreeNode> createChildren(ISession session, ObjectTreeNode parentNode)
    throws SQLException
  {
    final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
    final ISQLConnection conn = session.getSQLConnection();
    final SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();
    final IDatabaseObjectInfo parentDbinfo = parentNode.getDatabaseObjectInfo();
    final String schemaName = parentDbinfo.getSchemaName();

    PreparedStatement pstmt = conn.prepareStatement(SQL);
    try
View Full Code Here

        }
       
        ITableInfo tableInfo = (ITableInfo) dbObjs[0];
       
        ISQLConnection conn = _session.getSQLConnection();
        SQLDatabaseMetaData metaData = conn.getSQLMetaData();
       
        try {
            ResultSetDataSet rsds =
                metaData.getIndexInfo(tableInfo, indexColumnIndices, false);
            String indexName = "";
            while (rsds.next(null)) {
                String thisIndexName = (String)rsds.get(0);
                if (thisIndexName != null) {
                    if (!indexName.equals(thisIndexName)) {
View Full Code Here

   */
  public List<ObjectTreeNode> createChildren(ISession session, ObjectTreeNode parentNode)
    throws SQLException
  {
    final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
    final SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();

    // Users.
    DatabaseObjectInfo dboInfo = new DatabaseObjectInfo(null, null, "USERS",
                      IObjectTypes.USER_PARENT, md);
    ObjectTreeNode node = new ObjectTreeNode(session, dboInfo);
View Full Code Here

    private void populateAvailableTable(JTable table) {
        DatabaseObjectInfoTableModel model = (DatabaseObjectInfoTableModel) table.getModel();
       
        try {
            String catalog = _session.getSQLConnection().getCatalog();
            SQLDatabaseMetaData metaData = _session.getSQLConnection().getSQLMetaData();

            int i;

            /* add the tables. */
            ITableInfo[] tables = _session.getSchemaInfo().getITableInfos(catalog,null,new ObjFilterMatcher(),new String[] { "TABLE" });
            for (i = 0; i < tables.length; i++)
                model.addElement(tables[i]);
           
            /* add the views. */
            ITableInfo[] views = _session.getSchemaInfo().getITableInfos(catalog,null,new ObjFilterMatcher(),new String[] { "VIEW" });
            for (i = 0; i < views.length; i++)
                model.addElement(views[i]);
           
            /* add the procedures. */
            //IProcedureInfo[] procs = metaData.getProcedures(catalog,null,null);
            IProcedureInfo[] procs = _session.getSchemaInfo().getStoredProceduresInfos(catalog,null,new ObjFilterMatcher());
            for (i = 0; i < procs.length; i++)
                if (!procs[i].getSimpleName().startsWith("dt_"))
                    model.addElement(procs[i]);

            /* add the UDTs. */
            IUDTInfo[] udts = metaData.getUDTs(catalog,null,null,null);
            for (i = 0; i < udts.length; i++)
                model.addElement(udts[i]);
        }
        catch (SQLException ex) {
            _session.getApplication().showErrorDialog(ex.getMessage(),ex);
View Full Code Here

    ForeignKeyInfo fkInfo, SessionInfoProvider prov)
  {
    boolean result = false;
    try
    {
      SQLDatabaseMetaData md = prov.getDiffDestSession().getSQLConnection().getSQLMetaData();

      ITableInfo[] tables =
        md.getTables(destCatalog, destSchema, destTableName, new String[] { "TABLE" }, null);
      if (tables != null && tables.length == 1)
      {
        ForeignKeyInfo[] fks = SQLUtilities.getImportedKeys(tables[0], md);
        for (ForeignKeyInfo existingKey : fks)
        {
View Full Code Here

    String objectName, int sessionType) throws UserCancelledOperationException
  {
    String catalog = fixCase(session, catalogName);
    String schema = fixCase(session, schemaName);
    String object = fixCase(session, objectName);
    SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();
    boolean useSchema = true;
    boolean useCatalog = true;
    try
    {
      useCatalog = md.supportsCatalogsInTableDefinitions();
    }
    catch (SQLException e)
    {
      log.info("Encountered unexpected exception while attempting to "
        + "determine if catalogs are used in table definitions");
    }
    try
    {
      useSchema = md.supportsSchemasInTableDefinitions();
    }
    catch (SQLException e)
    {
      log.info("Encountered unexpected exception while attempting to "
        + "determine if schemas are used in table definitions");
View Full Code Here

  public static String getCatSep(ISession session)
  {
    String catsep = ".";
    try
    {
      SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();
      catsep = md.getCatalogSeparator();
    }
    catch (SQLException e)
    {
      log.error("getCatSep: Unexpected Exception - " + e.getMessage(), e);
    }
View Full Code Here

  private String[] getAccessibleSchemas(OracleAliasPrefs aliasPrefs, ISQLConnection con)
  {
    String[] result = null;
    ResultSet rs = null;
    Statement stmt = null;
    SQLDatabaseMetaData md = con.getSQLMetaData();
    String currentUserName = null;
    try
    {
      if (hasSystemPrivilege(con) || aliasPrefs.isLoadAllSchemas())
      {
        result = md.getSchemas();
      } else
      {
        currentUserName = md.getUserName();
        stmt = con.getConnection().createStatement();
        rs = stmt.executeQuery(SCHEMA_ACCESS_SQL);
        ArrayList<String> tmp = new ArrayList<String>();
        while (rs.next())
        {
View Full Code Here

TOP

Related Classes of net.sourceforge.squirrel_sql.fw.sql.SQLDatabaseMetaData

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.