Sorry, after reading the replies from others, I think I better understand
what you are asking (correct me if I'm wrong again.) The interest sample
program is not doing anything with a database. It simply invokes a method
on an EJB, which returns a simple value.
You can definitely connect to an EJB from a standalone application, just
like the interest sample does. JSPs connect to a database directly by
obtaining a JDBC connection themselves. Your standalone app can do the same
thing. This won't involve JBoss. If all you want is a connection pool, you
can do that totally inside your standalone app using one of several open
source connection pools.
What you cannot do is invoke a method on an EJB running in JBoss to return
to your standalone app a pooled database connection. JBoss is running in a
JVM on computer A, while your standalone app is running in a separate JVM on
computer B (where A may equal B.) Thus, a connection obtained by an EJB in
JBoss could not be handed out to your standalone app.
----- Original Message -----
From: "Ed Aihua Wu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 09, 2001 11:45 PM
Subject: Re: [JBoss-user] cann't get a connection from outside of the jboss
container.
> I understand JBoss is a container and provide the
> service to its components.
> I have a stand-alone test program (not a component
> inside the JBoss directories) and try to get a
> connection from JBoss. If a JSP page (it is not inside
> the JBoss container) can
> get a connection, why can't a stand-alone client program
> get a connection?
>
> In the interest tutorial program
> provided by JBoss, it has a client program
> InterestClient.java, it is run outside the container,
> It works perfectly well.
>
> So I should be able to get a connection even it is
> outside of the JBoss.
>
> Thanks for any help.
>
> Ed Wu
>
> ----- Original Message -----
> From: "Guy Rouillier" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, April 09, 2001 7:54 AM
> Subject: Re: [JBoss-user] cann't get a connection from outside of the
jboss
> container.
>
>
> > Use
> >
> > lookup("java:comp/env/jdbc/mySQLDS")
> >
> > in your bean, then in your ejb-jar.xml use something like this
> >
> > <resource-ref>
> > <description>A jdbc connection</description>
> > <res-ref-name>jdbc/mySQLDS</res-ref-name>
> > <res-type>javax.sql.DataSource</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> >
> > and finally in your jboss.xml use something like this:
> >
> > <resource-managers>
> > <resource-manager>
> > <res-jndi-name>mySQLDSndi-name>
> > <res-name>jdbc/mySQLDSame>
> > </resource-manager>
> > </resource-managers>
> >
> > where the res-jndi-name is the name that shows up in the jboss console
> > (after the java:/). What exactly do you mean by "My java code (outside
of
> > the jboss container)"? The whole purpose of JBoss (any app server) is
to
> > run inside the container. If you are running outside, you don't need
> jboss.
> >
> >
> > ----- Original Message -----
> > From: "Ed Aihua Wu" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Sunday, April 08, 2001 3:00 AM
> > Subject: [JBoss-user] cann't get a connection from outside of the jboss
> > container.
> >
> >
> > > Hi,
> > >
> > > I am using jboss 2.1 and I am trying to get a connection
> > > from the jboss connection pool.
> > >
> > > I have installed a jdbc driver in jboss,
> > > then I started the jboss, I can see my driver
> > > is started.
> > > [mySQLDS] Starting
> > > [mySQLDS] XA Connection pool mySQLDS bound to java:/mySQLDS
> > > [mySQLDS] Started
> > >
> > > My java code (outside of the jboss container) is something like this:
> > > (I have tryed java:comp/env/mySQLDS, it doesn't work either.)
> > >
> > > System.setProperty("java.naming.factory.initial",
> > > "org.jnp.interfaces.NamingContextFactory");
> > > System.setProperty("java.naming.provider.url",
> > > "localhost:1099");
> > > Context initial = new InitialContext();
> > > DataSource dataSource =
> > > (DataSource)initial.lookup("java:/mySQLDS");
> > > return dataSource.getConnection();
> > >
> > > The exception is something like this:
> > >
> > > javax.naming.NameNotFoundException: mySQLDS not bound
> > > at
> > > sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Stream
> > > RemoteCall.java:245)
> > > at
> > > sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
> > > 220)
> > > at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
> > > at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
> > > at
> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:295)
> > > at
> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:279)
> > > at javax.naming.InitialContext.lookup(InitialContext.java:350)
> > > at JDBCTest.getJbossConnection(JDBCTest.java:79)
> > > at JDBCTest.go(JDBCTest.java:40)
> > > at JDBCTest.main(JDBCTest.java:29)
> > >
> > > Thanks for any help.
> > >
> > > Ed Wu
> > >
> > >
> > > _______________________________________________
> > > 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
> >
>
> _______________________________________________
> 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