Package net.sourceforge.squirrel_sql.plugins.mssql.sql.dbfile

Examples of net.sourceforge.squirrel_sql.plugins.mssql.sql.dbfile.DatabaseFileInfo


               
                try {
                    if (nodes[0].getDatabaseObjectType() != DatabaseObjectType.CATALOG)
                        return;
                   
                    DatabaseFileInfo info = MssqlIntrospector.getDatabaseFileInfo(nodes[0].toString(), _session.getSQLConnection());
                    Object[] files = info.getDataFiles();
                    for (int i = 0; i < files.length; i++) {
                        DatabaseFile file = (DatabaseFile) files[i];
                        final ShrinkDatabaseFileAction shrinkDatabaseFileAction = new ShrinkDatabaseFileAction(app,_resources,plugin,nodes[0].toString(),file);
                        shrinkDatabaseFileAction.setSession(_session);
                        coll.add(shrinkDatabaseFileAction);
                        _resources.addToMenu(shrinkDatabaseFileAction,menu);
                    }
                    menu.addSeparator();
                    files = info.getLogFiles();
                    for (int i = 0; i < files.length; i++) {
                        DatabaseFile file = (DatabaseFile) files[i];
                        final ShrinkDatabaseFileAction shrinkDatabaseFileAction = new ShrinkDatabaseFileAction(app,_resources,plugin,nodes[0].toString(),file);
                        shrinkDatabaseFileAction.setSession(_session);
                        coll.add(shrinkDatabaseFileAction);
View Full Code Here


  }

  public static DatabaseFileInfo getDatabaseFileInfo(String catalogName, ISQLConnection conn)
    throws java.sql.SQLException
  {
    DatabaseFileInfo dbInfo = new DatabaseFileInfo();

    Connection c = conn.getConnection();

    CallableStatement stmt = null;
    ResultSet rs = null;

    try
    {
      stmt = c.prepareCall("{ call sp_helpdb ? }");
      stmt.setString(1, catalogName);

      if (!stmt.execute()) return null;
      rs = stmt.getResultSet();
      rs.next();

      dbInfo.setDatabaseName(rs.getString(1));
      dbInfo.setDatabaseSize(rs.getString(2));
      dbInfo.setOwner(rs.getString(3));
      dbInfo.setCreatedDate(rs.getString(5));
      String[] options = rs.getString(6).split(", ");
      dbInfo.setCompatibilityLevel(rs.getShort(7));

      // dbStatus -> `Status=ONLINE, Updateability=READ_WRITE, UserAccess=MULTI_USER, Recovery=SIMPLE,
      // Version=539, Collation=SQL_Latin1_General_CP1_CI_AS, SQLSortOrder=52, IsTornPageDetectionEnabled,
      // IsAutoCreateStatistic'
      for (int i = 0; i < options.length; i++)
      {
        if (options[i].indexOf('=') != -1)
        {
          String parts[] = options[i].split("=");
          dbInfo.setOption(parts[0], parts[1]);
        }
        else dbInfo.setOption(options[i], "1");
      }

      if (!stmt.getMoreResults()) return dbInfo;
    }
    catch (Exception e)
    {
      s_log.error("getDatabaseFileInfo(1): Unexpected exception - " + e.getMessage(), e);
    }
    finally
    {
      closeResultSet(rs);
      closeStatement(stmt);
    }

    try
    {
      rs = stmt.getResultSet();

      while (rs.next())
      {
        String name = rs.getString(1).trim();
        short id = rs.getShort(2);
        String filename = rs.getString(3).trim();
        String filegroup = rs.getString(4);
        String size = rs.getString(5);
        String maxSize = rs.getString(6);
        String growth = rs.getString(7);
        String usage = rs.getString(8);

        DatabaseFile file = new DatabaseFile();
        file.setName(name);
        file.setId(id);
        file.setFilename(filename);
        file.setFilegroup(filegroup);
        file.setSize(size);
        file.setMaxSize(maxSize);
        file.setGrowth(growth);
        file.setUsage(usage);

        if (filegroup == null) dbInfo.addLogFile(file);
        else dbInfo.addDataFile(file);
      }
    }
    catch (Exception e)
    {
      s_log.error("getDatabaseFileInfo(2): Unexpected exception - " + e.getMessage(), e);
View Full Code Here

  public static String generateCreateDatabaseScript(String catalogName, ISQLConnection conn)
    throws java.sql.SQLException
  {
    StringBuilder buf = new StringBuilder();

    DatabaseFileInfo dbInfo = MssqlIntrospector.getDatabaseFileInfo(catalogName, conn);
    Object[] dataFiles = dbInfo.getDataFiles();
    Object[] logFiles = dbInfo.getLogFiles();

    buf.append("CREATE DATABASE [");
    buf.append(dbInfo.getDatabaseName());
    buf.append("]\nON ");

    String lastFilegroup = "";
    for (int i = 0; i < dataFiles.length; i++)
    {
View Full Code Here

TOP

Related Classes of net.sourceforge.squirrel_sql.plugins.mssql.sql.dbfile.DatabaseFileInfo

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.