首页上一页 1 下一页尾页 2 条记录 1/1页
JSP下面程序体(body包含程序)在服务器上无法运行(无输出)
发表在JavaWeb编程词典答疑
2020-10-14
是否精华
是
否
版块置顶:
是
否
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/test";
String username="root";
String password="111";
Connection conn=DriverManager.getConnection(url,username,password);
if(conn!=null){
out.println("数据库连接成功");
conn.close();}
else{
out.println("数据库连接失败!");
}
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}
%>
</body>
</html>于2020-10-14 19:45:23编辑

购物车
发表新帖
立即签到








