title: Unable to connect to Postgres DB due to the authentication type 10 is not supported
body: <p>I have recently tried my hands on Postgres. Installed it on local (PostgreSQL 13.0).
  Created a maven project and used Spring Data JPA, works just fine. Whereas when I tried using Gradle project, I am not able to connect to the DB and keep getting the following error.</p>
  <blockquote>
  <p>org.postgresql.util.PSQLException: The authentication type 10 is not
  supported. Check that you have configured the pg_hba.conf file to
  include the client's IP address or subnet, and that it is using an
  authentication scheme supported by the driver.    at
  org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:614)
  ~[postgresql-42.1.4.jar:42.1.4]   at
  org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:222)
  ~[postgresql-42.1.4.jar:42.1.4]   at
  org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
  ~[postgresql-42.1.4.jar:42.1.4]   at
  org.postgresql.jdbc.PgConnection.(PgConnection.java:194)
  ~[postgresql-42.1.4.jar:42.1.4]   at
  org.postgresql.Driver.makeConnection(Driver.java:450)
  ~[postgresql-42.1.4.jar:42.1.4]   at
  org.postgresql.Driver.connect(Driver.java:252)
  ~[postgresql-42.1.4.jar:42.1.4]   at
  java.sql.DriverManager.getConnection(Unknown Source) [na:1.8.0_261]
  at java.sql.DriverManager.getConnection(Unknown Source)
  [na:1.8.0_261]    at
  org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:94)
  [postgresql-42.1.4.jar:42.1.4]    at
  org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:79)
  [postgresql-42.1.4.jar:42.1.4]</p>
  </blockquote>
  <p>I tried using JDBCTemplate as well. Doesn't work</p>
  <p>Modified the pg_hba.cfg file referring to <a href="https://stackoverflow.com/questions/4562471/connecting-to-local-instance-of-postgresql-with-jdbc">this</a> post - Doesn't work</p>
  <p>Used the deprecated Lib of  - Doesn't Work either.</p>
  <p>Please Suggest me a solution for this problem.</p>
  <p>My code and Config:</p>
  <pre><code>    @Configuration
      public class DataSourceConfig {
      
          
          @Bean
          public DriverManagerDataSource getDataSource() {
              DriverManagerDataSource dataSourceBuilder = new DriverManagerDataSource();
              dataSourceBuilder.setDriverClassName(&quot;org.postgresql.Driver&quot;);
              dataSourceBuilder.setUrl(&quot;jdbc:postgresql://localhost:5432/postgres&quot;);
              dataSourceBuilder.setUsername(&quot;postgres&quot;);
              dataSourceBuilder.setPassword(&quot;root&quot;);
              return dataSourceBuilder;
          }
          
      }
  
  
  
  @Component
  public class CustomerOrderJDBCTemplate implements CustomerOrderDao{
      
      private DataSource dataSource;
      
      private JdbcTemplate jdbcTemplateObject;
  
      @Autowired
      ApplicationContext context;
      
      public void setDataSource() {
          //Getting Bean by Class
          DriverManagerDataSource dataSource = context.getBean(DriverManagerDataSource.class);
          this.dataSource = dataSource;
          this.jdbcTemplateObject = new JdbcTemplate(this.dataSource);
      }
  
  @Override
      public Customer create(Customer customer) {
          setDataSource();
          String sql = &quot;insert into CustomerOrder (customerType, customerPayment) values (?, ?)&quot;;
          //jdbcTemplateObject.update(sql, customerOrder.getCustomerOrderType(), customerOrder.getCustomerOrderPayment());
          
          KeyHolder holder = new GeneratedKeyHolder();
          jdbcTemplateObject.update(new PreparedStatementCreator() {
              @Override
              public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
                  PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
                  ps.setString(1, customer.getType());
                  ps.setString(2, customer.getPayment());
                  return ps;
              }
          }, holder);
  
          long customerId = holder.getKey().longValue();
          customer.setCustomerID(customerOrderId);
          return customer;
          
      }
  
  }
  </code></pre>
  <p>dependencies</p>
  <pre><code>implementation('org.springframework.boot:spring-boot-starter-web')
      compile(&quot;org.springframework.boot:spring-boot-devtools&quot;)
      compile(group: 'org.postgresql', name: 'postgresql', version: '42.1.4')
      compile(&quot;org.springdoc:springdoc-openapi-ui:1.4.1&quot;)
      compile(&quot;org.springframework:spring-jdbc:5.2.5.RELEASE&quot;)
  </code></pre>
  <p><code>password_encryption</code> is set like this:</p>
  <pre><code>postgres=# show password_encryption;
   password_encryption
  ---------------------
   scram-sha-256
  (1 row)
  </code></pre>