MyBatisとpostgresを使ってjavaのwebアプリケーションを作成しています。
下記のようにinsertのクエリを実行するとエラーが発生してしまいます。
■MyBatisのxmlファイル
xml
1 <insert id="insertRace"> 2 insert into t_race( race_id, obstacle_flg, race_name, grade, race_number, field_type, distance, rotate_type, weather, field_condition, host_id, post_time, host_date, host_times, host_days, horse_type, age_condition, product_condition, appointed_condition, sex_condition, weight_condition, insert_date, insert_user, update_date, update_user) 3 values ('${raceId}', ${obstacleFlg}, '${raceName}', '${grade}', ${raceNumber}, '${fieldType}', ${distance}, '${rotateType}', '${weather}', '${fieldCondition}', '${hostId}', ${postTime}, ${hostDate}, ${hostTimes}, ${hostDays}, ${horseType}, '${ageCondition}', ${productCondition}, ${appointedCondition}, ${sexCondition}, ${weightCondition}, CURRENT_TIMESTAMP, 'SYSTEM', CURRENT_TIMESTAMP, 'SYSTEM') 4 </insert>
■postgresで出力されるエラー
postgreSQL
1ERROR: syntax error at or near ":" at character 433 2STATEMENT: insert into t_race( race_id, obstacle_flg, race_name, grade, race_number, field_type, distance, rotate_type, weather, field_condition, host_id, post_time, host_date, host_times, host_days, horse_type, age_condition, product_condition, appointed_condition, sex_condition, weight_condition, insert_date, insert_user, update_date, update_user) 3 values ('201606020302', 0, '3歳未勝利', '未勝利', 2, 'ダート', 1200, '右', '曇', '良', '06', 10:40:00, 2016-03-05, 2, 3, 1, '3歳', 1, 2, 999, 4, CURRENT_TIMESTAMP, 'SYSTEM', CURRENT_TIMESTAMP, 'SYSTEM')
■javaのコンソール例外
java
1### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near ":" 2 ポジション: 433 3### The error may involve defaultParameterMap 4### The error occurred while setting parameters 5### SQL: insert into t_race( race_id, obstacle_flg, race_name, grade, race_number, field_type, distance, rotate_type, weather, field_condition, host_id, post_time, host_date, host_times, host_days, horse_type, age_condition, product_condition, appointed_condition, sex_condition, weight_condition, insert_date, insert_user, update_date, update_user) values ('201606020302', 0, '3歳未勝利', '未勝利', 2, 'ダート', 1200, '右', '曇', '良', '06', 10:40:00, 2016-03-05, 2, 3, 1, '3歳', 1, 2, 999, 4, CURRENT_TIMESTAMP, 'SYSTEM', CURRENT_TIMESTAMP, 'SYSTEM') 6### Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near ":" 7 ポジション: 433 8; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near ":" 9 ポジション: 433] with root cause 10org.postgresql.util.PSQLException: ERROR: syntax error at or near ":" 11 ポジション: 433 12 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102) 13 at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835) 14 at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) 15 at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) 16 at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) 17 at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381) 18 at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:45) 19 at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:73) 20 at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49) 21 at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:115) 22 at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75) 23 at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:170) 24 at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:157) 25 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 26 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 27 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 28 at java.lang.reflect.Method.invoke(Method.java:483) 29 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358) 30 at com.sun.proxy.$Proxy12.insert(Unknown Source) 31 at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240) 32 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:52) 33 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) 34 at com.sun.proxy.$Proxy24.insertRace(Unknown Source) 35 at jp.keiba.analitics.service.ScrapingDataService.insertRace(ScrapingDataService.java:169) 36 at jp.keiba.analitics.service.ScrapingDataService.insertAll(ScrapingDataService.java:45) 37 at jp.keiba.analitics.controller.scraping.UrlRaceScrpController.raceComplete(UrlRaceScrpController.java:90) 38 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 39 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 40 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 41 at java.lang.reflect.Method.invoke(Method.java:483) 42 at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) 43 at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 44 at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) 45 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817) 46 at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731) 47 at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) 48 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) 49 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) 50 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968) 51 at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859) 52 at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) 53 at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844) 54 at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) 55 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) 56 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 57 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 58 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 59 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 60 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) 61 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 62 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) 63 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) 64 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) 65 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) 66 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) 67 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) 68 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 69 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) 70 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 71 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423) 72 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079) 73 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) 74 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) 75 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 76 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 77 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 78 at java.lang.Thread.run(Thread.java:745)
クエリに":"は使用しておらず、なぜエラーメッセージに「ERROR: syntax error at or near ":" 」が出力されるのか、解決方法がわからず困っております。
お手数をおかけしますがお力添えをいただけると大変幸いです。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/03/13 16:06
2016/03/13 23:18