본문 바로가기

JAVA/오류

오류 - JDBC 프로그래밍 연결 안된 오류

반응형

웹프로그래밍을 하면서 오류 내용 중에 classpath 혹은 ojdbc 이라는 용어가 나온다면 JDBC 연결이 안되서 생기는 경우를 생각해봅시다.


밑에 사진같은 경우에는 spring / mybatis / tomcat / oracle 환경에서 오류가 난 것입니다.





해결방법 


1. DBMS에 따른 jdbc 드라이버를 jdk에 복사 해둔다.

탐색기 - C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib

- 주소에서 두개의 파일 중 ojdbc14 복사하기


2. jdk 설치된 곳으로 감

두군데에 붙여 놓기 해야함

C:\Program Files\Java\jdk1.8.0_73\jre\lib\ext

- 주소에 붙여놓기

C:\Program Files\Java\jre1.8.0_73\lib\ext

- 주소에 붙여놓기







오류내용 - 두가지




HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceException: 


--------------------------------------------------------------------------------


type Exception report


message Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceException: 


description The server encountered an internal error that prevented it from fulfilling this request.


exception 


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: oracle.jdbc.driver.OracleDriver

### The error may exist in com/dt/data/MapperMember.xml

### The error may involve member.selectAll

### The error occurred while executing a query

### Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: oracle.jdbc.driver.OracleDriver

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)

org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)

javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)



root cause 


org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: oracle.jdbc.driver.OracleDriver

### The error may exist in com/dt/data/MapperMember.xml

### The error may involve member.selectAll

### The error occurred while executing a query

### Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: oracle.jdbc.driver.OracleDriver

org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:91)

com.dt.dao.MemberDao.list(MemberDao.java:39)

com.dt.controller.MemberController.list(MemberController.java:27)

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

java.lang.reflect.Method.invoke(Unknown Source)

org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)

org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)

org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)

org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)

org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)

org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)

org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)

javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)



root cause 


java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: oracle.jdbc.driver.OracleDriver

org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:196)

org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:180)

org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:176)

org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:80)

org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:371)

org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:80)

org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:131)

org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:58)

org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279)

org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:69)

org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)

org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)

org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141)

org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)

org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:91)

com.dt.dao.MemberDao.list(MemberDao.java:39)

com.dt.controller.MemberController.list(MemberController.java:27)

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

java.lang.reflect.Method.invoke(Unknown Source)

org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)

org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)

org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)

org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)

org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)

org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)

org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)

javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)



note The full stack trace of the root cause is available in the Apache Tomcat/7.0.70 logs.



--------------------------------------------------------------------------------


Apache Tomcat/7.0.70



HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceException: 


--------------------------------------------------------------------------------


type Exception report


message Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceException: 


description The server encountered an internal error that prevented it from fulfilling this request.


exception 


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

### The error may exist in com/dt/data/MapperMember.xml

### The error may involve member.selectAll

### The error occurred while executing a query

### Cause: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)

org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)

javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)



root cause 


org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

### The error may exist in com/dt/data/MapperMember.xml

### The error may involve member.selectAll

### The error occurred while executing a query

### Cause: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:91)

com.dt.dao.MemberDao.list(MemberDao.java:39)

com.dt.controller.MemberController.list(MemberController.java:27)

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

java.lang.reflect.Method.invoke(Unknown Source)

org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)

org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)

org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)

org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)

org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)

org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)

org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)

javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)



root cause 


java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

java.sql.DriverManager.getConnection(Unknown Source)

java.sql.DriverManager.getConnection(Unknown Source)

org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:181)

org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:176)

org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:80)

org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:371)

org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:80)

org.apache.ibatis.transaction.jdbc.JdbcTransaction.openConnection(JdbcTransaction.java:131)

org.apache.ibatis.transaction.jdbc.JdbcTransaction.getConnection(JdbcTransaction.java:58)

org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279)

org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:69)

org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)

org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)

org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141)

org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)

org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95)

org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:91)

com.dt.dao.MemberDao.list(MemberDao.java:39)

com.dt.controller.MemberController.list(MemberController.java:27)

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

java.lang.reflect.Method.invoke(Unknown Source)

org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)

org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)

org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)

org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)

org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)

org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)

org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)

org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)

org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)

javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)



note The full stack trace of the root cause is available in the Apache Tomcat/7.0.70 logs.



반응형