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

 

你可能感兴趣的:(weblogic)