Exemplo n.º 1
0
  @Override
  public Collection<Entry> findEntries(final String key, final String value) throws IOException {
    Debug.checkNull("key", key);
    Debug.checkNull("value", value);

    final MySQLConnection connection = this.db.obtainConnection();
    connection.checkIsOpen();
    try {
      final Connection mysql_connection = connection.getConnection();

      final String table_name = this.sql_table_name;
      final String stm = "SELECT * FROM " + table_name + " WHERE " + key + " = ?";
      final PreparedStatement statement =
          mysql_connection //
              .prepareStatement(stm);
      statement.setString(1, value);
      final ResultSet result = statement.executeQuery();
      final List<Entry> res = this.collectResult(result);
      return res;
    } catch (final SQLException e) {
      e.printStackTrace();
      throw new IOException(e);
    } finally {
      this.db.releaseConnection(connection);
    }
  }
Exemplo n.º 2
0
 @Override
 public String md5String(final String password) {
   Debug.checkNull("input", password);
   try {
     final ByteArray array = JUtils.newByteArray(password.getBytes());
     final Buffer buff = IO.newBuffer(array);
     final BufferInputStream bis = IO.newBufferInputStream(buff);
     bis.open();
     final String result = this.md5Stream(bis);
     bis.close();
     return result;
   } catch (final IOException e) {
     e.printStackTrace();
   }
   return null;
 }