Tomcat5.5数据源配置(4)
时间:2025-04-20
时间:2025-04-20
Tomcat5.5数据源配置,各位互相学习
<%
String path = request.getContextPath();
String
+"/";
%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'testPool.jsp' starting page</title>
<meta http-equiv="pragma" c>
<meta http-equiv="cache-control" c>
<meta http-equiv="expires" c>
<meta http-equiv="keywords" c>
<meta http-equiv="description" c>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page. <br>
<%
Connection c;
Context initCtx=new InitialContext();
Context ctx=(Context)initCtx.lookup("java:comp/env");
javax.sql.DataSource ds=(javax.sql.DataSource)ctx.lookup("jdbc/SQL");
c.getConnection();
Statement stmt=conn.createStatement();
PreparedStatement ps=conn.prepareStatement("select * from USERS"); basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path