DBCP 설정 방법 원문은 다음을 참고 하자.
http://commons.apache.org/dbcp/configuration.html
예시>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc url"
p:username="user"
p:password="password"
p:initialSize="5"
p:maxActive="200"
p:minIdle="100"
p:testOnBorrow="true"
p:testWhileIdle="true"
p:testOnReturn="true"
p:validationQuery="select 1" />
p:testWhileIdle="true" 는 장시간 DB 작업이 없을 경우에도 지속적으로 validationQuery를 전송하여 연결이끊기는 것을 방지한다.
p:testOnBorrow="true" 는 커넥션 풀에서 커넥션을 가져올때 커넥션이 유효한지 검사한다.
p:testOnReturn="true" 는 커넥션 풀에 커넥션을 반환할때 커넥션이 유효한지 검사한다.
자꾸만 DB 관련 에러가 나길래 보았더니 아무래도 데이터 소스 관련 설정 문제 인거 같아 위와같이 수정하니, 아직까지 에러가 나진 않는다. 에러가 다음과 같다면 한번쯤 생각해 보시길.
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: PreparedStatementCallback; SQL [select * from table where field=?]; Communications link failure due to underlying exception:
java.net.SocketException: Broken pipe at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2637) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1554) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665) at com.mysql.jdbc.Connection.execSQL(Connection.java:3176) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1153) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1266) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:643) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:586) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:636) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:665) at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:673) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:716) at com.embian.dao.UserDao.getUser(UserDao.java:23) at com.embian.controller.AuthController.doAuth(AuthController.java:28) at sun.reflect.GeneratedMethodAccessor60.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:717) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:165) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:378) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:366) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread.java:619)
'개발&팁 > JAVA & Spring Framework' 카테고리의 다른 글
Spring에서 기본적인 DataSource 설정. (3) | 2009.11.27 |
---|
댓글을 달아 주세요
Le parquet de Créteil a ouvert fin décembre une information judiciaire à la suite de la plainte pour discrimination déposée par sept policiers ou anciens fonctionnaires de la Police aux frontières (PAF) de l'aéroport d'Orly, http://www.timberlandbaratas.com Timberland Online, a appris mardi l'AFP de source judiciaire, http://www.timberlandbaratas.com timberland niños.Related articles:
http://frogsoccer.tistory.com/63 Public Relations is a very varied industry
http://jedobe.tistory.com/category/DeSign?page=3 L'homme qui a commis mercredi un attentat devant l'ambassade de France à Bamako
For cheap flights to Perth from UK, http://www.moncleroutletespain.com/ moncler outlet, travelers are advised to avoid months of November to February, as it is the peak season. Perth is a small city but offers a plenty of things to do, see and explore, http://www.moncleroutletespain.com/ moncler chaquetas. It offers a bouncing nightlife, http://www.moncleroutletespain.com/ moncler online, sun drenched and sandy beaches, beautiful architecture and parks, http://www.moncleroutletespain.com/ http://www.moncleroutletespain.com/. Pleasant climate and beautiful surroundings have made the city as one of the most favorable holiday destinations of the world.People choose book flights to Perth for many reasons. For those art lovers, http://www.moncleroutletespain.com/ moncler españa, the West Australian Art Gallery is home to the state's premier art collection. The Perth Concert Hall hosts many theatre, opera, ballet and orchestral performances and Burswood Dome hosts music concerts from the modern era, http://www.moncleroutletespain.com/ moncler.As the capital of Western Australia, Perth has become an ideal holiday destination for all ages. In fact, it is considered as the fourth most visited place in Australia. This makes it even easier for people to find good deals on discounted and affordable airfares.Related articles:
http://scjbible.tistory.com/1112 http://scjbible.tistory.com/1112
http://kissues.tistory.com/5 http://kissues.tistory.com/5
"Incroyable... Dans le coffre de la voiture, ils m'ont "rendu" presque tous les objets perso !" se réjouit Michael Youn, http://www.moncleroutletespain.com/ moncler chaquetas, sur son compte Twitter, http://www.moncleroutletespain.com/ http://www.moncleroutletespain.com/, mercredi, http://www.moncleroutletespain.com/ moncler españa. L'acteur fran?ais, http://www.moncleroutletespain.com/ moncler, cambriolé dans la nuit de vendredi à samedi (voir l'article ci-dessous), a en effet récupéré, mercredi, "les 5 ordi, http://www.moncleroutletespain.com/ moncler outlet, avec les disques durs, les appareils photo avec les cartes mémoires, et 2 objets d'une grande sentimentale", commente-t-il sur Twitter, en remerciant "la 2ème DPJ pour son efficacité et son accueil". Et Michael Youn de s'amuser : "Si ?a intéresse un ringard : je vends un Hummer qui a beaucoup servi, http://www.moncleroutletespain.com/ moncler online, y compris à des cambrioleurs. Prix : ce que tu m'en donnes." People Le père de Jackson réfute la thèse du suicide People Tournée Johnny Hallyday : 15 mai 2012Related articles:
http://realog.net/974 http://realog.net/974
http://realog.net/981 http://realog.net/981