JAVA所有的讨论-要一点一点的进步
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ page import="javax.sql.*"%> <%@ page import="javax.naming.*"%> <%@ page import="java.sql.*"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <% try { Context envContext = (Context) new InitialContext() .lookup("java:/comp/env"); DataSource ds = (DataSource) envContext.lookup("jdbc/pinyou"); //查找配置
Connection conn = ds.getConnection(); Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select pyid from pyinfo");
while (rs.next()) { out.println(rs.getString("pyid") + "<br>"); } } catch (NamingException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } %> </body> </html>
Powered by: BlogJava Copyright © 石头JAVA摆地摊儿