コード例 #1
0
  // Call from MangingComposer.java
  public void removeSubscriberStbBind(SubscribersettopboxbindBean bean, Connection conn)
      throws Exception {

    PreparedStatement preparedStatement = null;

    String sqlUpdateAllStmt =
        "UPDATE subscribersettopboxbind SET mode = ?, outdate = ? WHERE subscriber_id = ? ";

    try {

      preparedStatement = conn.prepareStatement(sqlUpdateAllStmt);

      preparedStatement.setString(1, bean.getMode());

      preparedStatement.setDate(2, bean.getOutdate());

      preparedStatement.setInt(3, bean.getSubscriber_id());

      preparedStatement.executeUpdate();

    } catch (Exception e) {

      e.printStackTrace();

      throw new Exception();

    } finally {

      try {
          /*dbDatabaseHandler.closeConnection();*/
        preparedStatement.close();
      } catch (SQLException ioe) {
      }
    }
  }
コード例 #2
0
  public int insertAllCols(SubscribersettopboxbindBean bean, Connection conn) throws Exception {

    // DatabaseHandler dbDatabaseHandler = DatabaseHandler.getNewInstance();

    // Connection conn = dbDatabaseHandler.getConnection();

    PreparedStatement preparedStatement = null;

    ResultSet resultSet = null;

    int generatedsubscriberstbbindId = 0;

    // String sqlInsertAllStmt = "INSERT INTO subscribersettopboxbind( id, subscriber_id,
    // settopbox_id, indate, mode, outdate ) VALUES ( ? , ? , ? , ? , ? , ?  )" ;
    String sqlInsertAllStmt =
        "INSERT INTO subscribersettopboxbind(subscriber_id,settopbox_id,indate) VALUES (?,?,?)";

    try {

      preparedStatement =
          conn.prepareStatement(sqlInsertAllStmt, preparedStatement.RETURN_GENERATED_KEYS);

      /*preparedStatement.setInt(1, bean.getId());*/

      preparedStatement.setInt(1, bean.getSubscriber_id());

      preparedStatement.setInt(2, bean.getSettopbox_id());

      preparedStatement.setDate(3, bean.getIndate());

      /*preparedStatement.setString(5, bean.getMode());*/

      /*preparedStatement.setDate(6, bean.getOutdate());*/

      preparedStatement.executeUpdate();

      resultSet = preparedStatement.getGeneratedKeys();

      if (resultSet.next()) {

        System.out.println("generatedsubscriberstbbindId: " + resultSet.getInt(1));

        generatedsubscriberstbbindId = resultSet.getInt(1);
      }

    } catch (Exception e) {

      e.printStackTrace();

      throw new Exception();

    } finally {

      try {
          /*dbDatabaseHandler.closeConnection();*/
        preparedStatement.close();
      } catch (SQLException ioe) {
      }
    }
    return generatedsubscriberstbbindId;
  }