Package org.apache.tuscany.das.rdb.exception

Examples of org.apache.tuscany.das.rdb.exception.DataSourceInitializationException


    private void initializeDriverManagerConnection(ConnectionInfo connectionInfo) {

        Connection connection = null;

        if (connectionInfo.getConnectionProperties() == null) {
            throw new DataSourceInitializationException("No existing context and no connection properties");
        }

        if (connectionInfo.getConnectionProperties().getDriverClass() == null) {
            throw new DataSourceInitializationException("No jdbc driver class specified!");
        }

        try {
            //initialize driver and register it with DriverManager
            Class.forName(connectionInfo.getConnectionProperties().getDriverClass());

            //prepare to initialize connection
            String databaseUrl = connectionInfo.getConnectionProperties().getDatabaseURL();
            String userName = connectionInfo.getConnectionProperties().getUserName();
            String userPassword = connectionInfo.getConnectionProperties().getPassword();
            int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout();

            DriverManager.setLoginTimeout(loginTimeout);
            if( (userName == null || userName.length() ==0) && (userPassword == null || userPassword.length()==0) ){
                //no username or password suplied
                connection = DriverManager.getConnection(databaseUrl);
            }else{
                connection = DriverManager.getConnection(databaseUrl, userName, userPassword);
            }

            if(connection == null){
                throw new DataSourceInitializationException("Error initializing connection : null");
            }

            connection.setAutoCommit(false);
            setConnection(connection);


        }catch(ClassNotFoundException cnf){
            throw new DataSourceInitializationException("JDBC Driver '" + connectionInfo.getConnectionProperties().getDriverClass() + "' not found", cnf);
        }catch(SQLException sqle){
            throw new DataSourceInitializationException(sqle.getMessage(), sqle);
        }

    }
View Full Code Here


    private void initializeDriverManagerConnection(ConnectionInfo connectionInfo) {

        Connection connection = null;
       
        if (connectionInfo.getConnectionProperties() == null) {
            throw new DataSourceInitializationException("No existing context and no connection properties");
        }

        if (connectionInfo.getConnectionProperties().getDriverClass() == null) {
            throw new DataSourceInitializationException("No jdbc driver class specified!");
        }

        try {
            //initialize driver and register it with DriverManager
            Class.forName(connectionInfo.getConnectionProperties().getDriverClass());
           
            //prepare to initialize connection
            String databaseUrl = connectionInfo.getConnectionProperties().getDatabaseURL();
            String userName = connectionInfo.getConnectionProperties().getUserName();
            String userPassword = connectionInfo.getConnectionProperties().getPassword();
            int loginTimeout = connectionInfo.getConnectionProperties().getLoginTimeout();
           
            DriverManager.setLoginTimeout(loginTimeout);
            if( (userName == null || userName.length() ==0) && (userPassword == null || userPassword.length()==0) ){
                //no username or password suplied
                connection = DriverManager.getConnection(databaseUrl);
            }else{
                connection = DriverManager.getConnection(databaseUrl, userName, userPassword);
            }
           
            if(connection == null){
                throw new DataSourceInitializationException("Error initializing connection : null");
            }
           
            connection.setAutoCommit(false);
            setConnection(connection);
               
           
        }catch(ClassNotFoundException cnf){
            throw new DataSourceInitializationException("JDBC Driver '" + connectionInfo.getConnectionProperties().getDriverClass() + "' not found", cnf);
        }catch(SQLException sqle){
            throw new DataSourceInitializationException(sqle.getMessage(), sqle);
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.exception.DataSourceInitializationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.