User: ejort Date: 02/03/06 12:23:24 Modified: src/main/org/jboss/test/bmp/beans SimpleBMPBean.java Log: Tests for create<METHOD> Revision Changes Path 1.4 +58 -0 jbosstest/src/main/org/jboss/test/bmp/beans/SimpleBMPBean.java Index: SimpleBMPBean.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/bmp/beans/SimpleBMPBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SimpleBMPBean.java 15 Feb 2002 06:15:51 -0000 1.3 +++ SimpleBMPBean.java 6 Mar 2002 20:23:24 -0000 1.4 @@ -74,10 +74,68 @@ return id; } + public Integer ejbCreateMETHOD (int _id, String _name) + throws CreateException, RemoteException + { + log.debug ("ejbCreateMETHOD (int, String) called"); + + id = new Integer (_id); + + boolean dublicate = false; + + Connection con = null; + try + { + con = ds.getConnection (); + Statement s = con.createStatement (); + ResultSet rs = s.executeQuery ("SELECT id FROM simplebean WHERE id=" + id.toString ()); + dublicate = rs.next (); + rs.close (); + s.close (); + + if (!dublicate) + { + PreparedStatement ps = con.prepareStatement ("INSERT INTO simplebean VALUES (?,?)"); + ps.setInt (1, _id); + ps.setString (2, _name); + ps.execute (); + ps.close (); + + name = _name; + } + } + catch (Exception _e) + { + throw new EJBException ("couldnt create: "+_e.getMessage ()); + } + finally + { + try + { + if (con != null) + con.close (); + } + catch (Exception _sqle) + { + } + } + + if (dublicate) + throw new DuplicateKeyException ("Bean with id="+_id+" already exists."); + + return id; + } + public void ejbPostCreate (int _id, String _name) throws CreateException, RemoteException { log.debug ("ejbPostCreate (int, String) called"); + } + + public void ejbPostCreateMETHOD (int _id, String _name) + throws CreateException, RemoteException + { + log.debug ("ejbPostCreateMETHOD (int, String) called"); } public void ejbLoad ()
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development