- jsp中jdbc連接數據庫出錯
-
代碼如下,錯誤我不知道如何解決:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Insert title here
<%
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306?stu/root/";
Connection conn=DriverManager.getConnection(url);
out.print("success!!!");
Statement stt=conn.createStatement();
ResultSet rst=stt.executeQuery("select * from t_students");
while(rst.next()){
out.print(rst.getString("name"));
}
%>
最佳回答:
自己回答:sb url寫錯了localhost:3306/stu?root