Here is my file GetCountryList.java.  I have sent the code for the fragment 
that retrieves the list of countries.  Yes, there are others, for getting the 
states, cities, and holiday lists, but these are all conceptually very similar 
and I have used the same code structure for all of them.
-------------------------------------------------------------
package com.worldholidaysandevents.restjsonwebservice;

import java.util.ArrayList;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class GetCountryList {

    public static ArrayList<String> doIt(Connection connection) {
        PreparedStatement getCountries = null;
        ResultSet resultSet;
        ArrayList<String> countryList = new ArrayList();
        try {
            getCountries = connection.prepareStatement(
                    "SELECT Name FROM countries ORDER BY Name");
            resultSet = getCountries.executeQuery();
            while (resultSet.next()) {
                countryList.add(resultSet.getString("Name"));
            }
        } catch (SQLException e) {
            System.out.println(e.getStackTrace());
        } catch (Exception e) {
            System.out.println(e.getStackTrace());
        } finally {
            try {
                if (getCountries != null) {
                    getCountries.close();
                }
            } catch (Exception e) {
                System.out.println(e.getStackTrace());
            }
        }
        return countryList;
    }
}

From: Chuck Caldarale <n82...@gmail.com>
Sent: Saturday, August 16, 2025 1:19 PM
To: Tomcat Users List <users@tomcat.apache.org>
Subject: Re: [EXTERNAL EMAIL] How to access a REST service

> On 2025 Aug 16, at 11:35, Daniel Schwartz 
> <d...@danielgschwartz.com<mailto:d...@danielgschwartz.com>> wrote: > > 
> Working through the numerous replies ... > > -----Original Message----- > 
> From: Robert Turner 
> <rtur...@e-djuster.ca.INVALID<mailto:rtur...@e-djuster.ca.INVALID>> >
NkdkJdXPPEBannerStart
Be Careful With This Message
From (Chuck Caldarale 
<n82...@gmail.com>)<https://godaddy1.cloud-protect.net/email-details/?k=k1&payload=53616c7465645f5fe5ddd8f8c456acd411856bce1fc00557b387a35fa011951ea72d245198a3728359fd4fc73151f370c0e368485739d043ecff55adc20084a406e8736a9260f9225738f0f1f3d2c640f3ecd476dfd262b631b02690981516c72c4a01f6166ac77c60906d82ff874d2d71234b391a17b9a7f46424cd0c7720b1f424ce80970822d3bd32df830858add24fa43915db82ab3e29e672fc0844d872bdfd1876ee3fd0f001507244df4a514e7c7c5cebe0c9d032eec81bb497d42b6b74e5425dc5961c3720163bde31b0e906c632c8299ab1728177e513afd691b25a5caac9627902dfde61d8ac9b403ba2ae>
Learn 
More<https://godaddy1.cloud-protect.net/email-details/?k=k1&payload=53616c7465645f5fe5ddd8f8c456acd411856bce1fc00557b387a35fa011951ea72d245198a3728359fd4fc73151f370c0e368485739d043ecff55adc20084a406e8736a9260f9225738f0f1f3d2c640f3ecd476dfd262b631b02690981516c72c4a01f6166ac77c60906d82ff874d2d71234b391a17b9a7f46424cd0c7720b1f424ce80970822d3bd32df830858add24fa43915db82ab3e29e672fc0844d872bdfd1876ee3fd0f001507244df4a514e7c7c5cebe0c9d032eec81bb497d42b6b74e5425dc5961c3720163bde31b0e906c632c8299ab1728177e513afd691b25a5caac9627902dfde61d8ac9b403ba2ae>
Potential Impersonation
The sender's identity could not be verified and someone may be impersonating 
the sender. Take caution when interacting with this message.

NkdkJdXPPEBannerEnd



> On 2025 Aug 16, at 11:35, Daniel Schwartz 
> <d...@danielgschwartz.com<mailto:d...@danielgschwartz.com>> wrote:

>

> Working through the numerous replies  ...

>

> -----Original Message-----

> From: Robert Turner 
> <rtur...@e-djuster.ca.INVALID<mailto:rtur...@e-djuster.ca.INVALID>>

> Sent: Saturday, August 16, 2025 1:03 AM

> To: Tomcat Users List 
> <users@tomcat.apache.org<mailto:users@tomcat.apache.org>>

> Subject: Re: [EXTERNAL EMAIL] How to access a REST service

>

> Dan,

>

> What's your thread pool size?

>

> DGS: I don't know how to determine this.





GlassFish does seem to be somewhat limited in its reporting of the 
configuration details. The 4.1 doc is even worse than the current 7.0 - wordy, 
but sparse details. They may be a GlassFish management page that reports DB and 
thread pool settings, but I haven’t found it yet.





> Could you provide a sample of the code that uses the connection?

>

> DGS: Here is the current version of the code fragment that retrieves the list 
> of countries.





I think what Robert is looking for is the code in GetCountryList, not the code 
that acquires the connection object.





>  The method call "GetCountryList.doIt(connection);" does create a prepared 
> statement, but this is always closed immediately after use.  In any case, the 
> DB connection is always closed in the code below, as far as I can tell.  I've 
> never seen an exception thrown in the running code, so I don't see any 
> possibility for a memory leak.





What about the other actual usage of the connection object? I believe you have 
stated that there are 4 such instances.



  - Chuck





---------------------------------------------------------------------

To unsubscribe, e-mail: 
users-unsubscr...@tomcat.apache.org<mailto:users-unsubscr...@tomcat.apache.org>

For additional commands, e-mail: 
users-h...@tomcat.apache.org<mailto:users-h...@tomcat.apache.org>


Reply via email to