hai
i wrote a BMP bean to insert values in to the database.
the following is the code.
In setEntityContext Method..
public void setEntityContext(EntityContext ctx)
{
this.ctx=ctx;
try
{
getConnection();
}catch(){}
In getConnection Method....
dbName="java:comp/env/jdbc/oraclePool";
public Connection getConnection()throws SQLException
{
Context c=new InitialContext();
DataSource ds=(DataSource).lookup(dbName);
return ds.getConnection();
}
but iam getting an error as unable to connect to the database "java:comp/env/jdbc/oraclePool"
so can u people tell me what is wrong with code
thanks
kiranlal
-
Connection to the database through BMP (3 messages)
- Posted by: kiran lal
- Posted on: January 19 2001 01:22 EST
Threaded Messages (3)
- Connection to the database through BMP by Srini gams on January 19 2001 17:15 EST
- Connection to the database through BMP by kiran lal on January 20 2001 04:05 EST
- Connection to the database through BMP by Kai Bi on January 21 2001 05:31 EST
-
Connection to the database through BMP[ Go to top ]
- Posted by: Srini gams
- Posted on: January 19 2001 17:15 EST
- in response to kiran lal
Check deployment descriptor for the resource ref tags.
<resource-ref>
<res-ref-name>jdbc/oraclePool</res-ref-name>
<res-type>javax.sql.DataSource<res-type>
<res-auth>Container</res-auth>
<res-link>xxx</res-link>
</resource-ref>
XXX- refers to connection cache on your Application server.
Gamini
-
Connection to the database through BMP[ Go to top ]
- Posted by: kiran lal
- Posted on: January 20 2001 04:05 EST
- in response to Srini gams
i did not understand the reply because i did not find anything related to<res-link>xxx</res-link>in any book.
ao please let me know what exactly it is and more ever we can work with BMP without writing any deployment descriptor.
so please let me know.
thanks
kiranlal -
Connection to the database through BMP[ Go to top ]
- Posted by: Kai Bi
- Posted on: January 21 2001 05:31 EST
- in response to kiran lal
hi kiran,
I don't think it's a good idea to get the connection in the "setEntityContext" method. Because of the limit of the number of database connection resource. When the EJB container starts, it'll initiate some pooled Entity Bean Object by calling the setEntityContext method. So, if number of the pooled entity bean instance is larger than the limit of connection of your database, no more connection could be established. I suggest to get the connection as late as possible, for example, get them in the ejbActivate method.
bikai