0

I am having some trouble in retrieving multiple rows from an SqlAnywhere database using jtds 1.3.1. I am using the following query SELECT menge_pe, text, plain_text, text_is_rtf FROM hs.vk_beleg_pos WHERE belegnr IN (602397), which returns the intended results when executed in an interactive SQL window using "SQL Central". To be clear the characters are correctly escaped in android studio, it's written like so above for clarity. However, when executed by my android application, only returns one row and produces and error as below:

I/System.out: 1000.0000 menge_pe, null text, {\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\lang1031\fs18 Epilox H'e4rter EC 5310\par } plain_text, 4096 text_is_rtf E/Error here 1 :: TDS Protocol error: Invalid packet type 0xd6

I am processing the results with the following code for the time being, for test purposes.

  public void purchaseDbLookup(String orderID, List<String> results) {
    SqlAnywhereConnClass cc = new SqlAnywhereConnClass("un", "pass", "db", "ip");
    Connection cn = cc.getConnection();
    Statement st = null;
    ResultSet rs;
    ResultSetMetaData rsmt;
    results.clear();

    try {
      st = (Statement) cn.createStatement();
      rs = st.executeQuery("SELECT menge_pe, text, plain_text, text_is_rtf FROM \"hs\".\"vk_beleg_pos\" WHERE belegnr IN (" + orderID + ")");

      ResultSetMetaData rsmd = rs.getMetaData();
      System.out.println("querying SELECT * FROM XXX");
      int columnsNumber = rsmd.getColumnCount();
      while (rs.next()) {
        for (int i = 1; i <= columnsNumber; i++) {
          if (i > 1) System.out.print(",  ");
          String columnValue = rs.getString(i);
          System.out.print(columnValue + " " + rsmd.getColumnName(i));
        }
        System.out.println("");
      }

SQL Central interactive window results

I've been stuck with this for a little while so I hope someone can help out :)

Thank you in advance, Matt

1 Answers1

-1

This looks like a connection/driver issue. Verify that you are using the correct driver - this thread should be helpfull:

how to connect sql server using JTDS driver in Android