连接到 SQLServer 2008 R2 期间发生 jasper 异常

发布于 2024-11-09 03:19:39 字数 1664 浏览 0 评论 0原文

<%@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很糊涂小朋友 2024-11-16 03:19:39
  1. 检查连接字符串 - jdbc:jtds:sqlserver://subversion/sql2k8:1433/career
  2. 使用 try-catch 块和 printstacktrace 来获取正确的错误消息。
  1. Check for connection string - jdbc:jtds:sqlserver://subversion/sql2k8:1433/career.
  2. Use try-catch block and printstacktrace to get proper error msg.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文