Search code examples
androiddatabasejaybird

Error using Jaybird and Android


I created an application on android with Firebird direct wifi connect. Sometimes I get this error:

FATAL EXCEPTION: AsyncTask #4 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:200) at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274) at java.util.concurrent.FutureTask.setException(FutureTask.java:125) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) at java.lang.Thread.run(Thread.java:1019) Caused by: java.lang.NullPointerException at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscDatabaseInfo(AbstractJavaGDSImpl.java:518) at org.firebirdsql.jdbc.AbstractConnection.isValid(AbstractConnection.java:594) at br.com.controlemesa.banco.DBFBConnect.disconnect(DBFBConnect.java:61) at br.com.controlemesa.banco.DBFBConnect.spListaMesas(DBFBConnect.java:170) at br.com.controlemesa.activities.MesasActivity$PopulaGridMesas.doInBackground(MesasActivity.java:193) at br.com.controlemesa.activities.MesasActivity$PopulaGridMesas.doInBackground(MesasActivity.java:1) at android.os.AsyncTask$2.call(AsyncTask.java:185) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306) ... 4 more

Has anyone else received this message? How can I prevent this?


Solution

  • Looking at the code, this NullPointerException can occur if the connection was already closed. I have created issue JDBC-313 in the Jaybird tracker. I will fix it in the 'normal' Jaybird for version 2.2.4. Usually the maintainer of the Android Jaybird project will release a new version shortly after that.

    Not knowing your exact code, I am not sure what a workaround is. As your stacktraces lists DBFBConnect.disconnect, I assume you want to disconnect. In that case I suggest you don't check for validity of the connection, but simply call close() on the connection.