× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



    Hi,

> Did you see my previous email I sent with the source to my new
> ToolboxDataSource class?  How does that look?  It works great so far.

    It came in as my last one went out.  Then I had to do some work for
those pesky clients, since I have to eat occasionally.

    I would have done it a little differently, but it looks like this should
work OK for your needs.  If I get the time, I may do a short article about
it off conceptGO's community page or elsewhere.  A couple of things:

    I would be sure that your documentation specifies that your
ToolboxDataSource is a connection pooler.  Normally, you would not want
regular apps to use it unless there were multiple threads doing lots of work
with ( relatively ) short lived connections.

    You should also override

getConnection(java.lang.String user, java.lang.String password)

probably to throw an exception.  Otherwise, a user could call it on your
AS400JDBCConnectionPoolDataSource ( remember, they extended it from
AS400JDBCDataSource ) and get a non-pooled, non-managed connection.

    Finally, this is not really a work around, but the sort of thing that
actually has to be done, even with a JNDI obtained pool managed DataSource.
It's just all hidden from you there.  And, it's not peculiar to JTOpen,
although some things, like the co-mingling of the DataSource and
ConnectionPoolDataSource interfaces in the AS400JDBCConnectionPoolDataSource
implementation, certainly are.

    Anyhow, I'm glad you were able to resolve the issue.  I think it was a
useful discussion for the list because some of this is not at all obvious,
and I hope no one was bored,  Best,


                                                         Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO         -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?             http://www.jguru.com/faq/Java400


----- Original Message -----
From: "Patrick L Archibald" <Patrick.Archibald@xxxxxxxxxxxxx>
To: "Java Programming on and around the iSeries / AS400"
<java400-l@xxxxxxxxxxxx>
Sent: Tuesday, July 29, 2003 6:20 PM
Subject: Re: dataSource.getConnection jt400


> Here is my work around. I created a class called ToolboxDataSource that
> extends the AS400JDBCConnectionPool.
>
> package com.hometelco.intranet;
> import java.sql.*;
> import com.ibm.as400.access.*;
> /**
>  * @author     Patrick L Archibald
>  * @created    July 29, 2003
>  */
> public class ToolboxDataSource extends AS400JDBCConnectionPoolDataSource {
>   AS400JDBCConnectionPool pool = null;
>   private String system;
>   private String user;
>   private String password;
>   public ToolboxDataSource(String system, String user, String password) {
>     super(system, user, password);
>     this.system = system;
>     this.user = user;
>     this.password = password;
>   }
>   public Connection getConnection() throws SQLException {
>     Connection connection = null;
>     if (pool == null) {
>       System.out.println("Get pool. Date: " + new java.util.Date());
>       AS400JDBCConnectionPoolDataSource test = new
> AS400JDBCConnectionPoolDataSource(system, user, password);
>       pool = new AS400JDBCConnectionPool(test);
>       try {
>         pool.fill(5);
>       }
>       catch (ConnectionPoolException e) {
>         System.out.println("ConnectionPoolException");
>       }
>     }
>     try {
>       connection = pool.getConnection();
>     }
>     catch (ConnectionPoolException e) {
>       System.out.println("ConnectionPoolException");
>     }
>     return connection;
>   }
> }
>
>
> Thanx, PLA







As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.