๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸŒฑ ๊ฐœ๋ฐœ ๋…ธํŠธ

[์˜ค๋ฅ˜ ํ•ด๊ฒฐ] Cannot create JDBC driver of class 'net.sf.log4jdbc.sql.jdbcapi.DriverSpy' ... java.sql.SQLException: No suitable driver

by OR15A 2024. 8. 9.
Cannot create JDBC driver of class 'net.sf.log4jdbc.sql.jdbcapi.DriverSpy' 
for connect URL 'jdbc:log4jdbc:sqlserver://[DB_IP]:[DB_PORT];database=[DATABASE_NAME]'
java.sql.SQLException: No suitable driver

 

STS๋กœ ๊ฐœ๋ฐœ์ค‘์ด๋˜ ํ”„๋กœ์ ํŠธ๋ฅผ ์ธํ…”๋ฆฌ์ œ์ด๋กœ ์˜ฎ๊ฒจ์„œ ๋นŒ๋“œํ•˜๋Š” ๊ณผ์ •์—์„œ  'java.sql.SQLException: No suitable driver' ์˜ค๋ฅ˜๊ฐ€ ํ„ฐ์กŒ๋‹ค. 

ํ•ด๊ฒฐ๊ณผ์ •
  1.  ํ•ด๋‹น ์˜ค๋ฅ˜ ๋ฉ”์„ธ์ง€๋ฅผ ๊ตฌ๊ธ€๋งํ•˜๋ฉฐ ๋‹ค์–‘ํ•œ ์›์ธ ํ™•์ธํ•จ
    1. driver-class-name ๋น ์กŒ๋Š”๊ฐ€?  → ์•„๋‹˜
    2. pom.xml ์˜์กด์„ฑ์— mssql-jdbc, log4jdbc-log4j2-jdbc4 ๊ฐ€ ๋น ์กŒ๋Š”๊ฐ€? → ์•„๋‹˜
    3. pom.xml์—๋Š” ๋ช…์‹œ๋˜์–ด์žˆ์ง€๋งŒ ๋ฉ”์ด๋ธ์ด jarํŒŒ์ผ์„ ๋ฐ›์•„์˜ค์ง€ ๋ชปํ•˜๋Š”๊ฐ€? → ์•„๋‹˜
    4. tomcat VM ์˜ต์…˜์— ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋ช…์‹œํ•ด์คฌ๋Š”๊ฐ€? → ์•ˆํ–ˆ์Œ → Jav VM Arguments ์ถ”๊ฐ€ํ–ˆ์ง€๋งŒ ํšจ๊ณผ ์—†์Œ
    5. log4jdbc.log4j2.properties ํŒŒ์ผ์— log4jdbc.drivers=org.mariadb.jdbc.Driver ์ถ”๊ฐ€ํ•˜๊ธฐ → ํšจ๊ณผ ์—†์Œ
  2. ์•„๋ฌด๋ฆฌ ๋ด๋„ ํ†ฐ์บฃ์ด JDBC ๋“œ๋ผ์ด๋ฒ„๋ฅผ ๋ชป ์ฝ๋Š” ๊ฒƒ. ํ†ฐ์บฃ libํด๋”์— JDBC๋ฅผ ๋„ฃ๊ณ  ํ•ด๊ฒฐํ–ˆ๋‹ค๋Š” ์‚ฌ๋žŒ๋“ค์˜ ๊ธ€์„ ์„ ํƒํ•จ
    1. Microsoft SQL Server JDBC Driver ๋‹ค์šด๋กœ๋“œ (https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15)
    2. ์••์ถ• ํ•ด์ œ ํ›„ ํ†ฐ์บฃ libํด๋”์— ์–ด๋–ค jarํŒŒ์ผ์„ ๋„ฃ์–ด์•ผ ํ•˜๋Š”์ง€ GPT์—๊ฒŒ ๋ฌป๋Š” ๊ณผ์ •์—์„œ ์‹ค๋งˆ๋ฆฌ๋ฅผ ๋ฐœ๊ฒฌํ•จ

 

 
GPT์™€์˜ ๋Œ€ํ™”

  • maven-compiler-plugin์ด 1.8์ด์—ˆ๊ธฐ ๋•Œ๋ฌธ์— java 1.8๋กœ ์ง์ž‘ํ•˜๊ณ  ์žˆ์—ˆ๊ณ , eclips์šฉ ์…‹ํŒ…ํŒŒ์ผ์„ ๋ณด๋‹ˆ 1.8์ด ๋งž์•˜์Œ
 
JDBC ๋“œ๋ผ์ด๋ฒ„์˜ ์ž๋ฐ” ๋ฒ„์ „ ์ˆ˜์ • ๊ฒฐ๊ณผ
  • No suitable driver ๋ฐœ์ƒํ•˜์ง€ ์•Š๊ณ  ์ •์ƒ ๋นŒ๋“œ๋˜์—ˆ๋‹ค
 

 

๊ถ๊ธˆ์ฆ

 
 
๊ทธ๋ ‡๋‹ค๊ณ  ํ•œ๋‹ค!