<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><%@ page import="java.sql.*" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
My JSP 'conn.jsp' starting page <% String JDriver="com.microsoft.sqlserver.jdbc.SQLServerDriver";String uri = "jdbc:sqlserver://localhost:1433; DatabaseName=shopping"; String user="sa";String password="sa";Connection conn=DriverManager.getConnection(uri,user,password);Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);Statement stmt1=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);request.setCharacterEncoding("gb2312");String sql="select * from goods";ResultSet rs=stmt.executeQuery(sql);while(rs.next()){%>第一段:<%=rs.getString(1) %>第二段:<%=rs.getString(2) %><%} %><% out.print("數據庫操作成功");%><%rs.close();stmt.close();conn.close(); %>嚴重: Servlet.service() for servlet [jsp] in context with path [/shopping_liumengmeng] threw exception [An exception occurred processing JSP page /conn.jsp at line 1613: String uri = "jdbc:sqlserver://localhost:1433; DatabaseName=shopping"; 14: String user="sa";15: String password="sa";16: Connection conn=DriverManager.getConnection(uri,user,password);Stacktrace:] with root cause
數據庫沒連上,檢查報錯的那幾行