SQLite prepareStatement:问号无法识别

时间:2018-08-02 09:42:19

标签: java sqlite jdbc

尝试基于查询生成prepareStatement时出现错误。

以下是查询:

import { ... } from 'angular-calendar-scheduler';

这是PreparedStatement:

private static final String SQL_SUPPRIMER_TOUS_SAUF_PLUS_RECENT = 
" delete from vue4 where nomdomaine=\'?\' and dateeditionvue4 in" +
" ( ( select dateeditionvue4 from VUE4 where nomdomaine = \"\" and >dateeditionVue4 < (?) and dateeditionVue4 > (?) ) " +
" < ( select max(dateEditionVue4) from VUE4 where nomdomaine = >\"\" and dateeditionVue4 < (?) and dateeditionVue4 > (?) ) ) ";

我收到此异常:

        // Préparation de la requête SQL
        preparedStatement = connection.prepareStatement(SQL_SUPPRIMER_TOUS_SAUF_PLUS_RECENT);
        connection.setAutoCommit(false);

        for (String domaine : listeCodeDomaine){
            for (MoisBudgetaire mois : listeDeMois ){

                preparedStatement.setObject(1, domaine );
                preparedStatement.setObject(2, domaine );
                preparedStatement.setObject(3, mois.getDateFin());
                preparedStatement.setObject(4, mois.getDateDebut() );
                preparedStatement.setObject(5, domaine );
                preparedStatement.setObject(6, mois.getDateFin());
                preparedStatement.setObject(7, mois.getDateDebut() );

                // Ajout de la requête au batch
                preparedStatement.addBatch();

            }           }

似乎引号之间的问号无法识别。

1 个答案:

答案 0 :(得分:0)

'在字符串文字的"引号内时,无需转义。

即使该列是文本类型,您也无法编写'?'