在Weblogic Server App 下通过JNDI name 获取 DataSourse
程序员文章站
2022-04-12 21:02:40
...
public String getString() {
String cacheLogFlag = null;
Connection con = null;
try {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(XXConstants.DATA_SOURCE);
con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT VALUE FROM XX_USING_PARAM WHERE PARAM_ID = '"
+ XXConstants.PARAM_ID_CUST_LOG_FLAG + "'");
while (rs.next()) {
cacheLogFlag = rs.getString("VALUE");
}
stmt.close();
rs.close();
} catch (Exception e) {
throw e;
} finally {
if (con != null)
con.close();
}
return cacheLogFlag;
}