Comment faire une selection des données d'une database SQLite à partir du code j

Résolu
Asm87 Messages postés 2 Date d'inscription mercredi 27 juin 2012 Statut Membre Dernière intervention 27 juin 2012 - 27 juin 2012 à 14:20
Asm87 Messages postés 2 Date d'inscription mercredi 27 juin 2012 Statut Membre Dernière intervention 27 juin 2012 - 27 juin 2012 à 15:34
Bonjour,
je travaille sur un projet qui utilise SQLite comme Data base et j'ai besoin de faire une requête qui nécessite une sélection depuis plusieurs tables des jointures et la mon problème ma requête ne me retourne rien du coup pourtant j'ai bon cherché et et j'ai fait beaucoup de modifications au niveau du code Java mais en vain :


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

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

for(String ico:columns){
logger.info(ico);
}
stmt = con.createStatement();
rs = stmt.executeQuery( ArgRequete );
logger.info("mon resultSet:"+ rs);

if ( !All )
{
while (rs.next())
{

String member= new String();

for(String aColumn : columns){
member += rs.getString(aColumn ) + ",";
logger.info("c'est quoi :"+member);

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

stmt.close();
return Str;

}


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 INNER JOIN t_srvbrick_attr_article srv ON art.artid = srv.artid INNER JOIN t_attribute att ON att.attbid = srv.attbid WHERE att.modoptidmodifiable = '2' and (att.attbinactivationdate is null or att.attbinactivationdate < date('now')) and art.artshortlabel='"+itab+"'",false);


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

}

et au niveau de mon fichier log :


15:58:39,667 INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](82) [] ret :busitypid,attblabel
15:58:39,667 INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](85) [] busitypid
15:58:39,667 INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](85) [] attblabel
15:58:40,199 INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](90) [] SELECT busitypid,attblabel FROM t_article art INNER JOIN t_srvbrick_attr_article srv ON art.artid = srv.artid INNER JOIN t_attribute att ON att.attbid = srv.attbid WHERE att.modoptidmodifiable = '2' and (att.attbinactivationdate is null or att.attbinactivationdate < date('now')) and art.artshortlabel='8001P'
15:58:40,199 INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](93) [] mon resultSet:org.sqlite.RS@24c672
15:58:40,199 INFO [com.sfr.price.functionalTest.scenario.impl.AJLINGE.etapeParametrerOption](799) [] ma liste :[]




do things from your heart ...

2 réponses

cormandyr Messages postés 600 Date d'inscription samedi 20 mai 2006 Statut Membre Dernière intervention 8 juillet 2016 11
27 juin 2012 à 14:43
salut

si tu exécutes directement ta requete, sans passer par le code java, tu as une réponse du select?

es-tu certain que ce champ att.modoptidmodifiable est de type alphanumérique? S'il n'est que numérique, pas besoin de mettre les ''
att.modoptidmodifiable '2'> att.modoptidmodifiable = 2
3
Asm87 Messages postés 2 Date d'inscription mercredi 27 juin 2012 Statut Membre Dernière intervention 27 juin 2012
27 juin 2012 à 15:34
Salut ,
oui ma requête sur un éditeur SQLite marche nickel , et mes champs sont des String .


do things from your heart ...
0
Rejoignez-nous