David Rogers
07/13/2022, 5:39 PMbdw429s
07/13/2022, 5:41 PMbdw429s
07/13/2022, 5:42 PMbdw429s
07/13/2022, 5:44 PMValidate
checkbox for the datasource
Validate the connection before use (only works with JDBC 4.0 Drivers)
which is the Lucee equivalent to Adobe CF's "validation query" feature, except you don't have to specify a query.David Rogers
07/13/2022, 5:44 PMqueryexecute("
kill every connection to some_test_db;
-- do other stuff
", {}, {datasource: "master/i.e. not some_test_db"})
which works every other request (coinciding with the above comment it seems)
(edited for marginally improved clarity)bdw429s
07/13/2022, 5:45 PMbdw429s
07/13/2022, 5:46 PMbdw429s
07/13/2022, 5:46 PMDavid Rogers
07/13/2022, 5:47 PMbdw429s
07/13/2022, 5:47 PMbdw429s
07/13/2022, 5:47 PMbdw429s
07/13/2022, 5:48 PMDavid Rogers
07/13/2022, 5:48 PMdswitzer
07/13/2022, 5:49 PMDavid Rogers
07/13/2022, 5:51 PMif you choose to validate before each requestas in, the box Brad posted is checked, yes?
bdw429s
07/13/2022, 5:51 PMhm, what happens if the connection is dead and it doesn't validate it as dead...I guess I will find out!Huh? What do you mean? Are you saying the JDBC driver may have a bug and not work correctly?
David Rogers
07/13/2022, 5:53 PMbdw429s
07/13/2022, 5:53 PMif you choose to validate before each request it does add some overhead.This is correct. I'm fairly sure the JDBC-level verification doesn't actual run any SQL, it just sends a round trip ping to the server to ensure it's still there.
you could just manually fire off a validation query in a try/catch,While this work "work", it seems worse in every possible way 😆 It's for sure going ot be more overhead. I'd let the JDBC drivers do their thing. The validation process is actually built into the JDBC spec and lucee is simply asking the JDBC driver to check the connection to make sure it's life still.
bdw429s
07/13/2022, 5:54 PMconnectionAt a low level, an instance of a "connection" class in Java represents an open TCP channel. In this case, from Lucee to the DB server.
dswitzer
07/13/2022, 5:55 PMbdw429s
07/13/2022, 5:56 PMbdw429s
07/13/2022, 5:56 PMbdw429s
07/13/2022, 5:59 PMjava.sql.Connection
class
https://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#isValid(int)David Rogers
07/13/2022, 5:59 PMbdw429s
07/13/2022, 6:01 PMi'm not validating before useTo be clear, it's not an action you need to take in your code. You just check the box in the admin and you're done. Lucee does it for you when checking a connection out of the pool before it it used to execute your query. If it isn't valid, lucee discards it and takes another from the pool. Rinse and repeat until a valid connection is found, or a new one is created.
sknowlton
07/13/2022, 6:36 PMbdw429s
07/13/2022, 6:37 PMbdw429s
07/13/2022, 6:38 PMbdw429s
07/13/2022, 6:38 PMthis.datasources["foo"] = {
...
, validate:true // default: false
};