You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot项目集成SQL Workbench连接失败,需补充application.properties配置?

Fixing Spring Boot & SQL Workbench Integration Issues

Hey there, let's figure out why your Spring Boot app isn't connecting properly to your 'abc' schema in SQL Workbench. First off, accessing localhost:3306\abc directly through your browser isn't the right way to interact with your database— that URL is for database clients like SQL Workbench, not for browser access. That 'pg not found' error is probably a red herring, but let's get your application config sorted first to ensure your app connects correctly.

Here are the essential configurations you need to add/update in your application.properties file, depending on which database you're using (the 'pg' in your error hints at PostgreSQL, so I'll cover both common options):

If you're using MySQL (since you mentioned port 3306):

# ===============================
# = DATA SOURCE
# ===============================
# Connection URL pointing directly to your 'abc' schema
spring.datasource.url=jdbc:mysql://localhost:3306/abc?useSSL=false&serverTimezone=UTC
# Replace with your SQL Workbench login username
spring.datasource.username=your_db_username
# Replace with your SQL Workbench login password
spring.datasource.password=your_db_password
# MySQL JDBC driver class
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# Optional but recommended Hibernate settings for ORM
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

If you're using PostgreSQL (since the error mentions 'pg'):

Note: PostgreSQL uses port 5432 by default, so adjust the port in your URL if that's your setup:

# ===============================
# = DATA SOURCE
# ===============================
# Connection URL pointing directly to your 'abc' schema
spring.datasource.url=jdbc:postgresql://localhost:5432/abc?useSSL=false&serverTimezone=UTC
# Replace with your SQL Workbench login username
spring.datasource.username=your_db_username
# Replace with your SQL Workbench login password
spring.datasource.password=your_db_password
# PostgreSQL JDBC driver class
spring.datasource.driver-class-name=org.postgresql.Driver

# Optional but recommended Hibernate settings for ORM
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

Quick Tips to Ensure Success:

  • Double-check that your JDBC driver dependency is present in your pom.xml (Maven) or build.gradle (Gradle). For MySQL, it's mysql-connector-java; for PostgreSQL, it's postgresql.
  • The spring.jpa.hibernate.ddl-auto=update setting will modify your existing database tables to match your Spring Boot entity classes—perfect for development.
  • After updating the config, restart your Spring Boot app. Check the logs for messages like "HikariPool-1 - Start completed" to confirm the connection to the 'abc' schema worked.

As for that 'pg not found' error: browsers can't connect directly to database ports like 3306. To interact with your data, create REST endpoints in your Spring Boot app that query the database, then access those endpoints (e.g., localhost:8080/api/your-resource).

内容的提问来源于stack exchange,提问作者sherry

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:28:43