Spring Boot 連接資料庫錯誤 timezone region not found 解決辦法

今天在測試機上執行 Spring Boot 的時候出現錯誤
環境是建立在 Docker 上的 Ubuntu ,連接 Oracle DB
錯誤訊息:
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found

解決方式:
設定 Ubuntu 和 JVM 的時區:

Ubuntu:
sudo dpkg-reconfigure tzdata
但是筆者在執行時遇到錯誤:
root@76eaa73b754a:/usr/share# dpkg-reconfigure tzdata
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at
/usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
dpkg-query: package 'tzdata' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
/usr/sbin/dpkg-reconfigure: tzdata is not installed
他說沒有安裝 tzdata
所以改成執行
sudo dpkg-reconfigure tzdata
依照內容設定即可,先選擇時區,再選擇城市或地區
最後會顯示:
Current default time zone: 'Asia/Taipei'

修改 JVM 時區:
export TZ="Asia/Taipei"

再次執行就可以正常連接資料庫了(歡呼

留言