0

我正在使用 SQLite,我需要从许多表中进行选择,并且我正在使用 java 我的问题是当我进行此选择时,结果我什么都没有,它返回一个空的 arrayList 。

 public void etapeParametrerOption(String login) throws IOException, SQLException
{
    assertTrue( "Texte 'Paramétrer les options' non présent, voir code source HTML dans LogOut",selenium.isTextPresent( "Paramétrer les options" ) );

   String [] tab=LogFile.showWSEtAppelCOffrEFrom(login);
  List<String>ls=new ArrayList<String>();

   for(String itab : tab){

       ls=dbCOffrE.executeSelect("SELECT busitypid,attblabel FROM t_article art, t_attribute att , t_srvbrick_attr_article srv WHERE att.attbid = srv.attbid and art.artid = srv.artid and att.modoptidmodifiable = '2' and (att.attbinactivationdate is null or att.attbinactivationdate < date('now')) and art.artshortlabel='"+itab+"'");

      logger.info("ma liste :"+ls);
   }


 public List<String> executeSelect( String ArgRequete, boolean All) throws SQLException

{

String ReturnColumn = ArgRequete.substring( ArgRequete.indexOf( "SELECT" )+ 6, ArgRequete.indexOf( "FROM" ) ).replaceAll(" ","");
List<String> Str = new ArrayList<String>();
logger.info("ret :"+ReturnColumn);
String[] columns=ReturnColumn.split(",");
for(String ico:columns){
 logger.info(ico);

} stmt = con.createStatement();

rs = stmt.executeQuery( ArgRequete );
logger.info(ArgRequete);

logger.info("mon resultSet:"+rs);
if ( !All )
{
    if ( rs.next() )
    {
        String result = "";
               for(String aColumn : columns){
                            result += rs.getString(aColumn ) + ",";
                            logger.info(result);

                }
                Str.add( result );
     }
}
while ( rs.next() && All )
{
                           String result = "";
                           for(String aColumn : columns){
                                       result += rs.getString( aColumn ) + ",";
                           }
    Str.add( result );
}
stmt.close();
return Str;

}

所以当我使用一个简单的请求时,比如“从 NameTable 中选择 S1,S2,其中 Id='345'”它工作得很好,但是这样的请求:SELECT busitypid,attblabel FROM t_article art,t_attribute att,t_srvbrick_attr_article srv WHERE att.attbid = srv .attbid and art.artid = srv.artid and att.modoptidmodifiable = '2' and (att.attbinactivationdate is null or att.attbinactivationdate < date('now')) and art.artshortlabel='"+itab+"'")它实际上崩溃了。

在我的日志文件中,我得到了结果: INFO com.sfr.price.functionalTest.commons.SQLBase.executeSelect [] ret:busitypid,attblabel INFO com.sfr.price.functionalTest.commons.SQLBase.executeSelect [] busitypid INFO com .sfr.price.functionalTest.commons.SQLBase.executeSelect [] attblabel INFO com.sfr.price.functionalTest.commons.SQLBase.executeSelect [] SELECT busitypid,attblabel FROM t_article art, t_attribute att, t_srvbrick_attr_article srv WHERE att.attbid = srv .attbid and art.artid = srv.artid and att.modoptidmodifiable = '2' and art.artshortlabel='8001P' INFO com.sfr.price.functionalTest.commons.SQLBase.executeSelect [] mon resultSet:org.sqlite.RS @ 24c672 信息 com.sfr.price.functionalTest.scenario.impl.AJLINGE.etapeParametrerOption [] ma liste :[]

4

1 回答 1

0

看起来附加的代码与您在您问题中附加的日志文件不对应。在日志文件中,我们可以看到执行了以下查询:

SELECT busitypid,attblabel FROM t_article art, t_attribute att , t_srvbrick_attr_article srv WHERE att.attbid = srv.attbid and art.artid = srv.artid and att.modoptidmodifiable = '2' and art.artshortlabel='8001P' 

在代码片段中您有以下查询

SELECT busitypid,attblabel FROM t_article art, t_attribute att , t_srvbrick_attr_article srv WHERE att.attbid = srv.attbid and art.artid = srv.artid and att.modoptidmodifiable = '2' and (att.attbinactivationdate is null or att.attbinactivationdate < date('now')) and art.artshortlabel='"+itab+"'"

请注意 WHERE 子句中对 att.attbinactivationdate 的附加检查。也许您实际执行的查询没有返回任何应有的值。

于 2012-06-26T14:18:30.120 回答