³JSPե

ˡ

1. ֤
2. DataSource dsפΡjava:comp/env/jdbc/mysqlפͤѹ

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="javax.naming.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
Connection con = ds.getConnection();
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery ("select user()");
%>
  <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    </HEAD>
    <BODY>
      <TABLE border=1>
      <%
        while (rset.next ()) {
          out.print("<tr>");
          out.print("<td>" + rset.getString(1) + "</td>");
          out.print("</tr>");
        }
      %>
      </TABLE>
    </BODY>
  </HTML>

ȥå   Խ ʬ ʎގ̎ ź ʣ ̾ѹ   ǽ   إ   ǽRSS
Last-modified: 2006-11-14 () 10:34:41 (5430d)