jameszhang
CJSDN高级会员
发贴: 1594
积分: 111
|
于 2003-03-06 14:04
那你看我这样关闭的是不是有错呢?另外如果我刷新的很慢,WEBLOGIC 是不抛出异常的,这点我刚才没有声明,请高手帮帮忙!!谢谢!
public class MyEJBBean implements SessionBean { SessionContext sessionContext; private javax.sql.DataSource jdbcFactory; private Connection connection=null;
public void ejbCreate() throws CreateException { /**@todo Complete this method*/ Context c = null; if (this.jdbcFactory == null) { try { c = new InitialContext(); this.jdbcFactory = (javax.sql.DataSource) c.lookup("myData"); } catch (Exception e){ System.out.println("Error: " + e); } }
} public void ejbRemove() { /**@todo Complete this method*/ } public void ejbActivate() { /**@todo Complete this method*/ } public void ejbPassivate() { /**@todo Complete this method*/ } public void setSessionContext(SessionContext sessionContext) { this.sessionContext = sessionContext; } ////////////////////////////////////////////////////////// private void getDBConnection() throws SQLException { try{ connection=this.jdbcFactory.getConnection(); }catch(Exception xxe) { System.out.println("getDBConnection Error :"+xxe); }
} /////////////////////////////////////////////////////// public int getCount() { int iRet=0; try{ this.getDBConnection(); AccessDAO adao=new AccessDAO(); iRet=adao.getCount(connection);
connection.close();
}catch(Exception xe) { System.out.println("get Count Error:"+xe); } return iRet; } }
|