@vlad12156
Студент

Не могу получить доступ к MSQL?

hibernate.connection.driver_class = com.ibm.db2.jcc.DB2Driver
hibernate.connection.url = jdbc:db2://127.0.0.1:3306/test1250
hibernate.connection.username = testuser
hibernate.connection.password = Test12345678
hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
driverClassName: com.mysql.cj.jdbc.Driver


Ошибок при вводе пароля и юзера нету

2022-02-01 13:57:15.094  INFO 13588 --- [  restartedMain] c.e.FrebieSir.FrebieSirApplication       : Starting FrebieSirApplication using Java 1.8.0_321 on DESKTOP-B2BUC1H with PID 13588 (D:\FrebieSir\target\classes started by vladb in D:\FrebieSir)
2022-02-01 13:57:15.095  INFO 13588 --- [  restartedMain] c.e.FrebieSir.FrebieSirApplication       : No active profile set, falling back to default profiles: default
2022-02-01 13:57:15.155  INFO 13588 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-02-01 13:57:15.155  INFO 13588 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-02-01 13:57:15.756  INFO 13588 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-02-01 13:57:15.798  INFO 13588 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 34 ms. Found 1 JPA repository interfaces.
2022-02-01 13:57:16.513  INFO 13588 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-02-01 13:57:16.522  INFO 13588 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-02-01 13:57:16.523  INFO 13588 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
2022-02-01 13:57:16.596  INFO 13588 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-02-01 13:57:16.596  INFO 13588 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1440 ms
2022-02-01 13:57:16.680  WARN 13588 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2022-02-01 13:57:16.683  INFO 13588 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-02-01 13:57:16.699  INFO 13588 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-01 13:57:16.715 ERROR 13588 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
	If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
	If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).


Process finished with exit code 0
  • Вопрос задан
  • 806 просмотров
Пригласить эксперта
Ответы на вопрос 2
azerphoenix
@azerphoenix Куратор тега Spring
Java Software Engineer
Вы хотите подключиться к MySQL или к MsSQL?

Тут в вашем конфиге ну все в одну кучу намешано.
Во-первых, необходимо прописать строки, которые указал Михаил
Во-вторых, драйвер не от MySQL и даже не от MsSQL. А от db2.
В-третьих, url тоже прописан для db2
hibernate.connection.driver_class = com.ibm.db2.jcc.DB2Driver
hibernate.connection.url = jdbc:db2://127.0.0.1:3306/test1250
hibernate.connection.username = testuser
hibernate.connection.password = Test12345678
hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
driverClassName: com.mysql.cj.jdbc.Driver


Предположительно должно быть:
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test1250
spring.datasource.username=testuser
spring.datasource.password=Test12345678
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

Возможно, что название БД, логин и пароль отличаются.
Ответ написан
@Akela_wolf
Extreme Programmer
spring.datasource.url=<jdbc string>
spring.datasource.username=<username>
spring.datasource.password=<password>

За остальными опциями см. документацию спринга.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы