You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Roberto Pellegrino <ro...@quix.it> on 2007/12/04 11:00:45 UTC

Tomcat data source

Hi all,
i use Tomcat *5.5.17 *my question is quite simple: it's possible to use 
a dataSource that are not defined on webApp context???

I define the dataSource on server.xml as follow:

<Resource auth="Container" driverClassName="DriverClassName"
        validationQuery="select count(*) from table"
        maxActive="100" maxIdle="30" maxWait="10000" 
name="jdbc/DataSourceName"
        password="pass" type="javax.sql.DataSource" 
url="jdbc:DBMS://ServerName:Port/dbName" username="user"/>
   
After, i want to be able use this dataSource on java program...
Normally this is the java code to get the dataSource:
    InitialContext initialContext = new InitialContext();
    DataSource ds = (DataSource) 
initialContext.lookup("jdbc:DBMS://ServerName:Port/DbName");
    conn = ds.getConnection();
If the dataSource is not defined on context (<ResourceLink 
name="jdbc/DataSourceName" global="jdbc/DataSourceName" 
type="javax.sql.DataSource"/>) the code return an exception:

Name DataSourceName is not bound in this Context.

Any Suggestions????

Robert.

















---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by Martin Gainty <mg...@hotmail.com>.
setting up Tomcat Datasource information such as the response juha supplied
is correct

You always have the option of connecting straight in without looking up the
DataSource parameters
but you would have to supply all necessary parameters such as user,pass and
driver for example
        if ( c_Driver == null )
            LoadDriver();
        try {
            Properties props = new Properties();
            props.put( c_sUserNameKey, c_sDBUser );
            props.put( c_sPasswordKey, c_sDBPassword );
            return c_Driver.connect( c_sDBURL, props );
            }
        catch ( SQLException sqlex )
            {
            c_Category.error( "Error connecting to database", sqlex );
            throw sqlex;
            }

unless of course there is a disconnect on your definition of datasource?

Martin-
----- Original Message -----
From: "Roberto Pellegrino" <ro...@quix.it>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Wednesday, December 05, 2007 5:13 AM
Subject: Re: Tomcat data source


> I have seen the documentatio many and many times...
> My question is clear? The response to my question is:
> "Isn't possible get dataSource reference if is not defined on webApp
> context"...
> This is a limitation if application expose a method to make query in
> varius and dinamic datasource....
> Only possibilities is defined the connection with url, user, pass,
> driver....
>
> Robert.
>
> Juha Laiho wrote:
> > If you want to access a resource defined in GlobalNamingResources
> > from a webapp, the context description for the webapp must
> > contain a ResourceLink for the resource.
> >
> > ResourceLink is what you use to "map" a server resource name to
> > the resource name expected by the application (so, is something
> > that is created at time of deployment).
> >
> > Please see the documentation:
> > http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
> > http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html
> >
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Resource%20Links
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by Roberto Pellegrino <ro...@quix.it>.
In my application is present a interface (visible only to admin) who 
permit to specificate what kind of db connection use to make query:
- DataConnection --> url, user, pass, driver. If the data are correct it 
work.
- DataSource -->  If data source are defined on webApp context the name 
is the local name.
                            At this point if i want to use all 
datasource defined on server.xml, the unique solution is include all 
datasource in webapp context (with ResourceLink) because is not possible
                            get dataSource via global name.
- Robert -

Konstantin Kolinko wrote:
>> I have seen the documentatio many and many times...
>> My question is clear? The response to my question is:
>> "Isn't possible get dataSource reference if is not defined on webApp
>> context"...
>>     
>
> Yes, it is not possible.The reference should be defined
> (either in context.xml, or in web.xml, but it should be).
>
>   
>> This is a limitation if application expose a method to make query in
>> varius and dinamic datasource....
>> Only possibilities is defined the connection with url, user, pass,
>> driver....
>>     
>
> It is designed so that application deployer (administrator) can check,
> what global resources are accessed by your application.
>
> You know, that those dataSources include name and password, and can be
> used to access the database.   I do not want them to be accessible
> without me explicitly granting / verifying such access.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>   



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by Konstantin Kolinko <kn...@gmail.com>.
> I have seen the documentatio many and many times...
> My question is clear? The response to my question is:
> "Isn't possible get dataSource reference if is not defined on webApp
> context"...

Yes, it is not possible.The reference should be defined
(either in context.xml, or in web.xml, but it should be).

> This is a limitation if application expose a method to make query in
> varius and dinamic datasource....
> Only possibilities is defined the connection with url, user, pass,
> driver....

It is designed so that application deployer (administrator) can check,
what global resources are accessed by your application.

You know, that those dataSources include name and password, and can be
used to access the database.   I do not want them to be accessible
without me explicitly granting / verifying such access.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by Roberto Pellegrino <ro...@quix.it>.
I have seen the documentatio many and many times...
My question is clear? The response to my question is:
"Isn't possible get dataSource reference if is not defined on webApp 
context"...
This is a limitation if application expose a method to make query in 
varius and dinamic datasource....
Only possibilities is defined the connection with url, user, pass, 
driver....

Robert.

Juha Laiho wrote:
> If you want to access a resource defined in GlobalNamingResources
> from a webapp, the context description for the webapp must
> contain a ResourceLink for the resource.
>
> ResourceLink is what you use to "map" a server resource name to
> the resource name expected by the application (so, is something
> that is created at time of deployment).
>
> Please see the documentation:
> http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
> http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html
> http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Resource%20Links
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by Juha Laiho <Ju...@iki.fi>.
If you want to access a resource defined in GlobalNamingResources
from a webapp, the context description for the webapp must
contain a ResourceLink for the resource.

ResourceLink is what you use to "map" a server resource name to
the resource name expected by the application (so, is something
that is created at time of deployment).

Please see the documentation:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
http://tomcat.apache.org/tomcat-6.0-doc/config/globalresources.html
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Resource%20Links

-- 
..Juha

Roberto Pellegrino wrote:
> DataSource defined on webApp context are accessed by similar url :
> java:comp/env/jdbc/dataSourceName.
> Now.
> Is't possible use with a url datasource that are only defined in
> GlobalNamingResources (in server.xml) using the name ???
> 
> - Robert -
> 
> David Smith wrote:
>> Then you might want to incorporate your own DBCP pool and a brief
>> config page in your webapp.
>>
>> - Store config data in a properties file inside WEB-INF or somewhere
>> else.
>> - Use a ServletContextListener to initialize the DataSource and store
>> it in the ServletContext.
>> - Implement a secured jsp or servlet to configure DBCP at runtime and
>> store the result in the config file
>> - On change have the jsp or servlet close down the existing DBCP and
>> replace it with a new one.
>> - Update all the other jsps and servlets to get their DataSource from
>> the ServletContext
>>
>> That's what I'd do at least.
>>
>> --David
>>
>> Roberto Pellegrino wrote:
>>> I have a particular application who make select query and show results.
>>> The dataSource are dinamic and defined by the administrator, not know
>>> at develop time.
>>> I want to be able to use the tomcat dataSource to use the pool...
>>>
>>> - Robert -
>>>
>>> David Smith wrote:
>>>> I don't think you can just define a global datasource and not make a
>>>> reference to it in the context.xml file.
>>>>
>>>> --David
>>>>
>>>> Roberto Pellegrino wrote:
>>>>> Hi all,
>>>>> i use Tomcat *5.5.17 *my question is quite simple: it's possible to
>>>>> use a dataSource that are not defined on webApp context???
>>>>>
>>>>> I define the dataSource on server.xml as follow:
>>>>>
>>>>> <Resource auth="Container" driverClassName="DriverClassName"
>>>>>        validationQuery="select count(*) from table"
>>>>>        maxActive="100" maxIdle="30" maxWait="10000"
>>>>> name="jdbc/DataSourceName"
>>>>>        password="pass" type="javax.sql.DataSource"
>>>>> url="jdbc:DBMS://ServerName:Port/dbName" username="user"/>
>>>>>   After, i want to be able use this dataSource on java program...
>>>>> Normally this is the java code to get the dataSource:
>>>>>    InitialContext initialContext = new InitialContext();
>>>>>    DataSource ds = (DataSource)
>>>>> initialContext.lookup("jdbc:DBMS://ServerName:Port/DbName");
>>>>>    conn = ds.getConnection();
>>>>> If the dataSource is not defined on context (<ResourceLink
>>>>> name="jdbc/DataSourceName" global="jdbc/DataSourceName"
>>>>> type="javax.sql.DataSource"/>) the code return an exception:
>>>>>
>>>>> Name DataSourceName is not bound in this Context.
>>>>>
>>>>> Any Suggestions????
>>>>>
>>>>> Robert.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by Pid <p...@pidster.com>.
Roberto Pellegrino wrote:
> DataSource defined on webApp context are accessed by similar url :
> java:comp/env/jdbc/dataSourceName.
> Now.
> Is't possible use with a url datasource that are only defined in
> GlobalNamingResources (in server.xml) using the name ???

<ResourceLink ...>

In your META-INF/context.xml, allows you to link to a globally scoped
resource.

p



> - Robert -
> 
> David Smith wrote:
>> Then you might want to incorporate your own DBCP pool and a brief
>> config page in your webapp.
>>
>> - Store config data in a properties file inside WEB-INF or somewhere
>> else.
>> - Use a ServletContextListener to initialize the DataSource and store
>> it in the ServletContext.
>> - Implement a secured jsp or servlet to configure DBCP at runtime and
>> store the result in the config file
>> - On change have the jsp or servlet close down the existing DBCP and
>> replace it with a new one.
>> - Update all the other jsps and servlets to get their DataSource from
>> the ServletContext
>>
>> That's what I'd do at least.
>>
>> --David
>>
>> Roberto Pellegrino wrote:
>>> I have a particular application who make select query and show results.
>>> The dataSource are dinamic and defined by the administrator, not know
>>> at develop time.
>>> I want to be able to use the tomcat dataSource to use the pool...
>>>
>>> - Robert -
>>>
>>> David Smith wrote:
>>>> I don't think you can just define a global datasource and not make a
>>>> reference to it in the context.xml file.
>>>>
>>>> --David
>>>>
>>>> Roberto Pellegrino wrote:
>>>>> Hi all,
>>>>> i use Tomcat *5.5.17 *my question is quite simple: it's possible to
>>>>> use a dataSource that are not defined on webApp context???
>>>>>
>>>>> I define the dataSource on server.xml as follow:
>>>>>
>>>>> <Resource auth="Container" driverClassName="DriverClassName"
>>>>>        validationQuery="select count(*) from table"
>>>>>        maxActive="100" maxIdle="30" maxWait="10000"
>>>>> name="jdbc/DataSourceName"
>>>>>        password="pass" type="javax.sql.DataSource"
>>>>> url="jdbc:DBMS://ServerName:Port/dbName" username="user"/>
>>>>>   After, i want to be able use this dataSource on java program...
>>>>> Normally this is the java code to get the dataSource:
>>>>>    InitialContext initialContext = new InitialContext();
>>>>>    DataSource ds = (DataSource)
>>>>> initialContext.lookup("jdbc:DBMS://ServerName:Port/DbName");
>>>>>    conn = ds.getConnection();
>>>>> If the dataSource is not defined on context (<ResourceLink
>>>>> name="jdbc/DataSourceName" global="jdbc/DataSourceName"
>>>>> type="javax.sql.DataSource"/>) the code return an exception:
>>>>>
>>>>> Name DataSourceName is not bound in this Context.
>>>>>
>>>>> Any Suggestions????
>>>>>
>>>>> Robert.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by Roberto Pellegrino <ro...@quix.it>.
DataSource defined on webApp context are accessed by similar url : 
java:comp/env/jdbc/dataSourceName.
Now.
Is't possible use with a url datasource that are only defined in 
GlobalNamingResources (in server.xml) using the name ???

- Robert -

David Smith wrote:
> Then you might want to incorporate your own DBCP pool and a brief 
> config page in your webapp.
>
> - Store config data in a properties file inside WEB-INF or somewhere 
> else.
> - Use a ServletContextListener to initialize the DataSource and store 
> it in the ServletContext.
> - Implement a secured jsp or servlet to configure DBCP at runtime and 
> store the result in the config file
> - On change have the jsp or servlet close down the existing DBCP and 
> replace it with a new one.
> - Update all the other jsps and servlets to get their DataSource from 
> the ServletContext
>
> That's what I'd do at least.
>
> --David
>
> Roberto Pellegrino wrote:
>> I have a particular application who make select query and show results.
>> The dataSource are dinamic and defined by the administrator, not know 
>> at develop time.
>> I want to be able to use the tomcat dataSource to use the pool...
>>
>> - Robert -
>>
>> David Smith wrote:
>>> I don't think you can just define a global datasource and not make a 
>>> reference to it in the context.xml file.
>>>
>>> --David
>>>
>>> Roberto Pellegrino wrote:
>>>> Hi all,
>>>> i use Tomcat *5.5.17 *my question is quite simple: it's possible to 
>>>> use a dataSource that are not defined on webApp context???
>>>>
>>>> I define the dataSource on server.xml as follow:
>>>>
>>>> <Resource auth="Container" driverClassName="DriverClassName"
>>>>        validationQuery="select count(*) from table"
>>>>        maxActive="100" maxIdle="30" maxWait="10000" 
>>>> name="jdbc/DataSourceName"
>>>>        password="pass" type="javax.sql.DataSource" 
>>>> url="jdbc:DBMS://ServerName:Port/dbName" username="user"/>
>>>>   After, i want to be able use this dataSource on java program...
>>>> Normally this is the java code to get the dataSource:
>>>>    InitialContext initialContext = new InitialContext();
>>>>    DataSource ds = (DataSource) 
>>>> initialContext.lookup("jdbc:DBMS://ServerName:Port/DbName");
>>>>    conn = ds.getConnection();
>>>> If the dataSource is not defined on context (<ResourceLink 
>>>> name="jdbc/DataSourceName" global="jdbc/DataSourceName" 
>>>> type="javax.sql.DataSource"/>) the code return an exception:
>>>>
>>>> Name DataSourceName is not bound in this Context.
>>>>
>>>> Any Suggestions????
>>>>
>>>> Robert.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by David Smith <dn...@cornell.edu>.
Then you might want to incorporate your own DBCP pool and a brief config 
page in your webapp.

- Store config data in a properties file inside WEB-INF or somewhere else.
- Use a ServletContextListener to initialize the DataSource and store it 
in the ServletContext.
- Implement a secured jsp or servlet to configure DBCP at runtime and 
store the result in the config file
- On change have the jsp or servlet close down the existing DBCP and 
replace it with a new one.
- Update all the other jsps and servlets to get their DataSource from 
the ServletContext

That's what I'd do at least.

--David

Roberto Pellegrino wrote:
> I have a particular application who make select query and show results.
> The dataSource are dinamic and defined by the administrator, not know 
> at develop time.
> I want to be able to use the tomcat dataSource to use the pool...
>
> - Robert -
>
> David Smith wrote:
>> I don't think you can just define a global datasource and not make a 
>> reference to it in the context.xml file.
>>
>> --David
>>
>> Roberto Pellegrino wrote:
>>> Hi all,
>>> i use Tomcat *5.5.17 *my question is quite simple: it's possible to 
>>> use a dataSource that are not defined on webApp context???
>>>
>>> I define the dataSource on server.xml as follow:
>>>
>>> <Resource auth="Container" driverClassName="DriverClassName"
>>>        validationQuery="select count(*) from table"
>>>        maxActive="100" maxIdle="30" maxWait="10000" 
>>> name="jdbc/DataSourceName"
>>>        password="pass" type="javax.sql.DataSource" 
>>> url="jdbc:DBMS://ServerName:Port/dbName" username="user"/>
>>>   After, i want to be able use this dataSource on java program...
>>> Normally this is the java code to get the dataSource:
>>>    InitialContext initialContext = new InitialContext();
>>>    DataSource ds = (DataSource) 
>>> initialContext.lookup("jdbc:DBMS://ServerName:Port/DbName");
>>>    conn = ds.getConnection();
>>> If the dataSource is not defined on context (<ResourceLink 
>>> name="jdbc/DataSourceName" global="jdbc/DataSourceName" 
>>> type="javax.sql.DataSource"/>) the code return an exception:
>>>
>>> Name DataSourceName is not bound in this Context.
>>>
>>> Any Suggestions????
>>>
>>> Robert.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by Roberto Pellegrino <ro...@quix.it>.
I have a particular application who make select query and show results.
The dataSource are dinamic and defined by the administrator, not know at 
develop time.
I want to be able to use the tomcat dataSource to use the pool...

- Robert -

David Smith wrote:
> I don't think you can just define a global datasource and not make a 
> reference to it in the context.xml file.
>
> --David
>
> Roberto Pellegrino wrote:
>> Hi all,
>> i use Tomcat *5.5.17 *my question is quite simple: it's possible to 
>> use a dataSource that are not defined on webApp context???
>>
>> I define the dataSource on server.xml as follow:
>>
>> <Resource auth="Container" driverClassName="DriverClassName"
>>        validationQuery="select count(*) from table"
>>        maxActive="100" maxIdle="30" maxWait="10000" 
>> name="jdbc/DataSourceName"
>>        password="pass" type="javax.sql.DataSource" 
>> url="jdbc:DBMS://ServerName:Port/dbName" username="user"/>
>>   After, i want to be able use this dataSource on java program...
>> Normally this is the java code to get the dataSource:
>>    InitialContext initialContext = new InitialContext();
>>    DataSource ds = (DataSource) 
>> initialContext.lookup("jdbc:DBMS://ServerName:Port/DbName");
>>    conn = ds.getConnection();
>> If the dataSource is not defined on context (<ResourceLink 
>> name="jdbc/DataSourceName" global="jdbc/DataSourceName" 
>> type="javax.sql.DataSource"/>) the code return an exception:
>>
>> Name DataSourceName is not bound in this Context.
>>
>> Any Suggestions????
>>
>> Robert.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat data source

Posted by David Smith <dn...@cornell.edu>.
I don't think you can just define a global datasource and not make a 
reference to it in the context.xml file.

--David

Roberto Pellegrino wrote:
> Hi all,
> i use Tomcat *5.5.17 *my question is quite simple: it's possible to 
> use a dataSource that are not defined on webApp context???
>
> I define the dataSource on server.xml as follow:
>
> <Resource auth="Container" driverClassName="DriverClassName"
>        validationQuery="select count(*) from table"
>        maxActive="100" maxIdle="30" maxWait="10000" 
> name="jdbc/DataSourceName"
>        password="pass" type="javax.sql.DataSource" 
> url="jdbc:DBMS://ServerName:Port/dbName" username="user"/>
>   After, i want to be able use this dataSource on java program...
> Normally this is the java code to get the dataSource:
>    InitialContext initialContext = new InitialContext();
>    DataSource ds = (DataSource) 
> initialContext.lookup("jdbc:DBMS://ServerName:Port/DbName");
>    conn = ds.getConnection();
> If the dataSource is not defined on context (<ResourceLink 
> name="jdbc/DataSourceName" global="jdbc/DataSourceName" 
> type="javax.sql.DataSource"/>) the code return an exception:
>
> Name DataSourceName is not bound in this Context.
>
> Any Suggestions????
>
> Robert.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org