Remark : 디비 연결이 되지 않는 형상
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
package com.jcg.spring.mvc.file.download; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import java.util.Properties; import org.apache.log4j.Logger; public class GenerateCsvData { static ResultSet res; static Statement stmt; static Connection conn; private static Logger logger = Logger.getLogger(GenerateCsvData.class); /**** This Method Is Used To Create A Database Connection Object ****/ public static Connection getDatabaseConnection() { try { Class.forName(IConstants.DB_DRIVER); conn = DriverManager.getConnection(IConstants.DB_URL, IConstants.DB_USERNAME,IConstants.DB_PASSWORD); //Properties info = new Properties(); //info.setProperty("user", IConstants.DB_USERNAME); //info.setProperty("password", IConstants.DB_PASSWORD); //info.setProperty("useSSL", "false"); //info.setProperty("autoReconnect", "true"); //conn = DriverManager.getConnection(IConstants.DB_URL, info); } catch(Exception exObj) { logger.error("Exception While Creating The Db Connection Object?= " + exObj); } return conn; } |
원인 : mysql-connector-java 버전 이 옛날 버전이라서 발생.
[현재 사용하는 버전] MySQL 버전 : 8.0.28
mysql-connector-java 버전 : 6.0.23 => 8.0.28 jar 업데이트
업데이트 방법 : pox.xml 수정