WebSphere Application Server - Problem with datasource setup

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Application Server > May 2004 > Problem with datasource setup





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Problem with datasource setup
narenn1

2004-05-19, 5:38 pm

I successfully compiled a sample Struts application using WSAD 5.1. The problem is that getDataSource(request) returns null. (request is pointer to HttpServletRequest) This is my datasource in struts-config file ...

<data-sources>
<data-source key="env7" type="oracle.jdbc.pool.OracleDataSource">
<set-property property="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
<set-property property="url" value="jdbc:oracle:thin:@caps00.fmr.com:1521:ntg1"/>
<set-property property="username" value="scott"/>
<set-property property="password" value="tiger"/>
<set-property property="minCount" value="2"/>
<set-property property="maxCount" value="5" />
</data-source>
</data-sources>

I am using oracle 8.1.7 i downloaded their latest classes12.zip file. I have tried this with test environment of WSAD as well as installing the application on WebSphere 5.0 server. It does not work and fails at the same place. I have zero errors after
i build the application. What am i doing wrong? Please advise.

Thank you

-Narendra
narenn1

2004-05-19, 5:38 pm

Sorry the datasource somehome did not get in, i had to remove leading < and trailing >....
Here it is anyway...

data-sources
data-source key="env7" type="oracle.jdbc.pool.OracleDataSource"
set-property property="driverClass" value="oracle.jdbc.driver.OracleDriver"/
set-property property="url" value="jdbc:oracle:thin:@caps00.fmr.com:1521:ntg1"/
set-property property="username" value="scott"/
set-property property="password" value="tiger"/
set-property property="minCount" value="2"/
set-property property="maxCount" value="5" /
/data-source
/data-sources



Paul Ilechko

2004-05-19, 5:38 pm

narenn1 wrote:

> I successfully compiled a sample Struts application using WSAD 5.1.
> The problem is that getDataSource(request) returns null. (request is
> pointer to HttpServletRequest) This is my datasource in
> struts-config file ...
>
> <data-sources> <data-source key="env7"
> type="oracle.jdbc.pool.OracleDataSource"> <set-property
> property="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
> <set-property property="url"
> value="jdbc:oracle:thin:@caps00.fmr.com:1521:ntg1"/> <set-property
> property="username" value="scott"/> <set-property property="password"
> value="tiger"/> <set-property property="minCount" value="2"/>
> <set-property property="maxCount" value="5" /> </data-source>
> </data-sources>
>
> I am using oracle 8.1.7 i downloaded their latest classes12.zip file.
> I have tried this with test environment of WSAD as well as installing
> the application on WebSphere 5.0 server. It does not work and fails
> at the same place. I have zero errors after i build the application.
> What am i doing wrong? Please advise.
>
> Thank you
>
> -Narendra


From the WAS infocenter:

Using a resource reference to access your data source or connection
factory is required when running in WebSphere Application Server. Some
of the reasons follow:

* If a data source is looked up directly, the connection gets all
default properties for the missing resource reference. For example, the
sharing-scope is a shareable connection resulting in the possibility
that the physical connection is the same each time the connection is
requested from the data source. This situation can cause a multitude of
problems if you expect unshareable connections.
* It relieves the programmer from having to know the name of the
actual data source at the target application server.
* You can set the default isolation level for the data source
through resource references. With no resource reference you get the
default for the JDBC driver you use.

Use a resource reference (resource-ref) for looking up a data source
through the standard Java Naming and Directory Interface (JNDI) naming
interface. The JNDI name defined in the resource-ref is a logical name
of the data source. Have your application use this JNDI name to look up
a data source instead of using the JNDI name that is defined on the data
source.

Later, you can substitute the real name, either by using the Assembly
Toolkit (ATK) or during installation of the application EAR file onto
the server.

For example, assume that you use a DataSource jdbc/Section as
illustrated in the code below.

javax.sql.DataSource specificDataSource =
(javax.sql.DataSource) javax.rmi.PortableRemoteObject.narrow( (new
InitialContext()).lookup("java:comp/env/jdbc/Section"),

javax.sql.DataSource.class);

In the ATK, specify the name (jdbc/Section) as the resource reference.
If you know the name of the DataSource, you specify it in the resource
references Bindings page.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com