Code example for DataSource

Methods: getConnection

        //Initial connection pool 
        InitialContext initialContext = new InitialContext();
        Context context = (Context) initialContext.lookup("java:comp/env");
        //The JDBC Data source that we just created 
        DataSource ds = (DataSource) context.lookup("hoteldb");
        Connection connection = ds.getConnection();
        if (connection == null) {
            throw new SQLException("Error establishing connection!");
        return connection;
Stop searching for code, let great code find you!  Add Codota to your java IDE