Retourner au contenu associé (entrée de forum : JNDI et problème de nommage)
Posté par allcolor le 04 septembre 2009 à 18:20. En réponse au message JNDI et problème de nommage. Évalué à 2.
Context initCtx = new InitialContext(); DataSource ds; try { Context envCtx = (Context) initCtx.lookup("java:comp/env"); ds = (DataSource) envCtx.lookup(location); } catch (NamingException namingEx) { // try looking up the location directly... ds = (DataSource) initCtx.lookup(location); }
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: Faire les 2 dans un try/catch
Posté par allcolor . En réponse au message JNDI et problème de nommage. Évalué à 2.
Les lignes que je voulais mettre en évidence:
Context initCtx = new InitialContext();
DataSource ds;
try {
Context envCtx = (Context) initCtx.lookup("java:comp/env");
ds = (DataSource) envCtx.lookup(location);
}
catch (NamingException namingEx) {
// try looking up the location directly...
ds = (DataSource) initCtx.lookup(location);
}