上圖是viewdata.jsp讀取一個數據庫表後顯示所有數據的效果截圖。已知Viewdata.jsp操作數據庫是用jdbc-odbc橋方式,odbc數據源名稱為grade,請完成程序。
<%@page contentType=“text/html;charset=gb2312”%>
<%@page import=“_____A_____ “%>
<%Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String strSQL = ““;
try{
Class.forName(“________B______”);
}
catch(ClassNotFoundException ce){}
try{
conn=DriverManager.__C_____ (“jdbc:odbc:___D___ “);
stmt=conn._______E_____;
strSQL = “SELECT * FROM grade”;
rs = stmt._____F____ (strSQL); %>
<TABLE BORDER=“1”>
<tr><td>學號</td><td>姓名</td><td>語文</td><td>數學</td><td>英語</td></tr>
<% ______G____{%>
<tr>
<td>____H_____</td>
<td>____I_____</td>
<td>_____J____</td>
<td>_____K____</td>
<td>_____L____</td>
</tr>
<%}%>
</TABLE><%}//END TRY
catch(Exception e){}
finally{ stmt.close(); conn.close(); }
%>
A:java.sql.*
B:com.microsoft.sqlserver.jdbc.SQLServerDriver
C:getConnection
D:username,password
E:createStatement()
F:executeQuery
G:while(rs.next())
H:<%=rs.getString("學號")%>
I:<%=rs.getString("姓名")%>
J:<%=rs.getString("語文")%>
K:<%=rs.getString("數學")%>
L:<%=rs.getString("英語")%>