0

I'm trying to connect to an Azure SQL database in Android using JDBC. After following the relevant tutorials, I've been met with an Assertion Error: numMsgsRcvd:1 should be less than numMsgsSent:1. Below is the code snippet and error trace. I'm not sure where to go from here, and how to add to the number of messages sent or reduce the number received, or whether this is just hiding a different issue.

public class Campus extends AsyncTask<Connection, Integer, Long> {

    public Connection connection;
    private String connectionString;

    public Campus(String conn) {
        connectionString = conn;
    }

    @Override
    protected Long doInBackground(Connection... connections) {
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            connection = DriverManager.getConnection(connectionString);
        } catch (SQLException | ClassNotFoundException throwables) {
            throwables.printStackTrace();
        }
        return Long.valueOf(100);
    }
}

java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$4.done(AsyncTask.java:415)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: java.lang.AssertionError: numMsgsRcvd:1 should be less than numMsgsSent:1
        at com.microsoft.sqlserver.jdbc.TDSReader.readPacket(IOBuffer.java:6601)
        at com.microsoft.sqlserver.jdbc.TDSReader.nextPacket(IOBuffer.java:6567)
        ...
        at uol.co4224.campusfood.Campus.doInBackground(Campus.java:22)
        at uol.co4224.campusfood.Campus.doInBackground(Campus.java:9)

0 Answers0