当前位置: 代码迷 >> Web前端 >> 在Weblogic Server App 上通过JNDI name 获取 DataSourse
  详细解决方案

在Weblogic Server App 上通过JNDI name 获取 DataSourse

热度:348   发布时间:2012-10-19 16:53:36.0
在Weblogic Server App 下通过JNDI name 获取 DataSourse

?

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

?

  相关解决方案