- <%@ page contentType="text/html; charset=gb2312" %>
- <%@ page import="javax.naming.Context" %>
- <%@ page import="javax.sql.DataSource"%>
- <%@ page import="javax.naming.InitialContext"%>
- <%@ page import="java.sql.*"%>
- <%
- try{
- Context initContext = new InitialContext();
- DataSource ds = (DataSource)initContext.lookup("java:/jboss/datasources/MysqlDs");
- if(ds!=null) {
- out.println(" DataSource!");
- out.println("<br>");
- Connection conn = ds.getConnection();
- Statement stmt=conn.createStatement();
- ResultSet rs=stmt.executeQuery("select * from table_person");
- out.println(" ");
- out.println("<br>");
- while(rs.next()) {
- out.println("person_name:"+rs.getString("person_name"));
- out.println("<br>"); }
- rs.close();
- stmt.close();
- conn.close();
- } else
- out.println(" !"); }
- catch(Exception ne) {
- out.println(ne);
- }
-
- %>