Problem insert into Mariadb database images

Asked

Viewed 89 times

-1

I am using Mariadb and a LONGBLOB field to store my images, when I have insert small images (300KB or less) normally inserts, however larger images that this gives this error here:

Mariadb [-1] Could not send query: Software caused Connection abort: socket write error

mar 25, 2019 2:50:23 PM 
org.apache.tomcat.dbcp.dbcp2.SwallowedExceptionLogger onSwallowException
ADVERTÊNCIA: An internal object pool swallowed an Exception.
java.sql.SQLNonTransientConnectionException: Could not send query: Last packet not finished
at org.mariadb.jdbc.internal.SQLExceptionMapper.get(SQLExceptionMapper.java:136)
at org.mariadb.jdbc.internal.SQLExceptionMapper.throwException(SQLExceptionMapper.java:106)
at org.mariadb.jdbc.MySQLStatement.executeQueryEpilog(MySQLStatement.java:264)
at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:288)
at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:338)
at org.mariadb.jdbc.MySQLConnection.rollback(MySQLConnection.java:244)
at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.rollback(DelegatingConnection.java:496)
at org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.passivateObject(PoolableConnectionFactory.java:373)
at org.apache.tomcat.dbcp.pool2.impl.GenericObjectPool.returnObject(GenericObjectPool.java:563)
at org.apache.tomcat.dbcp.dbcp2.PoolableConnection.close(PoolableConnection.java:205)
at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.closeInternal(DelegatingConnection.java:240)
at org.apache.tomcat.dbcp.dbcp2.DelegatingConnection.close(DelegatingConnection.java:222)
at org.apache.tomcat.dbcp.dbcp2.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:244)
at sge.persistencia.crud.CrudPersistence$ManagerPoolConnection.liberateResources(CrudPersistence.java:112)
at sge.persistencia.crud.CrudPersistence.liberateConnection(CrudPersistence.java:953)
at sge.processo.agenda.ProcessoRecado.enviarMensagem(ProcessoRecado.java:204)
at sge.apresentacao.agenda.RecadoFrm.enviarMensagem(RecadoFrm.groovy:274)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java:247)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at sge.seguranca.filtros.FiltroSeguranca.doFilter(FiltroSeguranca.java:40)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at sge.seguranca.filtros.CredencialFilter.doFilter(CredencialFilter.java:32)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:501)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:754)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1376)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
 Caused by: org.mariadb.jdbc.internal.common.QueryException: Could not send query: Last packet not finished
at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:984)
at org.mariadb.jdbc.MySQLStatement.execute(MySQLStatement.java:281)
... 57 more
Caused by: java.io.IOException: Last packet not finished
at org.mariadb.jdbc.internal.common.packet.PacketOutputStream.startPacket(PacketOutputStream.java:38)
at org.mariadb.jdbc.internal.common.packet.commands.StreamedQueryPacket.send(StreamedQueryPacket.java:76)
at org.mariadb.jdbc.internal.mysql.MySQLProtocol.executeQuery(MySQLProtocol.java:982)
... 58 more

1 answer

1


Mariadb, depending on installation and version, does not accept queries greater than 300 kB. Either you have to send the file binarially in incremental loops of at most 300 kB, or, in the database configuration file, edit the following line like this:

max_allowed_packet=25M

Also, if your application is web, your web server also needs to accept attachments of this size. At php.ini, for example, it would be necessary to change this setting like this (originally it is 8 MB):

post_max_size=25M

But of course, it depends on what software you’re employing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.