db.properties

 

데이터베이스 접속정보를 db.properties파일에 정리를 해놓고 properties파일을 가져다가 datasource를 만들었다.

 

 

@PropertySource("/WEB-INF/properties/db.properties")

db.properties를 PropertySource로 등록해주고 @Value를 이용해서 정의해준 변수들을 가져와서 dataSource를 만들어준다.

 

 

접속, 쿼리 관리를 하는 SqlSessionFactory객체와 쿼리문 실행을 위한 MapperFactoryBean객체도 정의해주었다.

 

 

 

 

MapperInterface에 데이터를 집어넣을 수 있는 Insert문을 넣었다.

 

MapperInterface를 자동주입받은 후 선언한 insert메소드를 출력해보았는데...

 

 

 

 

심각: 경로 [/MVCStudy_JAVA]의 컨텍스트 내의 서블릿 [dispatcher]을(를) 위한 Servlet.service() 호출이, 근본 원인(root cause)과 함께, 예외 [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Cannot create PoolableConnectionFactory 'root'@'localhost' (using password: YES))
### The error may exist in com/study/spring/mapper/MapperInterface.java (best guess)
### The error may involve com.study.spring.mapper.MapperInterface.insert
### The error occurred while executing an update

 

 

 

JDBC Connection에러가 발생하였다.

dataSource에 이상이 있는것 같아서 다시 지웠다가 써도 안된다...

MapperInterface.java에 오류가 존재한다고 해서 쿼리문도 다시 적었다.. 그런데도 에러가 난다.

 

 

가정 1. 빈의 프로퍼티명 불일치

가정 2. mapper클래스 스펠링 문제

가정 3. dbcp 버전 문제

 

이 3가지정도가 떠올라서 한개한개 다시 해보기로 했다.

 

 

 

결국.. 찾아낸 문제..

 

properties파일을 가져올때 스펠링이 오류가 있었나보다.

변수명을 복붙으로 다시 선언해주고 url주소도 다시 쳐서 dataSource에 넣어주니까 오류가 안난다...

 

+ Recent posts