0
我有下面的JSP將數據插入到Excel中。單個語句拋出異常
<%--
Document : GetRec
Created on : Apr 7, 2014, 7:44:25 PM
Author : u0138039
--%>
<%@page import="java.sql.ResultSetMetaData"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="DBCon.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<% try {
String x = request.getParameter("sid");
String query = "Select * from [Feb$] where [Shipment ID]=?";
ps = con.prepareStatement(query);
ps.setString(1, x);
rs = ps.executeQuery();
ResultSetMetaData meta = rs.getMetaData();
final int columnCount = meta.getColumnCount();
while (rs.next()) {%>
<table border="1px">
<tr>
<%
for (int i = 1; i < 21; i++) {%>
<td>
<b>
<%=meta.getColumnName(i)%>
</b>
</td>
<% }
%>
</tr>
<tr>
<td>
<%=rs.getString(1)%>
</td>
<td>
<%=rs.getString(2)%>
</td>
<td>
<%=rs.getString(3)%>
</td>
<td>
<%=rs.getString(4)%>
</td>
<td>
<%=rs.getString(5)%>
</td>
<%
if (rs.getString(6) == null) {
%>
<td> <select name="Type" id="Type">
<option value="" disabled selected>Select your option</option>
<option value="Looseleaf - Update">Looseleaf - Update</option>
<option value="Pamphlet">Pamphlet</option>
</select>
</td>
<%
} else {
%>
<td>
<%=rs.getString(6)%>
</td>
<%
}
%>
<%
}
} catch (Exception e) {
out.print(e);
}%>
</tr>
</table> </body>
</html>
我在這裏具有rs.getString(6)
價值,如果我使用它,而無需使用if condition
,價值是越來越打印,但是當我用if condition
做到這一點,它是扔我下面的例外。
java.sql.SQLException: No data found
請讓我知道如何解決這個問題。
謝謝
可以請你讓我知道該怎麼做呢。謝謝 – user2423959
請檢查更新 –