Examples of DBUtil


Examples of com.hdfs.util.DBUtil

    return false;
  }
  public User getinfo(String username) {
    User u = null;
    String sql = "SELECT * FROM user WHERE username=?";
    DBUtil util = new DBUtil();
    Connection conn = util.openConnection();
    try {
      PreparedStatement pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, username);
      ResultSet rs = pstmt.executeQuery();
      if (rs.next()) {
        u = new User();
        u.setUsername(rs.getString(1));
        u.setPassword(rs.getString(2));
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      util.closeConnection(conn);
    }
    return u;
  }
View Full Code Here

Examples of com.hdfs.util.DBUtil

import com.hdfs.util.DBUtil;

public class PictureDaoImpl implements PictureDao {
  public boolean insert(String username, String pathname) {
    String sql = "INSERT INTO picture (username, pathname) VALUES(?, ?)";
    DBUtil util = new DBUtil();
    Connection conn = util.openConnection();
    try {
      PreparedStatement pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, username);
      pstmt.setString(2, pathname);
      if (pstmt.executeUpdate() > 0) {
        return true;
      } else {
        return false;
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      util.closeConnection(conn);
    }
    return false;
  }
View Full Code Here

Examples of com.hdfs.util.DBUtil

  }

  public ArrayList<String> get(String username) {
    ArrayList<String> paths = new ArrayList<String>();
    String sql = "SELECT pathname FROM picture WHERE username=?";
    DBUtil util = new DBUtil();
    Connection conn = util.openConnection();
    try {
      PreparedStatement pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, username);
      ResultSet rs = pstmt.executeQuery();
      while (rs.next()) {
        String s = rs.getString(1);
        paths.add(s);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      util.closeConnection(conn);
    }
    return paths;
  }
View Full Code Here

Examples of com.hdfs.util.DBUtil

    return paths;
  }

  public boolean delete(String pathname) {
    String sql = "DELETE FROM picture WHERE pathname=?";
    DBUtil util = new DBUtil();
    Connection conn = util.openConnection();
    try {
      PreparedStatement pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, pathname);
      if (pstmt.executeUpdate() > 0) {
        return true;
      } else {
        return false;
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      util.closeConnection(conn);
    }
    return false;
  }
View Full Code Here

Examples of com.hdfs.util.DBUtil

public class LogDaoImpl implements LogDao {
  ArrayList<Log> logList = new ArrayList<Log>();

  public ArrayList<Log> read(String username) {
    String sql = "SELECT username, optime, action, filename, pathname FROM log WHERE username = ? order by optime desc";
    DBUtil util = new DBUtil();
    Connection conn = util.openConnection();
    try {
      PreparedStatement pstmt = conn.prepareStatement(sql);
      pstmt.setString(1, username);
      ResultSet rs = pstmt.executeQuery();
      while (rs.next()) {
        Log log = new Log();
        log.setUsername(rs.getString(1));
        log.setDate(rs.getString(2).substring(0, 19));
        log.setAction(rs.getString(3));
        log.setFilename(rs.getString(4));
        log.setPathname(rs.getString(5));
        logList.add(log);
      }
      return logList;
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      util.closeConnection(conn);
    }
    return null;
  }
View Full Code Here

Examples of org.apache.airavata.common.utils.DBUtil

    public LocalUserStore(ServletContext servletContext) throws Exception {
        // Properties properties = WebAppUtil.getAiravataProperties(servletContext);

        hashMethod = RegistrySettings.getSetting("default.registry.password.hash.method");

        dbUtil = new DBUtil(RegistrySettings.getSetting("registry.jdbc.url"),
                RegistrySettings.getSetting("registry.jdbc.user"),
                RegistrySettings.getSetting("registry.jdbc.password"),
                RegistrySettings.getSetting("registry.jdbc.driver"));

    }
View Full Code Here

Examples of org.apache.airavata.common.utils.DBUtil

    private CertificateCredentialWriter certificateCredentialWriter;

    public void init() throws ServletException {

        DBUtil dbUtil;

        try {
            dbUtil = DBUtil.getDBUtil();
        } catch (Exception e) {
            throw new ServletException("Error initializing database operations.", e);
View Full Code Here

Examples of org.apache.airavata.common.utils.DBUtil

    public LocalUserStore(ServletContext servletContext) throws Exception {
        // Properties properties = WebAppUtil.getAiravataProperties(servletContext);

        hashMethod = RegistrySettings.getSetting("default.registry.password.hash.method");

        dbUtil = new DBUtil(RegistrySettings.getSetting("registry.jdbc.url"),
                RegistrySettings.getSetting("registry.jdbc.user"),
                RegistrySettings.getSetting("registry.jdbc.password"),
                RegistrySettings.getSetting("registry.jdbc.driver"));

        dbUtil.init();
View Full Code Here

Examples of org.apache.airavata.common.utils.DBUtil

    }

    @Before
    public void setUp() throws Exception {

        DBUtil dbUtil = new DBUtil(getJDBCUrl(), getUserName(), getPassword(), getDriver());
        dbUtil.init();

        localUserStore = new LocalUserStore(dbUtil);
    }
View Full Code Here

Examples of org.apache.airavata.common.utils.DBUtil

        log.debug(stringBuilder.toString());
    }

    private void initializeDatabaseLookup() throws RuntimeException {

        this.dbUtil = new DBUtil(getDatabaseURL(), getDatabaseUserName(), getDatabasePassword(), getDatabaseDriver());

        try {
            this.dbUtil.init();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException("Error loading database driver. Driver class not found.", e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.