Hi,
The way you access the datasource is dependent on where will you access the
datasource from. I'm currently accessing the datasource from a servlet which
is pretty straightforward:
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/SQLServerDS");
The above method might not be portable but it works for me so I mention it.
Note that you don't need any special Orion datasource name. DataSource is
defined in javax.sql.*
The portable way which require more work is to add the following to your
web.xml if you access the datasource from servlets and/or JSP:
<context-param>
<param-name>myDS</param-name>
<param-value>jdbc/SQLServerDS</param-value>
</context-param>
<resource-ref>
<description>A data source</description>
<res-ref-name>myDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>CONTAINER</res-auth>
</resource-ref>
Now, you can access the datasource by:
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/myDS");
--Deepak
-----Original Message-----
From: Luis M Bernardo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 12, 2000 7:39 AM
To: Goel, Deepak
Subject: Re: ANSWER: How to use pooled connections in Orion?
hi. thanks for posting this message, but could you show me how you make
the connection (a code snippet)? Looking at old postings I see some people
using a DataSource and some others a ConnectionPoolDataSource. Also, you
use a DriverManagerDataSource, some other people use a
ConnectionDataSource.
cheers,
luis
On Sat, 7 Oct 2000, Goel, Deepak wrote:
> Hello everyone,
>
> I've seen that many people are confused over how to setup pooled
connections
> in Orion (even I was initially). Now since I figured out through
> documentation and through some hit and try, I would like to share these
> instructions. Keep in mind that this is only one way of setting it up and
> there are other ways to setup depending on capabilities of the driver.
>
> 1. Basically, the first step is to create a non-pooled version of your
data
> source. This can be done by adding something like this to your
> data-sources.xml:
>
> <data-source
> class="com.evermind.sql.DriverManagerDataSource"
> name="SQLServerNP"
> location="jdbc/SQLServerNP"
> xa-location="jdbc/xa/SQLServerXANP"
> ejb-location="jdbc/SQLServerNP"
> connection-driver="com.inet.tds.TdsDriver"
> username="user"
> password="pwd"
> url="jdbc:inetdae:localhost"
> inactivity-timeout="30"
> schema="database-schemas\ms-sql.xml"
> />
>
> The above example is for a SQL Server data source using i-net driver.
> Remeber to change the connection-driver, username, password and url.
>
> 2. Now, the following step will add the pooled version. Add the following
> lines to data-sources.xml.
>
> <data-source
> class="com.evermind.sql.OrionPooledDataSource"
> name="SQLServer"
> location="jdbc/SQLServerDS"
> xa-location="jdbc/xa/SQLServerXADS"
> ejb-location="jdbc/SQLServerDS"
> max-connections="4"
> source-location="jdbc/SQLServerNP"
> pooled-location="jdbc/SQLServerDS"
> inactivity-timeout="30"
> connection-driver="com.inet.tds.TdsDriver"
> url="jdbc:inetdae:localhost"
> />
>
> Note that the source-location should correspond to location in the 1st
step.
> "max-connections" can be changed to suit your requirements. I'm not sure
> whether url and connection-driver are required here.
>
> The above steps should work for any JDBC drivers. If your driver vendor
> supplies a data source, step 1 will be little bit different. Also, some of
> the driver vendors directly provide pooled data source implementation in
> which case 2 steps are not needed. I could successfully use i-net OPTA
> PooledDataSource with Orion.
>
> --Deepak
>
>