# Validate a datasource connection is working (SQL Server/jdbc)

**URL:** <https://forum.inductiveautomation.com/t/validate-a-datasource-connection-is-working-sql-server-jdbc/114045>\
**Category:** Module Development\
**Created:** [February 18, 2026, 9:49pm UTC](https://forum.inductiveautomation.com/t/validate-a-datasource-connection-is-working-sql-server-jdbc/114045 "2026-02-18T21:49:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jarvis\_Coghlin](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@Jarvis\_Coghlin](https://forum.inductiveautomation.com/u/Jarvis_Coghlin)\
**Post date:** [February 18, 2026, 9:49pm UTC](https://forum.inductiveautomation.com/t/validate-a-datasource-connection-is-working-sql-server-jdbc/114045/1 "2026-02-18T21:49:30Z")

</div>

I have been writing a custom ignition module that accesses an SQL Server data source and have been pulling my hair out trying to figure out why the following function I have running periodically isn’t working:

```python
    public boolean validateConnection() throws CustomException {
        try {
            // connection is an SRConnection
            boolean isValid = connection.isValid(3); 
            boolean isClosed = connection.isClosed();
            return isValid && !isClosed;
        } catch (SQLException e) {
            throw new CustomException("Error grabbing DB Connection status");
        }
    }

```

This method is in a custom wrapper for an SRConnection

As a bit of context, I just want to verify that my SQL Server connection is “Valid” i.e. I can make sql calls to it and expect the data to be returned back, but I can’t find any way to verify that

The issue is `.isValid()` and `.isClosed()` always respond with true and false respectively, even when I make the data source say “Faulted” in the Gateway

Any ideas on how to verify a db connection is up would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 18, 2026, 10:02pm UTC](https://forum.inductiveautomation.com/t/validate-a-datasource-connection-is-working-sql-server-jdbc/114045/2 "2026-02-18T22:02:54Z")

</div>

I don't think you're meant to be caching or holding onto instances of SRConnection.

You should always be getting the datasource and then getting a connection from it when you need to use one.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 18, 2026, 10:21pm UTC](https://forum.inductiveautomation.com/t/validate-a-datasource-connection-is-working-sql-server-jdbc/114045/3 "2026-02-18T22:21:40Z")

</div>

> [@Kevin.Herron](#):
>
> holding onto instances of SRConnection

Correct. That interferes with the JDBC connection pooling layer in Ignition.
