LIKE的谓词出错

时间:2015-12-01 21:41:18

标签: java prepared-statement pervasive-sql

Sub AddRows(Cnt As Integer, DestName As String)

    Dim DestSheet As Worksheet
    Dim i As Integer


    Set DestSheet = Worksheets(DestName)

    For i = 1 To Cnt

        Sheets(DestName).cell(i + 2, 1).AutoFill _
              Destination:=Range(LastRow)
    Next i
End Sub ' AddRows

此代码产生错误:

int sixteen = 16;
String full="%"+sixteen+"%";
conn = PervasiveUtil.loadDriver();
stmt = conn.prepareStatement("SELECT BKAR_INV_SONUM "
                           + " FROM BKARINV "
                           + " WHERE BKAR_INV_SONUM > 150000 "
                           + " AND BKAR_INV_SONUM LIKE ?"
                           + " ORDER BY BKAR_INV_SONUM DESC");
stmt.setString(1, full);
rs = stmt.executeQuery();

BKAR_INV_SONUM类型在数据库中是int。这会影响我的准备声明吗?我应该使用java.sql.SQLException: [LNA][Pervasive][ODBC Engine Interface]Error in predicate: BKAR_INV_SONUM LIKE ? 代替setInt()吗?

0 个答案:

没有答案