Android Question Remote Database Connector (RDC) stops to work

marcick

Well-Known Member
Licensed User
Longtime User
Hi all,
my app with RDC was working fine for several weeks, but suddenly I get the below error from server side. The RDC command is a simple "select" query and I have discovered that the error appears when the number of records of the result is more than a quota. I don't know this number but maybe around 2500 records.
Any idea ?

B4X:
        at java.lang.Thread.run(Thread.java:745)
2015-08-29 12:56:09.564:WARN::/
java.lang.IllegalStateException: STREAM
        at org.eclipse.jetty.server.Response.getWriter(Response.java:635)
        at anywheresoftware.b4a.remotedatabase.Servlet.doGet(Servlet.java:95)
        at anywheresoftware.b4a.remotedatabase.Servlet.doPost(Servlet.java:52)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538
)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:478)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:937)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
406)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:871)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:117)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:110)
        at org.eclipse.jetty.server.Server.handle(Server.java:346)
        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.
java:589)
        at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpCo
nnection.java:1065)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823)
        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)

        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:41
1)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEn
dPoint.java:535)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEnd
Point.java:40)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:529)
        at java.lang.Thread.run(Thread.java:745)
 

LucaMs

Expert
Licensed User
Longtime User
The exception ...

Caused by: java.lang.IllegalStateException: STREAM
at org.eclipse.jetty.server.Response.getWriter(Response.java:944)
...
... means that your code attempted to access HttpServletResponse.getWriter() after having already accessed HttpServletResponse.getOutputStream()

At the point in time when the .getWriter() call occurred, the state of the response was already in STREAM mode, hence the IllegalStateException


Thats not allowed per the servlet spec.


(source: http://stackoverflow.com/questions/...ream-when-writing-excel-file-as-response-with)
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Erel: that is the full error on the rdc console, server side.
Lucams: if I change the parameters of the query so that to reduce the number of records of the result, it works (I can verify how many records are with a test on phpmyadmin). And I don't try a query if the previous one is still running.
Actually there are 4 users that make query to rdc every about 10 seconds. Maybe there are problems in rdc managing parallel query?
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Found where is the problem, let me put together the description
 
Last edited:
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
The command, server side is :

sql.cmd1 = SELECT * FROM `records` WHERE `Idx` > ?

where Idx is the primary key of the database

The actual result is about 10k records, but the size is not the real problem. I have discovered that one record of the result contain a field that should be a datetime but it is '0000-00-00 00:00:00'

And I obtain this error in the RDC console (the first row says everything)

B4X:
Command: query: RDC_CmdSync, took 0ms, client=5.90.142.55
java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as jav
a.sql.Timestamp
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)
        at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:921)
        at com.mysql.jdbc.ByteArrayRow.getTimestampFast(ByteArrayRow.java:130)
        at com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:
5944)
        at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:5612)
        at com.mysql.jdbc.ResultSetImpl.getObject(ResultSetImpl.java:4587)
        at com.mchange.v2.c3p0.impl.NewProxyResultSet.getObject(NewProxyResultSe
t.java:2140)
        at anywheresoftware.b4a.remotedatabase.Servlet.executeQuery(Servlet.java
:160)
        at anywheresoftware.b4a.remotedatabase.Servlet.doGet(Servlet.java:78)
        at anywheresoftware.b4a.remotedatabase.Servlet.doPost(Servlet.java:52)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538
)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:478)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:937)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
406)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:871)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:117)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:110)
        at org.eclipse.jetty.server.Server.handle(Server.java:346)
        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.
java:589)
        at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpCo
nnection.java:1065)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823)
        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)

        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:41
1)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEn
dPoint.java:535)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEnd
Point.java:40)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:529)
        at java.lang.Thread.run(Thread.java:745)
2015-08-31 08:30:10.534:WARN::/
java.lang.IllegalStateException: STREAM
        at org.eclipse.jetty.server.Response.getWriter(Response.java:635)
        at anywheresoftware.b4a.remotedatabase.Servlet.doGet(Servlet.java:95)
        at anywheresoftware.b4a.remotedatabase.Servlet.doPost(Servlet.java:52)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538
)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:478)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:937)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
406)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:871)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:117)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:110)
        at org.eclipse.jetty.server.Server.handle(Server.java:346)
        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.
java:589)
        at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpCo
nnection.java:1065)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823)
        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)

        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:41
1)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEn
dPoint.java:535)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEnd
Point.java:40)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:529)
        at java.lang.Thread.run(Thread.java:745)

I will investigate why a record with a wronf datetime has been inserted in the database, but how avoid that RDC crashes in these cases ?
I'm not asking the query to do a filter based on datetime, just want to get the records as they are.
Any suggestion ?
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Sorry I didn't use the correct word. No, it doesn't crash, everything continues to work.
So you mean we can do nothing?
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
The same query in PhpMyAdmin doesn't generate any error and all the records are showed, included that one with the DateTime field '0000-00-00 00:00:00'
The problem appears only throught RDC, my app stops to work and can do anything. The app can't continue synchronization with the server because everytime the error is generated. I would like the app is able to manage and skip this error ....
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I have tried to modify the query in RDC like this

sql.cmd1 = SELECT * FROM `records` WHERE (`Idx` > ? AND 'Gtm' NOT LIKE "0000-00-00 00:00:00")

Funny workaround but ... it works !

Great Erel, thank you very much
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
(`Idx` > ? AND 'Gtm' NOT LIKE "0000-00-00 00:00:00"
have you tried to use
B4X:
(`Idx` > ? AND 'Gtm' <> "0000-00-00 00:00:00"
<> is much faster than a NOT LIKE
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
I'm really a beginner in MySql and just grabbed some samples here and there.
Moved to <> , works fine, thanks
 
Upvote 0
Top