src/main/java/com/helospark/telnetsnake/game/repository/configuration/HsqlAutoServerManager.java
/**
     * Starts a connection either by starting a new server and connect to it, or
     * find the running server for the given file and connect to it. TODO proper
     * exception handling
     *
     * @return JDBC connection, make sure to close it
     */
Starts a connection either by starting a new server and connect to it, or
find the running server for the given file and connect to it. TODO proper
exception handling

@return JDBC connection, make sure to close it
Starts a connection either by starting a new server and connect to it or find the running server for the given file and connect to it . TODO proper exception handling @return JDBC connection make sure to close it
public synchronized Connection createConnection() {
        try {
            String portToConnect;
            File databasePortFile = new File(databaseFileName + AUTOSTART_SERVER_FILE_LOCK_POSTFIX);
            if (!databasePortFile.exists()) {
                portToConnect = startNewServerAndGetPort(databasePortFile);
            } else {
                LOGGER.info(databasePortFile.getAbsolutePath() + " exists, initializing from there");
                portToConnect = readServerPortFromFile(databasePortFile);
            }
            try {
                return createJdbcHsqlConnectionToPort(portToConnect);
            } catch (Exception e) {
                LOGGER.warn("Unable to connect on " + portToConnect + ", creating new connection", e);
                databasePortFile.delete();
                portToConnect = startNewServerAndGetPort(databasePortFile);
                return createJdbcHsqlConnectionToPort(portToConnect);
            }
        } catch (Exception e) {
            throw new RuntimeException("Unable to create DB connection, check lock file", e);
        }
    }
public synchronized Connection createConnection ( ) { try { String portToConnect ; File databasePortFile = new File ( databaseFileName + AUTOSTART_SERVER_FILE_LOCK_POSTFIX ) ; if ( ! databasePortFile . exists ( ) ) { portToConnect = startNewServerAndGetPort ( databasePortFile ) ; } else { LOGGER . info ( databasePortFile . getAbsolutePath ( ) + " exists, initializing from there" ) ; portToConnect = readServerPortFromFile ( databasePortFile ) ; } try { return createJdbcHsqlConnectionToPort ( portToConnect ) ; } catch ( Exception e ) { LOGGER . warn ( "Unable to connect on " + portToConnect + ", creating new connection" , e ) ; databasePortFile . delete ( ) ; portToConnect = startNewServerAndGetPort ( databasePortFile ) ; return createJdbcHsqlConnectionToPort ( portToConnect ) ; } } catch ( Exception e ) { throw new RuntimeException ( "Unable to create DB connection, check lock file" , e ) ; } }
Starts a connection either by starting a new server and connect to it, or
 find the running server for the given file and connect to it.
Starts a connection either by starting a new server and connect to it or find the running server for the given file and connect to it .