running a web project in java gives an error

Question:

When starting a web project in java gives an error

ERROR: HHH000299: Could not complete schema update java.lang.UnsupportedOperationException: The application must supply JDBC connections

As I understand it, it is not possible to connect to the database. How to fix it – I don’t know.

spring-hibernate.xml

<!-- Настройки бина dataSource будем хранить в отдельном файле, определяем где именно -->
<bean id="placeholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
      p:location="classpath:jdbc.properties" />

<!-- Настройки подключения к БД, бин dataSource -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close"
      p:driverClassName="${jdbc.driverClassName}"
      p:url="${jdbc.url}"
      p:username="${jdbc.username}"
      p:password="${jdbc.password}"/>

<!-- Настройки фабрики сессий Хибернейта -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop><!-- SQL диалект -->
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop><!-- Вывод в консоль SQL-запросов -->
            <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop><!-- Автообновление структуры БД -->
        </props>
    </property>
</bean>

jdbc.properties

jdbc.driverClassName=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/SpringShop?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
jdbc.username=root
jdbc.password=root


hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update

I can't figure out why. Thanks in advance for your answers 🙂

Answer:

You did not specify a data source for the session factory

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
        ...
    </property>
</bean>
Scroll to Top
AllEscort