× 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.



This is a multipart message in MIME format.
--
[ Picked text/plain from multipart/alternative ]
we need regular access on different db-tables to our iSeries.  At the
moment I created a connectionobject which is placed in the session-context
to be used for all db-access within the EAR.  Each time a module needs
data from the iSeries,I give the connection-object as a parameter to my
database-objects.  I use this trick to avoid opening and closing
databaseconnections all the time.

Now i'm experimenting with connection-pooling which should be faster, as
they say.  As far as I understand it, it also creates a connection which I
could keep into a sessionvar but, what's my profit then?  I still use one
connection which is created at logon and is kept open all the time and
used as needed.

So what I 'dlike to know :
- what's my profit here?
- what can I expect when I remove the connection from my session and use
db-access using connectionpooling, I need a connection for each access
then, no?

I got following working example:
1) create a connection
2) create a statement
3) execute statement
4) examine resultset
5) close connection

this seems to be quit the same as using direct jdbc-connections???

import java.sql.*;
public class TestDataSource
{
        public static void main(String[] args)
        {
                Connection connection = null;
                String name;
                try
                {
                        java.util.Hashtable parms = new java.util.Hashtable();
 parms.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
                           //"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
                           "com.ibm.websphere.naming.WsnInitialContextFactory");
                        javax.naming.Context ctx = new 
javax.naming.InitialContext(parms);

                        javax.sql.DataSource ds =
(javax.sql.DataSource)ctx.lookup("jdbc/testDS");
                        connection = ds.getConnection("user", "pasword");
                        Statement query = connection.createStatement();
                        ResultSet rs = query.executeQuery("Select * from 
PERSONNEL");

                        while(rs.next())
                        {
                                name = rs.getString("FNAME");
                                System.out.println("name = " + name);
                        }
                        rs.close();
                        connection.commit();
                        connection.close();
                }
                catch (javax.naming.NamingException e)
                {
                        System.out.println(e);
                        return false;
                }
                catch (SQLException e)
                {
                        System.out.println(e);
                        try
                        {
                                connection.rollback();
                        }
                        catch (Exception e1)
                        {
                                System.out.println("Rollback fails");
                        }
                        return false;
                }
                return true;
        }
}




"   I don't have problems, only challenges...  "

Patrick Goovaerts
WebMaster
Clipper Support nv
TEL : 0032 (0)3 5453991
GSM: 0498 610 325
WEB: www.conti7.be


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.