Hi reader,
I had developed a BMP entity bean. Though it inserts the data in access but I am getting the following error while I try to find the record in database: The error I encounter is :
java.rmi.RemoteException: Exception in ejbFindByPrimaryKey; nested exception is:
javax.ejb.EJBException
- with nested exception:
[java.sql.SQLException: Connection has already been closed.]
Start server side stack trace:
java.rmi.RemoteException: Exception in ejbFindByPrimaryKey; nested exception is:
javax.ejb.EJBException
- with nested exception:
[java.sql.SQLException: Connection has already been closed.]
java.sql.SQLException: Connection has already been closed.
Now, I copy paste my ejbFindBy PrimaryKey method.
public ShipPK ejbFindByPrimaryKey(ShipPK pk) throws FinderException
{
Connection con = null;
PreparedStatement st = null;
try
{
con = this.getConnection();
st = con.prepareStatement("select ship_id from ship where ship_id = ?");
st.setInt(1, pk.id);
ResultSet result = st.executeQuery();
if (!result.next())
throw new ObjectNotFoundException("Cannot found object");
}
catch(SQLException se)
{System.out.println(se); }
finally
{
try
{
if (con != null)
con.close();
if (st != null)
st.close();
}
catch(SQLException e)
{ throw new EJBException(e); }
}
return pk;
}
Please let me know what exactly can be problem.
thank you,
