On Mon, 28 May 2001, Marcel Schepers wrote:
> Hello Per,
>
> I've attached my ejbCreate() implementation and implementation of
> insertRow, a method called by ejbCreate method. The ejbPostCreate()
> method is empty. Thanks for taking a look.
Hi,
You should read Georg's response which deals with MySQL and transactions.
It explains MySQL weirdness that I am blissfully ignorant of.
Anyhoo, it seems as though there is some problem with the insertRow method
that would arise even if you were to use a real database ;)
>
> Marcel
>
[ejbCreate snipped]
> private Long insertRow(Timestamp invoerdatumtijd, String voorletters,
> String tussenvoegsel, String naam, String adres,
> String postcode, String woonplaats,
> String telefoonDag, String telefoonAvond,
> String geboortedatum, String geslacht,
> String email, String groep,
> String vrijeInvoer)
> throws SQLException {
>
> ResultSet resultSet = null;
>
> try{
> String insertStatement =
> m"INSERT INTO formulier (invoerdatumtijd, voorletters, " +
> "tussenvoegsel, naam, adres, postcode, woonplaats, " +
> "telefoonDag, telefoonAvond, geboortedatum, geslacht, " +
> "email, groep, vrijeInvoer) " +
> "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
>
> PreparedStatement prepStmt =
> this.connection.prepareStatement(insertStatement);
>
> prepStmt.setTimestamp(1, invoerdatumtijd);
> prepStmt.setString(2, voorletters);
> prepStmt.setString(3, tussenvoegsel);
> prepStmt.setString(4, naam);
> prepStmt.setString(5, adres);
> prepStmt.setString(6, postcode);
> prepStmt.setString(7, woonplaats);
> prepStmt.setString(8, telefoonDag);
> prepStmt.setString(9, telefoonAvond);
> prepStmt.setString(10, geboortedatum);
> prepStmt.setString(11, geslacht);
> prepStmt.setString(12, email);
> prepStmt.setString(13, groep);
> prepStmt.setString(14, vrijeInvoer);
>
> resultSet = prepStmt.executeQuery();
> prepStmt.close();
> }
> catch(SQLException e){
> if (DEBUG) {
> System.out.println("SQLException in FormBean.insertRow");
> System.out.println(e.getMessage());
> } // end of if (DEBUG)
> throw e;
> }
> finally{
> return new Long(resultSet.getLong("id"));
There will be a problem here since unless there was an SQLException
earlier the resultSet will be closed. The Statement.close() method also
closes the ResultSet. Come to think of it, the statement has gone out of
scope and cannot be relied on so the ResultSet is probably going to be
closed anyway.
Why do you want to return the id if there was an SQLException? The finally
block is executed whenever and however you leave the try/catch block
(save perhaps for System.exit() ;).
BTW...A common way to deal with sql queries is to move the calls to
close() methods to the finally block.
} finally {
try { stmt.close(); } catch(Exception e) {}
}
> }
> }
>
> Per Lewau wrote:
>
> > On Mon, 28 May 2001, Marcel Schepers wrote:
> >
> >
> > Looks like an exception is raised inside your ejbCreate method. If a
> > runtime exception is raised there it will result in a transaction
> > rollback. It could be a NullPointerException; it usually is.
> >
> > Strange though that the database contains the new information. What does
> > your ejbCreate method do?
> >
> >
> >> Hello,
> >>
> >> I have a question regarding an error I get. In a JSP page I use a
> >> regular Java bean. Some properties are set and at the end I call the
> >> bean's create() methode to actually create a new EJB Entity bean.
> >> Creating the EJB fails: I get the error attached to the end of this
> >> message. Now the funny part is that the database contains the new EJB
> >> data. The question I would like to ask you: where to look for the solution?
> >>
> >> The code I use in my regular Java access bean:
> >>
> >> public void createEJB(){
> >> if (DEBUG) {
> >> System.out.println("FormAccessBean.create() --- entry");
> >> } // end of if (DEBUG)
> >>
> >> try{
> >> String jndiName = "stam/Form";
> >> Broker broker = Broker.getInstance();
> >> FormHome formHome = (FormHome)
> >> broker.getHome(jndiName, FormHome.class);
> >> Form form = formHome.create(this.voorletters,
> >> this.tussenvoegsel,
> >> this.naam, this.adres, this.postcode,
> >> this.woonplaats, this.telefoonDag,
> >> this.telefoonAvond, this.geboortedatum,
> >> this.geslacht, this.email, this.groep,
> >> this.vrijeInvoer);
> >> if (DEBUG) {
> >> System.out.println("Form: " + form);
> >> } // end of if (DEBUG)
> >> }
> >> ....
> >> }
> >>
> >>
> >> I have a feeling that my mySQL transaction management is not
> >> configured properly. These are my mySQL settings in jboss.jcml
> >>
> >> <!-- JDBC -->
> >> <mbean code="org.jboss.jdbc.JdbcProvider"
> >> name="DefaultDomain:service=JdbcProvider">
> >> <attribute
> >>
> >>
>name="Drivers">org.hsql.jdbcDriver,org.enhydra.instantdb.jdbc.idbDriver,org.gjt.mm.mysql.Driver</attribute>
>
> >>
> >>
> >> </mbean>
> >> <mbean code="org.jboss.jdbc.XADataSourceLoader"
> >> name="DefaultDomain:service=XADataSource,name=mySQLPool">
> >> <attribute name="PoolName">mySQLPool</attribute>
> >> <attribute
> >>
>name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImpl</attribute>
>
> >>
> >> <attribute name="Properties"></attribute>
> >> <attribute name="URL">jdbc:mysql://x.x.nl/stam</attribute>
> >> <attribute name="GCMinIdleTime">1200000</attribute>
> >> <attribute name="JDBCUser">x</attribute>
> >> <attribute name="MaxSize">10</attribute>
> >> <attribute name="Password">x</attribute>
> >> <attribute name="GCEnabled">false</attribute>
> >> <attribute name="InvalidateOnError">false</attribute>
> >> <attribute name="TimestampUsed">false</attribute>
> >> <attribute name="Blocking">true</attribute>
> >> <attribute name="GCInterval">120000</attribute>
> >> <attribute name="IdleTimeout">1800000</attribute>
> >> <attribute name="IdleTimeoutEnabled">false</attribute>
> >> <attribute name="LoggingEnabled">false</attribute>
> >> <attribute name="MaxIdleTimeoutPercent">1.0</attribute>
> >> <attribute name="MinSize">0</attribute>
> >> </mbean>
> >>
> >> And finally, I've attached the start of the error log messages.
> >>
> >>
> >> [EmbeddedTomcat] FormAccessBean.create() --- entry
> >> [Form] TRANSACTION ROLLBACK EXCEPTION:ejbCreate: null; nested exception is:
> >> javax.ejb.EJBException: ejbCreate: null
> >> [Form] javax.ejb.EJBException: ejbCreate: null
> >> [Form] at nl.inpact.stam.ejb.form.FormBean.ejbCreate(FormBean.java:168)
> >> [Form] at java.lang.reflect.Method.invoke(Native Method)
> >> [Form] at
> >>
>org.jboss.ejb.plugins.BMPPersistenceManager.createEntity(BMPPersistenceManager.java:121)
>
> >>
> >> [Form] at
> >> org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:441)
> >> [Form] at java.lang.reflect.Method.invoke(Native Method)
> >> [Form] at
> >>
>org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:639)
>
> >>
> >> [Form] at
> >>
>org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:160)
>
> >>
> >> [Form] at
> >>
>org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:87)
>
> >>
> >> [Form] at
> >> org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
> >>
> >> [Form] at
> >>
>org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:263)
> >>
> >> [Form] at
> >> org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
> >> [Form] at
> >>
>org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:164)
> >>
> >> [Form] at
> >> org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
> >> [Form] at
> >> org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:316)
> >> [Form] at
> >>
>org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:436)
>
> >>
> >> [Form] at
> >> org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:212)
> >> [Form] at $Proxy9.create(Unknown Source)
> >> [Form] at
> >> nl.inpact.stam.ejb.form.FormAccessBean.createEJB(FormAccessBean.java:128)
> >> [Form] at
> >>
>_0002fformhandle_0002ejspformhandle_jsp_29._jspService(_0002fformhandle_0002ejspformhandle_jsp_29.java:432)
>
> >>
> >>
> >> Thank you,
> >>
> >> Marcel
> >>
> >>
> >> _______________________________________________
> >> JBoss-user mailing list
> >> [EMAIL PROTECTED]
> >> http://lists.sourceforge.net/lists/listinfo/jboss-user
> >>
> >
> > -----------------------------------------------------------------------
> > Per Lewau ([EMAIL PROTECTED])
> >
> > "Why waste time learning, when ignorance is instantaneous?"
> > - Hobbes
> >
> >
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> > http://lists.sourceforge.net/lists/listinfo/jboss-user
> >
> >
> >
>
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
-----------------------------------------------------------------------
Per Lewau ([EMAIL PROTECTED])
"Why waste time learning, when ignorance is instantaneous?"
- Hobbes
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user