Number of tries is the number of attempts to connect to the database
during this login attempt (if we need to open the database)
This needs rewritten wuth better pooling support, the existing code
needs signature changes since the Prepared statements needs cached
with the connections.
The code below will try twice if there is a SQLException so the
connection may try to be opened again. On normal conditions (including
invalid login - the above is only used once.