public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException { response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Hi,world");
try{
InitialContext ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("oracle");
Connection conn=ds.getConnection();
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from scott.emp");
while(rs.next()){
out.println(rs.getString(1)+"<br>");
}
}catch(javax.naming.NamingException ne){
out.println(ne);
ne.printStackTrace(out);
} catch (SQLException se) {
// TODO Auto-generated catch block
out.println(se);
se.printStackTrace(out);
}
out.flush();
out.close();
}
这是代码
throws IOException { response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Hi,world");
try{
InitialContext ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("oracle");
Connection conn=ds.getConnection();
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from scott.emp");
while(rs.next()){
out.println(rs.getString(1)+"<br>");
}
}catch(javax.naming.NamingException ne){
out.println(ne);
ne.printStackTrace(out);
} catch (SQLException se) {
// TODO Auto-generated catch block
out.println(se);
se.printStackTrace(out);
}
out.flush();
out.close();
}
这是代码
解决方案 »
- 怎么把struts1的页面标签换成springMVC, 页面怎么写?例如下面
- 谁有这本书,JAVA项目开发全程实录.pdf
- 一百分急求教通过webservice调用applet后,session过期问题
- jsp中表单提交
- JSP页面怎么显示Sql Server 2000中image字段的数据?
- 在线等 ,struts如何显示,由Action执行查询后返回的结果
- struts string和hibernate 如何配置dataSource为连接池
- 哪位能给说说如何控制JBoss热部署很多jar时,如何来控制部署的顺序!
- Hibernate的标准化查询究竟有用吗?
- 读取上传的excel,excel参数怎么位置?
- weblogic里部署完毕,在调用的时候出了错
- 求助:特殊字符处理问题
如果已经配过了,启动的时候看看有没有错误,还可以看看Server的Jndi tree,看有没有这个“oracle”的项