连接到 SQLServer 2008 R2 期间发生 jasper 异常
<%@page import="java.sql.*"%>
<form name="form" method="post" >
<b>Select a country:</b> </td>
<select name="sel"><option value=""><---Select---></option>
<%
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:jtds:sqlserver://subversion/sql2k8:1433/career","sa","Cloud#123");
PreparedStatement psmnt = con.prepareStatement("select * from country ");
ResultSet results = psmnt.executeQuery();
while(results.next()){
String name = results.getString(2);
String id = results.getString(1);
%><option value="<%= name %>"><%=name%></option>
<%} results.close(); psmnt.close(); %>
</select><br>
以及随之而来的错误:-
org.apache.jasper.JasperException: An exception occurred processing JSP page /1.dropdown_insert.jsp at line 13
10:
11:
12:
13: Connection con=DriverManager.getConnection("jdbc:jtds:sqlserver://subversion/sql2k8:1433/career","sa","Cloud#123");
14:
15: PreparedStatement psmnt = con.prepareStatement("select * from country ");
16: ResultSet results = psmnt.executeQuery();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
<%@page import="java.sql.*"%>
<form name="form" method="post" >
<b>Select a country:</b> </td>
<select name="sel"><option value=""><---Select---></option>
<%
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:jtds:sqlserver://subversion/sql2k8:1433/career","sa","Cloud#123");
PreparedStatement psmnt = con.prepareStatement("select * from country ");
ResultSet results = psmnt.executeQuery();
while(results.next()){
String name = results.getString(2);
String id = results.getString(1);
%><option value="<%= name %>"><%=name%></option>
<%} results.close(); psmnt.close(); %>
</select><br>
and the error which comes:-
org.apache.jasper.JasperException: An exception occurred processing JSP page /1.dropdown_insert.jsp at line 13
10:
11:
12:
13: Connection con=DriverManager.getConnection("jdbc:jtds:sqlserver://subversion/sql2k8:1433/career","sa","Cloud#123");
14:
15: PreparedStatement psmnt = con.prepareStatement("select * from country ");
16: ResultSet results = psmnt.executeQuery();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jdbc:jtds:sqlserver
://subversion/sql2k8:1433/career
。jdbc:jtds:sqlserver
://subversion/sql2k8:1433/career
.try-catch
block and printstacktrace to get proper error msg.