public void insertCategory(String codeSubscriber, String systemUsed, String codeCategory, String codeCategoryGroup, String categoryDesc, String actionBy, Timestamp newTimestamp) throws ETMDataAccessException, ETMDataAlreadyExistsException { try { CategoryHome home =(CategoryHome)EJBUtil.getEJBHome( "MyMasterCategory",CategoryHome.class); home.create(codeSubscriber, systemUsed, codeCategory, codeCategoryGroup, categoryDesc, actionBy, newTimestamp); } catch (DuplicateKeyException e) { throw new ETMDataAlreadyExistsException(); } catch (RemoteException e) { throw new ETMDataAccessException(e); } catch (CreateException e) { throw new ETMDataAccessException(e); } }
String subscriberSql = "Select code_subscriber, subscriber_name " + "From subscriber Where status = "A" ";
public Collection getSubscriberList() throws ETMDataAccessException { Connection con = null; PreparedStatement pStmt = null; ResultSet res = null; SubscriberEntity subscriber = null; Collection page = new ArrayList(); try { //getConnection(); con = EJBUtil.getConnection("jdbc/XAOracle"); pStmt = con.prepareStatement(subscriberSql); SystemLogger.getInstance().logDebug("SQL:"+subscriberSql+"<-START->"); res = pStmt.executeQuery(); SystemLogger.getInstance().logDebug("SQL:"+subscriberSql+"<-END->"); while (res.next()) { subscriber = new SubscriberEntity( res.getString("code_subscriber"), res.getString("subscriber_name")); page.add(subscriber); } } catch (SQLException e) { throw new ETMDataAccessException(e); } finally { if (res != null) { try { res.close(); } catch (Exception e) {} } if (pStmt != null) { try { pStmt.close(); } catch (Exception e) {} } if (con != null) { try { con.close(); con = null; } catch (Exception e) {} } } return page; }
|