LoginSignup
1
0

More than 5 years have passed since last update.

Spring Boot で Azure MySQL(Clear DB)のFreeプランに接続する際

Posted at

AzureのClear DB提供のMySQLでは接続数に制限があり、
Freeプランでは「4」と少ない。

で、何も考えずにSpring Bootで以下のようにapplication.ymlを設定して接続してみると・・・

application.yml
spring:
  datasource:
    url: jdbc:mysql://{AzureDBホスト名}:3306/{DB名}
    username: {username}
    password: {password}
    driverClassName: com.mysql.jdbc.Driver

以下のようなエラーが出て怒られる。

User '{username}' has exceeded the 'max_user_connections' resource (current value: 4)

いやいや、4も接続しとらんやん。
・・・と思ったんだけど、TOMCATさんがどうやら4以上poolしていることが判明。

なので、application.ymlを以下のように変更したところ正常に動いたよ。

application.yml
spring:
  datasource:
    url: jdbc:mysql://{AzureDBホスト名}:3306/{DB名}
    username: {username}
    password: {password}
    driverClassName: com.mysql.jdbc.Driver
    tomcat:
      maxActive: 4
      maxIdle: 4
      minIdle: 1
      initialSize: 1

最大接続数?と思われる設定を4にして
最小接続数?と思われる設定を1にしました。

※解釈が間違っている可能性がありますのでご了承ください。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0