⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpleselect.jsp

📁 weblogic应用全实例
💻 JSP
字号:
<!doctype html public "-//w3c/dtd HTML 4.0//en">

<!-- 这是个Jsp页面,演示了如何使用WebLogic连接池驱动来为一个Servlet建立JDBC连接
-->

<html>
<head>
<title>Simple Select</title>
</head>
<body bgcolor=#FFFFFF>

<H1>Simple Select</h1>
<p>
<%--本类用到的类和包--%>
<%@ page import="
java.io.*,
java.sql.*,
javax.servlet.*,
javax.servlet.http.*,
java.util.Properties,
weblogic.db.jdbc.*
"%>

<%
//声明连接变量
 Connection conn  = null;
 	try {  
      //加载WebLogic连接池驱动程序
	Class.forName("weblogic.jdbc.pool.Driver").newInstance();
	//建立连接池连接
	conn = DriverManager.getConnection("jdbc:weblogic:pool:oraclePool", null);
	//声明SQL语句对象	
      Statement stmt = null;
      //声明结果集变量
	ResultSet rs = null;
	//创建声明对象
	stmt = conn.createStatement();
	//执行SQL语句并返回结果集
	rs = stmt.executeQuery("select * from emp " + "where sal < 2000 " + "order by empno");
     //从请求页面获取参数
     String empno  = request.getParameter("empno");
     String job  = request.getParameter("job");
     String mgr  = request.getParameter("mgr");
     String hiredate  = request.getParameter("hiredate");
     String sal  = request.getParameter("sal");
     String comm  = request.getParameter("comm");
     String deptno  = request.getParameter("deptno");
 %>  
      <HR>
	  <table border=1 cellpadding=5>
        <th>EMPNO</th>
        <th>ENAME</th>
        <th>JOB</th>
        <th>MGR</th>
        <th>HIREDATE</th>
        <th>SAL</th>
        <th>COMM</th>
        <th>DEPTNO</th>

 <%
 	//打印结果集
 	while (rs.next()) {
      	String ename = rs.getString("ename");
      	//打印一个记录
 %>
	  
	<tr>
          <td><%= rs.getString("empno") != null ? rs.getString("empno") : "&nbsp;" %></td>
          <td><%= ename %></td>
          <td><%= rs.getString("job") != null ? rs.getString("job") : "&nbsp;" %></td>
          <td><%= rs.getString("mgr") != null ? rs.getString("mgr") : "&nbsp;" %></td>
          <td><%= rs.getString("hiredate") != null ? rs.getString("hiredate") : "&nbsp;" %></td>
          <td><%= rs.getString("sal") != null ? rs.getString("sal") : "&nbsp;" %></td>
          <td><%= rs.getString("comm") != null ? rs.getString("comm") : "&nbsp;" %></td>
          <td><%= rs.getString("deptno") != null ? rs.getString("deptno") : "&nbsp;" %></td>
      </tr>

 <%
	}
 %>
     
	</table> 

 <%
	}
	catch (Exception e){
	//异常处理
	out.print("Connection Failed" + e.getMessage());
	}
		finally {
		if(conn != null)
		//关闭连接池连接对象
 		try{
			conn.close();
		   }  catch (Exception e){
		   //异常处理
			out.print("Exception:" + e);
			}
		}
%>

<p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -