Ejemplo n.º 1
0
  /**
   * only for sql statements UPDATE, INSERT, DELETE.
   *
   * @param sql
   * @throws SQLException
   */
  public static void executeUpdate(String sql) {

    Connection con = null;
    Statement st = null;
    DatabaseConnect.dbConnect();
    con = DatabaseConnect.getConnection();

    try {
      st = con.createStatement();
      st.executeUpdate(sql);
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  public static ResultSet execute(String sql) {

    Connection con = null;
    Statement st = null;
    DatabaseConnect.dbConnect();
    con = DatabaseConnect.getConnection();
    ResultSet rs = null;

    try {
      st = con.createStatement();
      rs = st.executeQuery(sql);

    } catch (SQLException e) {
      e.printStackTrace();
    }
    return rs;
  }