欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在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;
	}
 

 

相关标签: Weblogic