Re: Datasource and tomcat, Postgresql 7.4, jkd1.4.1 --

Поиск
Список
Период
Сортировка
От Christopher Elkins
Тема Re: Datasource and tomcat, Postgresql 7.4, jkd1.4.1 --
Дата
Msg-id 3157863E-3EBC-11D7-A1D6-0003936808BE@scardini.com
обсуждение исходный текст
Ответ на Re: Datasource and tomcat, Postgresql 7.4, jkd1.4.1 --  (GB Clark <postgres@vsservices.com>)
Список pgsql-jdbc
This is off-topic, but it's not exactly well-documented anywhere.


On Tuesday, February 11, 2003, at 07:12 PM, GB Clark wrote:

> I had to include my database parameters INSIDE the context for my
> application.  Can anyone tell
> me why this fixed my problem?  Or is that where the database
> parameters should be anyway...

Typically, that's where they're defined. However, as you've noticed,
this is less than ideal for resources that you want to share across
webapp contexts.

> If I wanted another servlet to use the same datasource would I have to
> duplicate the parameters
> everytime?

You can configure global resources (i.e., in the
<GlobalNamingResources> section), but you need to use a slightly
different syntax in your webapp context in order for it to "see" them.

Specifically, add the relevant <Resource> and <ResourceParams> elements
to the global resources section. Then, in your webapp context add a
<ResourceLink> element.

For example,

<GlobalNamingResources>
   <Resource name="jdbc/ globaldb" type="javax.sql.DataSource" />
   <ResourceParams name="jdbc/ globaldb">
     .. the usual DBCP configuration stuff ...
   </ResourceParams>
</GlobalNamingResources>
...
<Context path="/myapp">
   <ResourceLink name="jdbc/mydb" global="jdbc/globaldb"
type="javax.sql.DataSource" />
</Context>

Your code can now lookup "java:comp/env/jdbc/mydb" and get a reference
to the globally-defined data source. Keep in mind that because this is
a Tomcat-specific configuration feature, you cannot define it in the
webapp's deployment descriptor (i.e., web.xml) and must therefore
deploy your webapp "manually" (e.g., through Tomcat's manager
application).

--
Christopher Elkins


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Barry Lind
Дата:
Сообщение: Re: [HACKERS] Wrong charset mappings
Следующее
От: Peter Katzmann
Дата:
Сообщение: Re: Timestamp problems