I am beginner on sqlite,I use it I have no choice and I code with java, I have a request that It should return as reslutat two columns, but It returns anything, the resultSet is org.sqlite.RS@..,please I need help on this , thank you in advance.
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;
}
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+"'",false); logger.info("ma liste :"+ls);
}}
what my file log containt
INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](82) [] ret :busitypid,attblabel
INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](85) [] busitypid
INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](85) [] attblabel
INFO [com.sfr.price.functionalTest.commons.SQLBase.executeSelect](90) [] 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](93) [] mon resultSet:org.sqlite.RS@24c672
INFO [com.sfr.price.functionalTest.scenario.impl.AJLINGE.etapeParametrerOption](799) [] ma liste :[]
The reason you’re getting
org.sqlite.RS@24c672when printing your result set is because that class has not overridden the default implementation of toString() in the base object class. According to the SQLiteJDBC documentation, you should be able to iterate through the ResultSet and print out values accordingly.Something like this should work:
Also, I do not understand the purpose of your boolean
All. (Note: Java style convention indicates that this variable should be namedall, with lowercase first letter.) Because of the way yourwhileloop andifstatement are written, you will end up either printing only the column headings, or only the contents of your result set. Based on the contents of your log file, I’d assume you’d passed inAll = false— which would make your output correct.