WebLogic 有自带的,挺好用的
解决方案 »
- web项目路径问题。在线等。
- wiki 如何用关系数据库实现版本控制
- HttpClient请求dwr失败
- struts+hibernate的简单问题
- sql 全角符号
- EL表达式为什么这里用不行?
- 最常用的JS匯總,精心整理,供大家參考!!!請高手繼續增加,大家一起頂起!!
- 请教如何使用htmlparser取的html表单中的值?
- 关于weblogic的问题 急 跪求各位帮帮忙
- 如何用jsp或者是java写出一个可以访问客户端的应用(就象activeX一样重服务器下在到客户,用一操做客户的资源)
- 请问前端用jquery如何调用 java写的webservice接口。
- JSP中try....catch 的问题
-> id int not null auto_increment primary key,
-> foo varchar(25),
-> bar int); (2) 编写测试程序test.jsp,读取数据库表名为testdata的字段的内容,并将结果显示出来。testdata有两个字段foo和bar。 <html> <head> <title>DB Test</title> </head> <body> <% foo.DBTest tst = new foo.DBTest(); tst.init(); %> <h2>Results</h2> Foo <%= tst.getFoo() %><br/> Bar <%= tst.getBar() %> </body></html> (3)编写javabean程序取名为DBTest.java用于连接数据库,将编译好的DBTest.class保存到/tomcat/webapps/DBTest/WEB-INF/classes/foo目录下 package foo;import javax.naming.*;import javax.sql.*;import java.sql.*; public class DBTest { String foo = "Not Connected"; int bar = -1; public void init() { try{ Context ctx = new InitialContext(); if(ctx == null ) throw new Exception("Boom - No Context"); DataSource ds = (DataSource)ctx.lookup( "java:comp/env/jdbc/TestDB"); if (ds != null) { Connection conn = ds.getConnection(); if(conn != null) { foo = "Got Connection "+conn.toString(); Statement stmt = conn.createStatement(); ResultSet rst = stmt.executeQuery( "select id, foo, bar from testdata"); if(rst.next()) { foo=rst.getString(1); bar=rst.getInt(2); } conn.close(); } } }catch(Exception e) { e.printStackTrace(); } } public String getFoo() { return foo; } public int getBar() { return bar;}} (3) 启动tomcat,运行测试程序# /usr/local/tomcat/bin/startup.shhttp://localhost:8080/DBTest/test.jsp运行结果将显示testdata表中的foo和bar字段的内容。