Code example for Connection

Methods: getMetaData

    public DatabaseType getDatabaseName(Connection connection) throws UnsupportedDatabaseException {
        String connectionUrl = null;
        try { 
            DatabaseMetaData metaData = connection.getMetaData();
            connectionUrl = metaData.getURL();
        } catch (SQLException e) {
            log.error("Failed to get connection url from DatabaseMetaData", e);
        DatabaseType type  =null;
           type =  getDatabaseType(connectionUrl.split(":")[1]);
        catch (UnsupportedDatabaseException ignored){
            //includin the check to sql server with jTDS Eg: jdbc:jtds:sqlserver://<host>:<port> 
            String[] urlElements = connectionUrl.split(":");
            if (urlElements.length > 2){
               type = getDatabaseType(urlElements[2]);
Stop searching for code, let great code find you!  Add Codota to your java IDE