anonymous wrote :
|
| 1, how can I get the datasource object so to get a connection ? Since my web app is in
the save JVM, could i get the datasource directly without a jndi lookup (may fetch the
datasource mbean directly ?)? some code snippet will be really appreciated.
|
|
Being in VM has nothing to do with it. JNDI is the *only* way to look up the managed
object. Your choice of how you do this depends:
You can always look up the object directly in JNDI
InitialContext initCtx = new InitialContext();
DataSource ds = (DataSource)initCtx.lookup("java:/PostgresDS");
Note the use of the "java:/" qualifier in the lookup. DataSources are, by
default, bound into the java: namespace and are meant to be used within the context of
JBoss and not remotely (ie by a thin Client). Note, there is a way to disable this and use
it outside of the container but it is *not*, and I cannot stress this more emphatically,
*not* recommended.
The other approach is to use a resource-ref in your web.xml/ejb-jar.xml file. This
introduces a logical binding between a name and a raw jndi name. Consult the relevant J2EE
specifications for more information.
anonymous wrote :
| 2,Is the database connections REALLY been pooled ,according the config like above ?
|
Yes.
anonymous wrote :
| 3,how to config to let jboss server initiate serveral database connection when
startup?
|
JBoss 4.0.5 introduces a option to JBoss/JCA. The deault pool behavior does not construct
managed connections on startup but rather, uses lazy initialization. The option allows
the pool to prefill to the mininum allowance. Note, this can only be used for pools with
the criteria of 'ByNothing'.
See
http://wiki.jboss.org/wiki/Wiki.jsp?page=ConfigDataSources
and
http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossJCAPooling
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969896#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...