亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? billingenginebean.java

?? Sun公司Dream項目
?? JAVA
字號:
/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the "License").  You may not use this file except
 * in compliance with the License.
 *
 * You can obtain a copy of the license at
 * http://www.opensource.org/licenses/cddl1.php
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * HEADER in each file and include the License file at
 * http://www.opensource.org/licenses/cddl1.php.  If 
 * applicable, add the following below this CDDL HEADER, 
 * with the fields enclosed by brackets "[]" replaced 
 * with your own identifying information: 
 * Portions Copyright [yyyy]
 * [name of copyright owner]
 */ 

/*
 * $(@)BillingEngineBean.java $Revision: 1.1.1.1 $ $Date: 2006/03/15 13:12:10 $
 * 
 * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
 */
/**

 *

 * @version: 1.0

 * @date: Sept 19, 2002

 *

 */

package com.sun.sjc.idtv.vod.server.billing;



import java.sql.*;

import java.util.*;

import javax.sql.*;

import javax.ejb.*;

import javax.naming.*;

import com.sun.sjc.idtv.vod.shared.data.*;



/**

 * Implementation bean for the <code>BillingEngine</code> interface, <code>BillingEngine</code>

 * defines all possible business methods for the bean.

 *

 * @see BillingEngine

 * @see BillingEngineHome

 */

public class BillingEngineBean implements SessionBean {



    private  javax.ejb.SessionContext m_ctx = null; 

    public static final int QUERYTIMEOUT = 60;

    private DataSource dataSource;



    /**

     * Sets the session context. Required by EJB spec.

     * @param ctx A SessionContext object.

     */

    public void setSessionContext(javax.ejb.SessionContext ctx) { 

        m_ctx = ctx; 

	try {

	    InitialContext ic = new InitialContext();

	    //dataSource = (DataSource) ic.lookup("java:comp/env/jdbc/vod");

	    dataSource = (DataSource) ic.lookup("jdbc/sample");

	} catch (Exception ex) {

	    throw new EJBException("Unable to connect to database. " +

				   ex.getMessage());

	}

    }



    /**

     * Creates a bean. Required by EJB spec.

     * @exception throws CreateException.

     */

    public void ejbCreate() throws java.rmi.RemoteException, javax.ejb.CreateException { 

    } 



    /**

     * Removes the bean. Required by EJB spec.

     */

    public void ejbRemove() { 

    } 



    /**

     * Loads the state of the bean from secondary storage. Required by EJB spec.

     */

    public void ejbActivate() { 

    } 



    /**

     * Serializes the state of the bean to secondary storage. Required by EJB spec.

     */

    public void ejbPassivate() { 

    } 



    /**

     * Required by EJB spec.

     */

    public void BillingEngine() { 

    } 





    /**

     * Rent a movie.

     * @param subscriber the subscriber.

     * @param movie the movie.

     * @return true if the account balance allows the rental

     * @exception RemoteException

     */

    public boolean rentMovie(Subscriber subscriber, Movie movie) throws java.rmi.RemoteException, SQLException {



	// check if already rented

	boolean currentrental = isRental(subscriber, movie);

	float balance = 0;

	if (!currentrental) {

	    // check account balance

	    balance = getAccountBalance(subscriber);

	    if (balance < movie.stdprice) {

		return false;

	    }

	}



	// log

	insertCDR(subscriber, movie);



	// bill

	if (!currentrental) {

	    setAccountBalance(subscriber, balance - movie.stdprice);

	}

	return true;

    }



    private boolean isRental(Subscriber subscriber, Movie movie) throws java.rmi.RemoteException, SQLException {



       // get db connection from pool

       Connection conn = dataSource.getConnection();



       // check if this movie is currently rented

       PreparedStatement stmt = conn.prepareStatement("SELECT * FROM subscrentals WHERE subscrid = ? AND movieid = ? AND starttimest > ? AND elapsedviewtime > ?");



       stmt.setQueryTimeout(QUERYTIMEOUT);

       if (subscriber.ismaster) {

	   stmt.setLong(1, subscriber.masterid);

       } else {

	   stmt.setLong(1, subscriber.id);

       }

       stmt.setLong(2, movie.id);

       Timestamp yesterday = new Timestamp(System.currentTimeMillis() - (24 * 60 * 60 * 1000)); // 24 hours watch window

       stmt.setTimestamp(3, yesterday);

       stmt.setLong(4, -1); // unlimited viewtime for now

       ResultSet rs = stmt.executeQuery();

       

       boolean isrental = rs.next();



       stmt.close();

       conn.close();

       return isrental;

    }



    private void insertCDR(Subscriber subscriber, Movie movie) throws SQLException {



       // get db connection from pool

       Connection conn = dataSource.getConnection();



       // insert a CDR

       PreparedStatement stmt = conn.prepareStatement("INSERT INTO billingcdr VALUES (?, ?, ?, ?)");



       stmt.setQueryTimeout(QUERYTIMEOUT);

       stmt.setLong(1, subscriber.masterid);

       stmt.setLong(2, movie.id);

       Timestamp now = new Timestamp(System.currentTimeMillis());

       stmt.setTimestamp(3, now);

       stmt.setFloat(4, movie.stdprice);

       stmt.executeUpdate();

       stmt.close();



       // rent it

       stmt = conn.prepareStatement("INSERT INTO subscrentals VALUES (?, ?, ?, ?, ?)");



       stmt.setQueryTimeout(QUERYTIMEOUT);

       if (subscriber.ismaster) {

	   stmt.setLong(1, subscriber.masterid);

       } else {

	   stmt.setLong(1, subscriber.id);

       }

       stmt.setLong(2, movie.id);

       stmt.setTimestamp(3, now);

       stmt.setLong(4, 0);

       stmt.setString(5, "");

       stmt.executeUpdate();

       stmt.close();



       conn.close();

       return;

    }



    /**

     * Get the account balance for a given subscriber.

     * @param subscriber the subscriber.

     * @return account balance

     * @exception RemoteException

     */

    public float getAccountBalance(Subscriber subscriber) throws java.rmi.RemoteException, SQLException {



       // get db connection from pool

       Connection conn = dataSource.getConnection();



       // get account balance

       PreparedStatement stmt = conn.prepareStatement("SELECT subscracct.balance FROM subscracct WHERE (subscracct.subscrid = ?)");



       stmt.setQueryTimeout(QUERYTIMEOUT);

       stmt.setLong(1, subscriber.masterid);

       ResultSet rs = stmt.executeQuery();

       float balance = 0;

       if (rs.next()) {

	   balance = rs.getFloat(1);

       }

       rs.close();

       stmt.close();

       conn.close();

       return balance;

    }



    /**

     * Set the account balance for a given subscriber.

     * @param subscriber the subscriber.

     * @exception RemoteException

     */

    public void setAccountBalance(Subscriber subscriber, float balance) throws java.rmi.RemoteException, SQLException {



       // get db connection from pool

       Connection conn = dataSource.getConnection();



       // set account balance

       PreparedStatement stmt = conn.prepareStatement("UPDATE subscracct SET balance = ? WHERE (subscracct.subscrid = ?)");



       stmt.setQueryTimeout(QUERYTIMEOUT);

       stmt.setFloat(1, balance);

       stmt.setLong(2, subscriber.masterid);

       stmt.executeUpdate();

       stmt.close();

       conn.close();

       return;

    }



    /**

     * Get the account movement history for a given subscriber.

     * @param subscriber the subscriber.

     * @param start start date for the history.

     * @param end end date for the history.

     * @return movement history

     * @exception RemoteException

     */

    public String[] getHistory(Subscriber subscriber, java.util.Date start, java.util.Date end) throws java.rmi.RemoteException, SQLException {



	// get db connection from pool

       Connection conn = dataSource.getConnection();



       // get CDRs

       //PreparedStatement stmt = conn.prepareStatement("SELECT * FROM billingcdr WHERE (billingcdr.subscrid = ?) AND (billingcdr.purchasedate >= ?) AND (billingcdr.purchasedate < ?) ORDER BY billingcdr.purchasedate");

       PreparedStatement stmt = conn.prepareStatement("SELECT * FROM billingcdr WHERE (billingcdr.subscrid = ?) ORDER BY billingcdr.purchasedate");



       stmt.setQueryTimeout(QUERYTIMEOUT);

       stmt.setLong(1, subscriber.masterid);

       //stmt.setTimestamp(2, new Timestamp(start.getTime()));

       //stmt.setTimestamp(3, new Timestamp(end.getTime()));

       ResultSet rs = stmt.executeQuery();

       Vector v = new Vector();

       while (rs.next()) {

	   String cdr = "" + rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3);

	   v.addElement(cdr);

       }

       rs.close();

       stmt.close();

       conn.close();

       String[] cdrs = new String[v.size()];

       for (int i=0; i<v.size(); i++ ) {

	   cdrs[i] = (String) v.elementAt(i);

       }

       return cdrs;

    }

} 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品av麻豆的观看方式| 国产精品综合一区二区三区| 国产精品 欧美精品| 国产不卡视频在线观看| 欧美成人乱码一区二区三区| 午夜激情综合网| 91成人免费在线视频| 亚洲国产精品久久艾草纯爱 | 欧亚一区二区三区| 日韩一级精品视频在线观看| 日韩国产欧美一区二区三区| 欧美久久久久久久久| 国产日韩精品视频一区| 国产成人8x视频一区二区| 亚洲精品在线观看视频| 久久av老司机精品网站导航| 久久久久久麻豆| 99精品久久只有精品| 五月天一区二区| 欧美电影免费观看高清完整版在线| 国产乱码精品一区二区三| 中文字幕五月欧美| 欧洲另类一二三四区| 日本不卡视频在线| 日本一区二区不卡视频| 色av成人天堂桃色av| 免费成人结看片| 欧美国产国产综合| av在线不卡网| 国产亲近乱来精品视频| 国产成人在线免费| 亚洲欧洲99久久| 国产一区在线看| 国产91对白在线观看九色| 欧美性大战xxxxx久久久| 亚洲福利一二三区| 在线观看一区不卡| 午夜欧美电影在线观看| 欧美三级视频在线| 青青草国产精品亚洲专区无| 久久精子c满五个校花| eeuss鲁片一区二区三区在线看| 国产精品视频一二三区| 色诱亚洲精品久久久久久| 日韩高清不卡一区| 久久久久久久免费视频了| 精品视频在线免费看| 精一区二区三区| 亚洲日本电影在线| 欧美日韩极品在线观看一区| 国产美女精品人人做人人爽| 一区二区三区视频在线看| 精品999在线播放| 91蜜桃在线观看| 日本成人在线视频网站| 国产精品国产三级国产aⅴ中文| 色综合久久久久久久久久久| 亚洲成人资源网| 久久精品免视看| 欧美精品日韩一区| 成人免费毛片高清视频| 午夜婷婷国产麻豆精品| 国产精品人成在线观看免费| 91麻豆精品国产无毒不卡在线观看| 国产精品一区二区在线观看不卡| 精品三级在线看| 国产精品77777| 91精品国产欧美一区二区| 日本一区二区三区四区在线视频| 国内精品写真在线观看| 欧美精选在线播放| 亚瑟在线精品视频| 日韩欧美国产综合| 国内久久精品视频| 久久先锋资源网| 99视频国产精品| 日本在线不卡一区| 亚洲一区二区欧美激情| 蜜臀精品一区二区三区在线观看 | 日韩欧美国产小视频| 成人网在线免费视频| 一区二区三区91| 中文字幕亚洲一区二区av在线 | 国产日韩av一区二区| 日韩av网站免费在线| 亚洲免费在线视频| 亚洲色图在线播放| 亚洲人午夜精品天堂一二香蕉| 国产精品欧美极品| 中文字幕综合网| 亚洲久草在线视频| 一区二区三区视频在线看| 亚洲高清免费在线| 日韩精品视频网站| 久久成人18免费观看| 国产乱码精品一区二区三区五月婷| 国产一区二区剧情av在线| 国产黄色精品视频| bt欧美亚洲午夜电影天堂| 99久久精品免费精品国产| 91亚洲国产成人精品一区二三| 色哦色哦哦色天天综合| 欧美日韩精品免费| 日韩视频一区二区| 国产日韩欧美不卡| 一区二区三区四区五区视频在线观看 | 91福利在线播放| 欧美电影一区二区三区| 亚洲精品一区二区三区在线观看| 久久久精品综合| 中文字幕一区av| 日本一不卡视频| 国产不卡视频在线观看| 色婷婷av一区二区三区大白胸 | 欧美军同video69gay| 日韩精品在线一区二区| 国产欧美日韩中文久久| 一区二区三区 在线观看视频| 日本视频一区二区三区| jizzjizzjizz欧美| 91.xcao| 国产精品免费免费| 日韩电影在线一区二区| 国产91色综合久久免费分享| 欧美日本在线看| 国产精品久久久久影视| 视频一区在线播放| 激情欧美一区二区| 色婷婷亚洲一区二区三区| 日韩一区二区在线观看| 久久蜜桃一区二区| 国产精品每日更新在线播放网址| 国产欧美视频在线观看| 国产精品国产三级国产普通话99| 日韩精品久久久久久| 国产精品996| 久久婷婷国产综合国色天香 | 国产精品欧美综合在线| 久久精品视频免费| 五月激情六月综合| 日韩福利视频网| 懂色av一区二区三区蜜臀| 欧美日韩高清不卡| 亚洲欧美日韩在线| 91精品办公室少妇高潮对白| 欧美巨大另类极品videosbest | 精品影院一区二区久久久| 国产精品护士白丝一区av| 狠狠色丁香婷婷综合久久片| 国产成a人亚洲精| 欧美精品乱人伦久久久久久| 亚洲欧美一区二区视频| 国产精品一区在线观看乱码| 欧美一级黄色大片| 亚洲bt欧美bt精品777| 欧美日韩在线播放一区| 亚洲综合精品久久| 精品婷婷伊人一区三区三| 欧美精品一区二区在线播放| 国产一区二区三区香蕉| 亚洲国产一区视频| 亚洲手机成人高清视频| 成人性生交大合| 国产夜色精品一区二区av| 国产一区在线视频| 精品国产乱码久久久久久1区2区 | 国产精品毛片高清在线完整版| 日本91福利区| 在线观看国产91| 亚洲欧美国产毛片在线| 色综合久久久久综合99| 亚洲免费观看高清| 97se亚洲国产综合在线| 中文文精品字幕一区二区| 国产乱淫av一区二区三区| 精品国产91洋老外米糕| 韩国v欧美v亚洲v日本v| 久久久噜噜噜久久人人看| 激情文学综合网| 欧美精品一区二区精品网| 久久国产精品99精品国产| 在线播放91灌醉迷j高跟美女| 亚洲一级二级三级在线免费观看| 欧美日韩美女一区二区| 日本成人在线不卡视频| 精品一区二区免费视频| 国产91精品久久久久久久网曝门| 91老师国产黑色丝袜在线| 亚洲黄色片在线观看| 美女脱光内衣内裤视频久久影院| jlzzjlzz欧美大全| 精品成人一区二区三区| 国产精品一区二区三区四区| 亚洲国产精华液网站w| 91蜜桃网址入口| 亚洲精品视频一区| 337p亚洲精品色噜噜噜| 理论片日本一区| 国产精品久久久久7777按摩| 91久久精品一区二区三|