I configure the project for work with PostgreSQL. Project on Spring 5, Hibernate 5.
Base settings connected, Connect Successfull.
The database configuration file is as follows:
@Configuration @EnableTransactionManagement @EnableJpaRepositories("ru.example.repository") @PropertySource("classpath:/properties/postgresql.properties") public class TransactionManagerConfig { @Autowired Environment env; @Autowired private ApplicationContext applicationContext; @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws PropertyVetoException { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource()); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter); entityManagerFactoryBean.setPackagesToScan("ru.example.entity"); return entityManagerFactoryBean; } public DataSource dataSource() throws PropertyVetoException { ComboPooledDataSource dataSource = new ComboPooledDataSource(); dataSource.setDriverClass("org.postgresql.Driver"); dataSource.setJdbcUrl("jdbc:postgresql://localhost:3306/database"); dataSource.setUser("user"); dataSource.setPassword("password"); return dataSource; } @Bean public JpaTransactionManager transactionManager() throws PropertyVetoException { JpaTransactionManager transactionManager = new JpaTransactionManager(); transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); return transactionManager; } } Struktreys:
дек 08, 2017 1:55:46 PM org.postgresql.Driver connect SEVERE: Connection error: org.postgresql.util.PSQLException: Ошибка протокола. Установление сессии не удалось. at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:622) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:222) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194) at org.postgresql.Driver.makeConnection(Driver.java:450) at org.postgresql.Driver.connect(Driver.java:252) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125) at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44) at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) So far I have driven in the settings in the Datasource bin, this is understandable temporarily.