<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<html><head><title>Oracle JDBC Test</title></head>
<body>
<%		
	Connection conn = null;
	Statement stmt = null;
	ResultSet rs = null;
	ResultSetMetaData md = null;
	try{		
		Context initCtx=new InitialContext();
	//获得JNDI初始化上下文信息，即获取目录上下文的引用
		DataSource ds=(DataSource)initCtx.lookup("java:comp/env/jdbc/hap");
	//定位数据源jdbc/plm
		if(ds!=null){
			out.println("get DataSource");
			out.println(ds.toString());
			conn=ds.getConnection();
			if(conn!=null){
				out.println("create connection sucess!");
				stmt=conn.createStatement();
				out.println("createStatement Success!");
				rs=stmt.executeQuery("select * from gld_currency");
				md=rs.getMetaData();
				out.println("<table border=1>");
				out.println("<tr>");
				for(int i=0;i<md.getColumnCount();i++){
					out.println("<td>"+md.getColumnName(i+1)+"</td>");
				}
				while(rs.next()){
					out.println("<tr>");
					out.println("<td>"+rs.getString(1)+"</td>");
					out.println("<td>"+rs.getString(2)+"</td>");
					out.println("<td>");
				}
				out.println("</table>");
			}
	}
	}catch(Exception e){
		out.println(e.toString());
		System.out.println(e.toString());
	}
%>
</body>
	</html>