|
The DataSource interface was envisioned by the JDBC powers to almost always be used in conjunction with JNDI. Unfortunately, this implies a large number of assumptions that aren't always in place with your applications.
First, it's clear that you have a little more going on than just
Connection connection = dataSource.getConnection();
for your native applications, and we have no clue what that is.
The mostly generic solution would be for you to create your own intermediate class that determines how to get a DataSource and implements the DataSource interface. In your case, the simplest would be to check the OS, then get as usual if you're on the AS/400, otherwise create or get an instance of AS400JDBCConnectionPoolDataSource ( assuming JTOpen ). Generically better would be to use a property to determine whether JNDI ( or other accessor ) should be used or if you need to handle it via creation of a ConnectionPoolDataSource.
If you create your own ConnectionPoolDataSource, then your intermediate class returns connections obtained from the ConnectionPoolDataSource, otherwise from the DataSource obtained through JNDI or other accessor.
In your applications, you would have a call to your intermediate class to obtain the DataSource, then proceed as usual:
DataSource ds = new PLADataSource();
or, if static
DataSource ds = PLADataSource.getDataSource();
then
Connnection connection = ds.getConnection();
Obviously, you can embellish this in any number of ways. HTH,
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: <java400-l@xxxxxxxxxxxx> Sent: Monday, July 28, 2003 9:26 PM Subject: dataSource.getConnection jt400
Hi
I would like to get a connection from a pool using jt400 on the PC like I get natively on the AS/400.
I've got a DataSource configured so that I get a pooled connection natively using
Connection connection = dataSource.getConnection();
Using jt400 it looks like I have to:
AS400JDBCPooledConnection pooledConnection = dataSource.getPooledConnection(); Connection connection = pooledConnection.getConnection();
I'm sure I could implement some roll-your-own pooling but I was wonder if I could use jt400 right out of the box to accomplish this. Any suggestions on how to get a standard DataSource configured for pooling with the Toolbox so I can continue to use the following statement everywhere:
Connnection connection = dataSource.getConnection();
Thanx, PLA
_______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
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.