java - Resultset getString throw ArrayIndexOutOfBoundsException -


i got exception when trying retrieve string value resultset. happens after added 2 new columns image_url , icon_url table (default null) , trying retrieve new added columns. table create statement below:

create table `examples` ( `id` int(11) not null auto_increment, `name` varchar(255) collate utf8_unicode_ci default null, `description` text collate utf8_unicode_ci, `event_id` int(11) default null, `created_at` datetime not null, `updated_at` datetime not null, `session_id` varchar(255) collate utf8_unicode_ci default null, `location` varchar(255) collate utf8_unicode_ci default null, `start_date` datetime default null, `end_date` datetime default null, `url` varchar(255) collate utf8_unicode_ci default null, `button_label` varchar(255) collate utf8_unicode_ci default null, `hidden` tinyint(1) default null, `image_url` varchar(255) collate utf8_unicode_ci default null, `icon_url` varchar(255) collate utf8_unicode_ci default null, primary key (`id`) ) engine=innodb auto_increment=427 default charset=utf8  collate=utf8_unicode_ci; 

the query pretty simple, query fields examples object:

@override public list<example> getexamples(integer eventid) {     return jdbctemplate.query(             "select * examples event_id= ?",             new object[]{eventid},             (rs, rownum) -> {                  example ex = new example();                  ex.setid(rs.getint("id"));                  ex.setname(rs.getstring("name"));                  ex.setdescription(rs.getstring("description"));                  ex.setexpoid(rs.getint("expo_id"));                  ex.setsessionid(rs.getstring("session_id"));                  ex.setlocation(rs.getstring("location"));                  ex.setstartdate(rs.getstring("start_date"));                  ex.setenddate(rs.getstring("end_date"));                  ex.seturl(rs.getstring("url"));                  ex.setbuttonlabel(rs.getstring("button_label"));                  ex.sethidden(rs.getboolean("hidden"));                  ex.setimageurl(rs.getstring("image_url")); //throw arrayindexoutofboundsexception                  ex.seticonurl(rs.getstring("icon_url")); // throw arrayindexoutofboundsexception             }); } 

the exception go away if update image_url , icon_url empty string instead of null value.

i'm using hikaricp config , manage datasouce:

   @bean(name = "datasouce")    public datasource datasouce() {     hikariconfig config = new hikariconfig();     config.setjdbcurl(env.getproperty("ds.url"));     config.setusername(env.getproperty("ds.username"));     config.setpassword(env.getproperty("ds.password"));     config.setdriverclassname(env.getproperty("ds.driver.classname"));     config.adddatasourceproperty("cacheprepstmts", "true");     config.adddatasourceproperty("prepstmtcachesize", "250");     config.adddatasourceproperty("useserverprepstmts", "true");     config.adddatasourceproperty("uselocalsessionstate", "true");     config.adddatasourceproperty("uselocaltransactionstate", "true");     config.adddatasourceproperty("rewritebatchedstatements", "true");     config.adddatasourceproperty("cacheresultsetmetadata", "false");     config.adddatasourceproperty("cacheserverconfiguration", "true");     config.adddatasourceproperty("elidesetautocommits", "true");     config.adddatasourceproperty("maintaintimestats", "false");     return new hikaridatasource(config); } 

i've been debugging hours no luck of finding what's going on, pretty new hikaricp not sure if have effect caching query results. complete exception trace below:

2017-08-14 12:09:53.020 [http-apr-8080-exec-2] warn  example.mvclogger - handler execution resulted in exception java.lang.arrayindexoutofboundsexception: 939 @ com.mysql.cj.mysqla.io.buffer.readinteger(buffer.java:284) @ com.mysql.cj.mysqla.result.binarybufferrow.getvalue(binarybufferrow.java:231) @ com.mysql.cj.jdbc.result.resultsetimpl.getstring(resultsetimpl.java:880) @ com.mysql.cj.jdbc.result.resultsetimpl.getstring(resultsetimpl.java:892) @ com.zaxxer.hikari.pool.hikariproxyresultset.getstring(hikariproxyresultset.java) @ com.playstation.sony.otg.service.impl.eventsserviceimpl.lambda$getexamples$2(eventsserviceimpl.java:162) @ org.springframework.jdbc.core.rowmapperresultsetextractor.extractdata(rowmapperresultsetextractor.java:93) @ org.springframework.jdbc.core.rowmapperresultsetextractor.extractdata(rowmapperresultsetextractor.java:60) @ org.springframework.jdbc.core.jdbctemplate$1.doinpreparedstatement(jdbctemplate.java:708) @ org.springframework.jdbc.core.jdbctemplate.execute(jdbctemplate.java:644) @ org.springframework.jdbc.core.jdbctemplate.query(jdbctemplate.java:695) @ org.springframework.jdbc.core.jdbctemplate.query(jdbctemplate.java:727) @ org.springframework.jdbc.core.jdbctemplate.query(jdbctemplate.java:737) @ org.springframework.jdbc.core.jdbctemplate.query(jdbctemplate.java:787) @ com.playstation.sony.otg.service.impl.eventsserviceimpl.getexamples(eventsserviceimpl.java:158) @ com.playstation.sony.otg.controller.admincontroller.eventidexamplesget(admincontroller.java:48) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:498) @ org.springframework.web.method.support.invocablehandlermethod.doinvoke(invocablehandlermethod.java:221) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:137) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:110) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlermethod(requestmappinghandleradapter.java:775) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:705) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:85) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:959) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:893) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:967) @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:858) @ javax.servlet.http.httpservlet.service(httpservlet.java:624) @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:843) @ javax.servlet.http.httpservlet.service(httpservlet.java:731) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ com.playstation.sony.otg.logging.logging.loggerfilter.dofilter(loggerfilter.java:46) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ com.playstation.sony.otg.config.simplecorsfilter.dofilter(simplecorsfilter.java:22) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:505) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:169) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:956) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:436) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1078) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:625) @ org.apache.tomcat.util.net.aprendpoint$socketprocessor.dorun(aprendpoint.java:2517) @ org.apache.tomcat.util.net.aprendpoint$socketprocessor.run(aprendpoint.java:2506) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(thread.java:745) 

it might dumb mistake i've made since i've leave industry years , back, appreciated!

there's bug on mysql connector / j 6.0.5 same exception closed

exception in thread "main" java.lang.arrayindexoutofboundsexception: 10     @ com.mysql.cj.mysqla.io.buffer.readinteger(buffer.java:284)     @ com.mysql.cj.mysqla.result.binarybufferrow.getvalue(binarybufferrow.java:227) 

the comment:

an arrayindexoutofboundsexception thrown when server-side prepared statement used , there null in blob, text, or json type column in resultset

this fixed in connector / j 8.0.7

an arrayindexoutofboundsexception thrown when server-side prepared statement used , there null in blob, text, or json type column in resultset. (bug #25215008, bug #84084)


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -