Search in sources :

Example 1 with DBConnectionException

use of com.twosigma.beakerx.sql.DBConnectionException in project beakerx by twosigma.

the class DbExplorerFactory method getDbInfo.

// private static final String VENDOR_JDBC_ORACLE = "jdbc:oracle:";
// private static final String VENDOR_JDBC_MSSQL = "jdbc:sqlserver:";
public static DbInfo getDbInfo(String txt, JDBCClient jdbcClient, String sessionId, ConnectionStringHolder defaultConnectionString, Map<String, ConnectionStringHolder> namedConnectionString) {
    final NamespaceClient namespaceClient = NamespaceClient.getBeaker(sessionId);
    final BeakerParser beakerParser;
    try {
        beakerParser = new BeakerParser(txt, namespaceClient, defaultConnectionString, namedConnectionString, jdbcClient);
        final String uri = beakerParser.getDbURI().getActualConnectionString();
        if (uri != null) {
            final DataSource ds = jdbcClient.getDataSource(uri);
            if (uri.startsWith(VENDOR_JDBC_MYSQL)) {
                return new MysqlDbExplorer(ds);
            }
        }
    } catch (IOException | DBConnectionException e) {
        logger.error(e.getMessage());
    }
    return null;
}
Also used : NamespaceClient(com.twosigma.beakerx.NamespaceClient) DBConnectionException(com.twosigma.beakerx.sql.DBConnectionException) BeakerParser(com.twosigma.beakerx.sql.BeakerParser) IOException(java.io.IOException) DataSource(javax.sql.DataSource)

Aggregations

NamespaceClient (com.twosigma.beakerx.NamespaceClient)1 BeakerParser (com.twosigma.beakerx.sql.BeakerParser)1 DBConnectionException (com.twosigma.beakerx.sql.DBConnectionException)1 IOException (java.io.IOException)1 DataSource (javax.sql.DataSource)1