• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Please help !!!!!!!!!!!

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post your getConnection() method -- my guess is that the problem is actually occuring there.
Kyle
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here, I post getConnection() method.
private Connection getConnection() throws SQLException
{
try {
Context jndiContext = new InitialContext();
DataSource source = (DataSource) jndiContext.lookup("weblogic.data");

return source.getConnection(); }
catch(NamingException ne)
{ throw new EJBException(ne); }
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic