executequery ne retourne rien ?
Bonjour,
je veux récuperer un ResultSet dans le main. J'appelle pour cela une méthode d'une autre classe. Je n'obtiens rien alors qu'une fois appelée depuis la classe, mes résultats sortent.
Qu'y a-til d'illégal dans ce code ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// MAIN
public static void main(String[] args)
{
// db test
dbtest db = new dbtest();
//db.init();
final String[][] list = new String[4][4] ;
ResultSet tmp ;
try
{
tmp = db.getRecords("SELECT * FROM tst_01 ; ");
}catch(Exception e) {} |
Ma classe étant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
public class dbtest
{
public ResultSet getRecords(String pSql)
{// >(string) - (ResultSet)>
try
{
// get
res = stmt.executeQuery(pSql) ;
while(res.next() )
System.out.println( res.getString(2) ) ;
}catch(SQLException e){ System.err.println( e.toString() ) ; }
return this.res ;
}
public void init()
{
// get
ResultSet rs = this.getRecords("SELECT * FROM tst_01 ;");
}
} |