Logo Search packages:      
Sourcecode: henplus version File versions  Download package

henplus::SQLSession::SQLSession ( String  url,
String  user,
String  password 
) throws IllegalArgumentException, ClassNotFoundException, SQLException, IOException [inline]

creates a new SQL session. Open the database connection, initializes the readline library

Definition at line 49 of file SQLSession.java.

References henplus::PropertyRegistry::registerProperty().

    {
      _statementCount = 0;
      _showMessages = 1;
      _conn = null;
      _url = url;
      _username = user;
      _password = password;
      _propertyRegistry = new PropertyRegistry();

      Driver driver = null;
      //HenPlus.msg().println("connect to '" + url + "'");
      driver = DriverManager.getDriver(url);

      HenPlus.msg().println ("HenPlus II connecting ");
      HenPlus.msg().println(" url '" + url + '\'');
      HenPlus.msg().println(" driver version " 
                   + driver.getMajorVersion()
                   + "."
                   + driver.getMinorVersion());
      connect();
      
      int currentIsolation = Connection.TRANSACTION_NONE;
      DatabaseMetaData meta = _conn.getMetaData();
      _databaseInfo = (meta.getDatabaseProductName()
                   + " - " + meta.getDatabaseProductVersion());
      HenPlus.msg().println(" " + _databaseInfo);
      try {
          if (meta.supportsTransactions()) {
            currentIsolation = _conn.getTransactionIsolation();
          }
          else {
            HenPlus.msg().println("no transactions.");
          }
          _conn.setAutoCommit(false);
      }
      catch (SQLException ignore_me) {
      }

      printTransactionIsolation(meta,Connection.TRANSACTION_NONE, 
                          "No Transaction", currentIsolation);
      printTransactionIsolation(meta, 
                          Connection.TRANSACTION_READ_UNCOMMITTED,
                          "read uncommitted", currentIsolation);
      printTransactionIsolation(meta, Connection.TRANSACTION_READ_COMMITTED,
                          "read committed", currentIsolation);
      printTransactionIsolation(meta, Connection.TRANSACTION_REPEATABLE_READ,
                          "repeatable read", currentIsolation);
      printTransactionIsolation(meta, Connection.TRANSACTION_SERIALIZABLE, 
                          "serializable", currentIsolation);

        Map availableIsolations = new HashMap();
        addAvailableIsolation(availableIsolations,
                              meta, Connection.TRANSACTION_NONE, "none");
        addAvailableIsolation(availableIsolations,
                              meta, Connection.TRANSACTION_READ_UNCOMMITTED,
                              "read-uncommitted");
        addAvailableIsolation(availableIsolations,
                              meta, Connection.TRANSACTION_READ_COMMITTED,
                              "read-committed");
        addAvailableIsolation(availableIsolations,
                              meta, Connection.TRANSACTION_REPEATABLE_READ,
                              "repeatable-read");
        addAvailableIsolation(availableIsolations,
                              meta, Connection.TRANSACTION_SERIALIZABLE,
                              "serializable");

        _propertyRegistry.registerProperty("auto-commit", 
                                           new AutoCommitProperty());
        _propertyRegistry
            .registerProperty("isolation-level",
                              new IsolationLevelProperty(availableIsolations,
                                                         currentIsolation));
    }


Generated by  Doxygen 1.6.0   Back to index