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 30 31 32 33 34 35 36 37 38 39
|
String nomConnect = "java:/maConnection";
try
{
Context jndi = new InitialContext();
ds = (DataSource)jndi.lookup(nomConnect);
}
catch (Exception e)
{
System.out.println("erreur connexion ... "+ e.getMessage());
ok = false;
}
try
{
l_connection = ds.getConnection();
l_stmt = l_connection.createStatement();
l_rset = l_stmt.executeQuery(texteSql);
System.out.println(texteSql);
while(l_rset.next())
{
champ = l_rset.getString("CHAMP"));
}
}
catch (SQLException sqlExcp)
{
ok = false;
}
finally
{
try
{
if (l_rset!=null) l_rset.close();
if (l_stmt!=null) l_stmt.close();
}
catch (Exception e)
{
System.out.println("erreur fermeture connexion"+e);
}
} |