实现简单功能:查询oracle表中数据,然后放到table中。
<body>
<%!
Connection getConnection(){
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:orac:thin:@localhost:1521:orcl","system","njniit");
}catch(Exception e){
e.printStackTrace();
}
return conn;
}%>
<%
String sql="select sid,stuname from stuinfo";
Connection conn= getConnection();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
%>
<center>
<table border="1" style="color:blue">
<caption style="color:red">学生表</caption>
<tr>
<td>学号</td><td>姓名</td>
</tr>
<% while(rs.next()){
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2)%></td>
</tr>
<%}%>
</table>
</center>
</body>
语法掩盖没错误,可是调试总是不能实现
<body>
<%!
Connection getConnection(){
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:orac:thin:@localhost:1521:orcl","system","njniit");
}catch(Exception e){
e.printStackTrace();
}
return conn;
}%>
<%
String sql="select sid,stuname from stuinfo";
Connection conn= getConnection();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
%>
<center>
<table border="1" style="color:blue">
<caption style="color:red">学生表</caption>
<tr>
<td>学号</td><td>姓名</td>
</tr>
<% while(rs.next()){
%>
<tr>
<td><%=rs.getInt(1)%></td>
<td><%=rs.getString(2)%></td>
</tr>
<%}%>
</table>
</center>
</body>
语法掩盖没错误,可是调试总是不能实现
解决方案 »
- 请教spring+hibernate事务的问题
- 一个选择题?????????????????????????、
- 初次开发structs程序出现以下错误,高手们帮忙看看什么原因,谢谢了
- weblogic9.0怎么配置成服务器呀?
- struts2 跳转带参数,这样写可以吗?
- struts里面如何自动提交多行表单数据
- 学j2ee你们都会碰到的问题,愿IQ高的朋友,慷慨解答!!
- 为什么我的serversocket监听程序只能得到一个连接?
- 开发JSP,J2EE快两年了,没用过Struts,现在想不到用Struts的必要?(困惑中)
- jsp调用ejb问题
- Web Service可否返回xml的属性
- 关于线程的小问题
53: <%
54: String sql="select sid,stuname from stuinfo";
55: Connection conn= getConnection();
56: Statement stmt=conn.createStatement();
57: ResultSet rs=stmt.executeQuery(sql);
58: %>
59: <center> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root causejava.lang.NullPointerException
org.apache.jsp.FirstJsp_jsp._jspService(FirstJsp_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:390)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.7 logs.
这里是不是少了二个字母呀,改为如下试试:
conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","system","njniit");