Esempio n. 1
0
  /**
   * Sets the current db URL.
   *
   * @param url db URL
   * @since 0.0.1
   */
  public void setUrl(final String url) {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart(url));
    if (null == url) {
      throw new RuntimeExceptionIsNull("url"); // $NON-NLS-1$
    }
    this.url = url;

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit());
  }
Esempio n. 2
0
  /**
   * Sets the current db user password.
   *
   * @param password for the user/db
   * @since 0.0.1
   */
  public void setPassword(final String password) {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart(password));
    //		if (null == password) {
    //			throw new RuntimeExceptionIsNull("password"); //$NON-NLS-1$
    //		}

    this.password = password;

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit());
  }
Esempio n. 3
0
  /**
   * Sets the current db user.
   *
   * @param user for the db
   * @since 0.0.1
   */
  public void setUser(final String user) {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart(user));
    //		if (null == user) {
    //			throw new RuntimeExceptionIsNull("user"); //$NON-NLS-1$
    //		}

    this.user = user;

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit());
  }
Esempio n. 4
0
  /**
   * Sets the current db driver class
   *
   * @param driver db driver class
   * @since 0.0.1
   */
  public void setDriver(final String driver) {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart(driver));
    if (null == driver) {
      throw new RuntimeExceptionIsNull("driver"); // $NON-NLS-1$
    }

    this.driver = driver;

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit());
  }
Esempio n. 5
0
  @Override
  public Connection getConnection()
      throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException,
          NoSuchMethodException, InvocationTargetException {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart());

    Class.forName(driver).getConstructor().newInstance();
    final Connection result = DriverManager.getConnection(url, user, password);

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit(result));
    return result;
  }
Esempio n. 6
0
  public ProviderSqlImpl(
      final String driver, final String url, final String user, final String password) {
    super();
    if (log.isTraceEnabled()) log.trace(HelperLog.constructor(driver, url, user, password));

    setDriver(driver);
    setUrl(url);
    setUser(user);
    setPassword(password);
  }
Esempio n. 7
0
  @Override
  public boolean execute(final String statement)
      throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException,
          NoSuchMethodException, InvocationTargetException {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart(statement));
    if (null == statement) {
      throw new RuntimeExceptionIsNull("statement"); // $NON-NLS-1$
    }
    if (!HelperString.isValid(statement)) {
      throw new RuntimeExceptionIsEmpty("statement"); // $NON-NLS-1$
    }

    try (Connection con = getConnection();
        Statement stmt = con.createStatement()) {
      final boolean result = stmt.execute(statement);

      if (log.isDebugEnabled()) log.debug(HelperLog.methodExit(result));
      return result;
    }
  }
Esempio n. 8
0
  /**
   * Returns the current db URL.
   *
   * @return db URL
   * @since 0.0.1
   */
  public String getUrl() {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart());

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit(url));
    return url;
  }
Esempio n. 9
0
  /**
   * Returns the current db driver class.
   *
   * @return db driver class
   * @since 0.0.1
   */
  public String getDriver() {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart());

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit(driver));
    return driver;
  }
Esempio n. 10
0
  /**
   * Returns the current db user password.
   *
   * @return db user password
   * @since 0.0.1
   */
  public String getPassword() {
    if (log.isDebugEnabled()) log.debug(HelperLog.methodStart());

    if (log.isDebugEnabled()) log.debug(HelperLog.methodExit(password));
    return password;
  }