分类: Oracle
2008-04-30 18:44:53
首先打开tomcat文件夹,在conf下面找到server.xml(建议先做备份),打开server.xml并在前面加入以下代码(请注意格式): test Tomcat<% try { Context initCtx=new InitialContext(); DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/TestDB"); Connection conn=ds.getConnection(); out.println("data from database: "); Statement stmt=conn.createStatement(); ResultSet rs =stmt.executeQuery("select id, foo, bar from testdata"); while(rs.next()) { out.println(rs.getInt("id")); out.println(rs.getString("foo")); out.println(rs.getString("bar")); } rs.close(); stmt.close(); } catch(Exception e) { e.printStackTrace(); } %>
原文:http://louisyoo.blog.ccidnet.com/blog-htm-itemid-115811-do-showone-type-blog-uid-41414.html |