1

I want to fetch data from exasol but only facing this issue when I use limit clause in query.

If i hardcode the limit values in query and don't use prepared statement for then it works fine. But when I try to set int for limit clause in prepared statement it gives me exception

public static final String FROM_DWB_DATA = "SELECT *  FROM DWB_DATA a \n"
    + "INNER JOIN DWB_CONN b \n"
    + "ON a.SOURCE_ID=b.ID\n"
    + "WHERE b.PROJECT_ID=? ORDER BY a.TABLE_NAME LIMIT ? , ?";


    //and in Prepared statement i am setting these values
    PreparedStatement ps = getSQLConnection(projectId, conid)
        .prepareStatement(FROM_DWB_DATA_TABLE);

    ps.setString(1, projectId);
    ps.setInt(2, 0);
    ps.setInt(3, 2);

java.sql.SQLException: non-negative integer value expected in LIMIT clause

Faizan
  • 289
  • 4
  • 15

1 Answers1

0

I guess, it adds your values in quoted form: LIMIT '0', '2'.

Try to build query string normally and run it as simple non-prepared query.

wildraid
  • 126
  • 4