code: private static Connection connect(final String url, final String user, final String password) throws NamingException, SQLException {
  		if (url.toLowerCase(Locale.ROOT).startsWith("java:")) {
  			DataSource source = (DataSource) new InitialContext().lookup(url);
  			if (user == null) {
  				return source.getConnection();
  			} else {
  				return source.getConnection(user, password);
  			}
  		} else {
  			if (user == null) {
  				return DriverManager.getConnection(url);
  			} else {
  				return DriverManager.getConnection(url, user, password);
  			}
  		}
  	}
docs: Establishes the connection to the database.
  
  @param url
  JDBC or data source URL
  @param user
  User name for login (can be {@code null} if no login is required)
  @param password
  Password for login (can be {@code null} if no login is required)
  @return Connection to the database
  
  @throws NamingException
  Requested data source cannot be found
  @throws SQLException
  Failed to connect to database