struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kyle Korndoerfer <kkorndoer...@yahoo.com>
Subject Re: Problem with PostgreSQL data source
Date Sat, 02 Oct 2004 15:20:27 GMT
> 1. You should use the Container (Tomat and not Struts) data source
> and not use connection pool, rather the DataSourcePool that comes
with
> JDBC drivers. Connections are more for clients and PooledDataSource
> is for servers, so use that part of any JDBC driver.
 
OK, can you show me what the configuration should look like?

The only info I've found is on Tomcat's website, but doesn't mention
anything about using the DataSourcePool drivers from PostgreSQL. This
is what I think my files should look like based on what I've been able
to find online...

===== web.xml snippet ==========
<resource-ref>
  <description>DataSource for PostgreSQL database</description>
  <res-ref-name>jdbc/PostgreSQL</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>
===== web.xml snippet ==========

===== context.xml snippet ==========
<Resource name="jdbc/PostgreSQL" auth="Container"
    type="javax.sql.DataSource" />

<ResourceParams name="jdbc/PostgreSQL">
  <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
  </parameter>
  <parameter>
    <name>driverClassName</name>
    <value>org.postgresql.Driver</value>
  </parameter>
  <parameter>
    <name>url</name>
    <value>jdbc:postgresql://192.168.200.10/testdb</value>
  </parameter>

  <parameter>
    <name>username</name>
    <value>username</value>
  </parameter>
  <parameter>
    <name>password</name>
    <value>password</value>
  </parameter>

  <parameter>
    <name>maxActive</name>
    <value>20</value>
  </parameter>
  <parameter>
    <name>maxIdle</name>
    <value>10</value>
  </parameter>
  <parameter>
    <name>maxIdle</name>
    <value>10</value>
  </parameter>
  <parameter>
    <name>maxWait</name>
    <value>-1</value>
  </parameter>

  <parameter>
    <name>removeAbandoned</name>
    <value>true</value>
  </parameter>
  <parameter>
    <name>removeAbandonedTimeout</name>
    <value>300</value>
  </parameter>
</ResourceParams>
===== context.xml snippet ==========

What needs to change with these file to do like you mentioned?

Do you use the same method to get a connection as you normally would?

===== snippet ==========
Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup( "java:/comp/env" );
DataSource ds = (DataSource)envContext.lookup( "jdbc/PostgreSQL" );
Connection conn = ds.getConnection();
//etc.
===== snippet ==========


> pgSQL rocks!

I agree, which is why I really want to get this working! Thanks for the
help!

> 
> good luck.
> 
> .V
> 
> 
> Kyle Korndoerfer wrote:
> > I am not running PostgreSQL on my Windows box. The connection
> string in
> > the Data Source config section is pointing to the SuSE box. I am
> using
> > pgAdmin III on my Windows box to manage the database without error,
> so
> > I can connect to my SuSE box and PostgreSQL without issue.
> > 
> > I launch Tomcat from within Eclipse strictly for debugging
> purposes.
> > Even though I am using the Sysdeo plugin (to get the debugging
> > capability), my Ant build script copies the WAR file into the
> > TOMCAT/webapps folder first, then I start Tomcat (I do not use any
> of
> > the deploy tools with the Sysdeo Plugin).
> > 
> > The PostgreSQL jar file is configured as a User Library within
> Eclipse
> > and has been added to my Project. I've also tried loading Tomcat
> > individually (not from within Eclipse), but I still get the same
> error.
> > 
> > I think the issue is less about being able to actually talk to the
> > server & service, since it can't even load the Driver (which you
> have
> > to do before even attempting to make a connection).
> > 
> > The crazy part about this is that I've used the Struts DataSources
> with
> > PostgreSQL in the past without issue.
> > 
> > I'm going to download the latest PostgreSQL JDBC drivers tonight
> and
> > see if that makes any difference. Hopefully it will, since I'm
> still
> > utterly stumped...
> > 
> > Thanks for the help so far.
> > 
> > -={ Kyle }=-
> > 
> > 
> > --- Paul Woods <lists@nwnetsolutions.net> wrote:
> > 
> > 
> >>On Mon, 2004-09-27 at 20:57, Kyle Korndoerfer wrote:
> >>
> >>>OK, so my idea (recently upgraded Tomcat to 5.0.28 thinking the
> >>
> >>problem
> >>
> >>>could be thier and forgot to update my $CATALINA_HOME to take that
> >>
> >>into
> >>
> >>>account), but that didn't help...
> >>>
> >>>Still stumped. Anyone? Bueler?
> >>>
> >>>Thanks for any help/suggestions. I've been starring at it so long,
> >>
> >>I
> >>
> >>>know it must be something simple.
> >>>
> >>>-={ Kyle }=-
> >>
> >>David brings up an interesting point.  I'd expand a bit and ask if
> >>you
> >>can connect to the Suse box's postgres via psql (is that available
> >>for
> >>windows?) on your windows box?  psql is a command line client - and
> >>would verify that you have permissions on the suse box to connect
> >>from a
> >>remote client (and that the network setup is correct).
> >>
> >>Something else that crossed my mind.  If you have the JAR in the
> /lib
> >>directory of your webapp, in eclipse, right click on the webapp
> >>project,
> >>and select 'properties'.  Verify that the .jar file is in the
> >>Libraries
> >>tab underneath Java Build Path.  Sometimes just putting in /lib
> isn't
> >>enough.
> >>
> >>
> >>
> >>
>
>>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> > 
> > 
> > 
> > 
> > 		
> > _______________________________
> > Do you Yahoo!?
> > Declare Yourself - Register online to vote today!
> > http://vote.yahoo.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


=====
-={ Kyle }=-


		
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message