public function createConnection(string $dsn, string $driverClass = 'com.mysql.jdbc.Driver'): Interfaces\JavaObject
    {
        if (!is_string($dsn) || trim($dsn) == '') {
            $message = 'DSN param must be a valid (on-empty) string';
            throw new Exception\InvalidArgumentException(__METHOD__.' '.$message);
        }

        $class = $this->ba->javaClass('java.lang.Class');
        try {
            $class->forName($driverClass);
        } catch (Exception\JavaException $e) {
            throw $e;
        }

        try {
            $conn = $this->getDriverManager()->getConnection($dsn);
        } catch (Exception\JavaExceptionInterface $e) {
            throw $e;
        }

        return $conn;
    }
public function createConnection(string $dsn, string $driverClass = 'com.mysql.jdbc.Driver'): Interfaces\JavaObject
    {
        if (!is_string($dsn) || trim($dsn) == '') {
            $message = 'DSN param must be a valid (on-empty) string';
            throw new Exception\InvalidArgumentException(__METHOD__.' '.$message);
        }

        $class = $this->ba->javaClass('java.lang.Class');
        try {
            $class->forName($driverClass);
        } catch (Exception\JavaException $e) {
            throw $e;
        }

        try {
            $conn = $this->getDriverManager()->getConnection($dsn);
        } catch (Exception\JavaExceptionInterface $e) {
            throw $e;
        }

        return $conn;
    }
public function createConnection ( string $ dsn , string $ driverClass = 'com.mysql.jdbc.Driver' ) : Interfaces \ JavaObject { if ( ! is_string ( $ dsn ) || trim ( $ dsn ) == '' ) { $ message = 'DSN param must be a valid (on-empty) string' ; throw new Exception \ InvalidArgumentException ( __METHOD__ . ' ' . $ message ) ; } $ class = $ this -> ba -> javaClass ( 'java.lang.Class' ) ; try { $ class -> forName ( $ driverClass ) ; } catch ( Exception \ JavaException $ e ) { throw $ e ; } try { $ conn = $ this -> getDriverManager ( ) -> getConnection ( $ dsn ) ; } catch ( Exception \ JavaExceptionInterface $ e ) { throw $ e ; } return $ conn ; }
Create an sql connection to database.


@throws Exception\JavaException
@throws Exception\ClassNotFoundException
@throws Exception\InvalidArgumentException
@throws Exception\BrokenConnectionException

@param string $dsn
@param string $driverClass

@return Interfaces\JavaObject Java('java.sql.Connection')
Create an sql connection to database .