<%@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();
堆栈跟踪:
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)
答案 0 :(得分:0)
jdbc:jtds:sqlserver
:// subversion / sql2k8 :1433/career
。 try-catch
阻止和printstacktrace来获取正确的错误信息。