If the connection fails, bail early. Otherwise the processing of the
queued SQL statements will cause an infinite loop by continually pushing
the same statement into the queue due to lack of connection.
Also add a local variable for the connection for clarity and
performance.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>