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

📄 displayitemstable.jsp

📁 BEA WebLogic Server 8.1大全 = BEA webLogic server 8.1 unleashed (美) Mark Artiges等著 袁毅 ... [等] 译 eng
💻 JSP
字号:
<%@ page import="javax.naming.*,java.sql.*,javax.sql.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>XYZ Confectionaries-Display Items</title>
	<b><u>XYZ Confectionaries - Display Items</u></b>
</head>

<body>

<br><br><br>
<% 
	boolean ctxInitialized = false;
	boolean connInitialized = false;
	boolean stmtInitialized = false;
	boolean rsInitialized = false;

	Context ctx = null;
	DataSource ds = null ;
	Connection aConnection = null;
	Statement stmt = null;
	ResultSet rs = null;
	try
	{
		ctx = new InitialContext(); ctxInitialized = true ;
		ds = (DataSource) ctx.lookup("jdbc/XYZConfDataSource");
		aConnection = ds.getConnection(); connInitialized = true;
		stmt = aConnection.createStatement(); stmtInitialized = true;
		rs = stmt.executeQuery( " SELECT * FROM XYZCONF.ITEM "); rsInitialized = true;
%>
<table frame="box" rules="all">
<caption align="bottom">Items in the XYZ Confectionaries ITEM table</caption>
<tr> <th>ID</th><th>Description</th><th>Stock</th><th>Price</th> </tr>
<%
		while (rs.next()) {
%>
<tr><td><%=rs.getString(1)%></td><td><%=rs.getString(2)%></td><td><%=rs.getDouble(3)%></td><td><%=rs.getDouble(4)%></td></tr>
<%
		}
%>
</table>
<%
	}
	catch (NamingException ne)
	{
		ne.printStackTrace();
%>
Naming Exception occurred. <%=ne.getMessage()%>
<%
	}
	catch (SQLException sqle)
	{
		sqle.printStackTrace();
%>
SQL Exception occurred. <%=sqle.getMessage()%>
<%
	}
	finally
	{
		if (rsInitialized) rs.close();
		if (stmtInitialized) stmt.close();
		if (connInitialized) aConnection.close();
		if (ctxInitialized) ctx.close();
	}
%>


</body>
</html>

⌨️ 快捷键说明

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