在运行jsp时出现了下面的问题,有知道怎么解决的吗
我只是写了一个简单的连接数据库的代码而已
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.sun.corba.se.impl.orb.PrefixParserAction" %>
<%@ page import="com.microsoft.sqlserver.jdbc" %>
<html>
<head>
<title>SQL Server 2019</title>
</head>
<body>
<%
try
{
Class.forName("com.mysql.jdbc.Driver"); //加载MYSQL JDBC驱动程序
//Class.forName("org.gjt.mm.mysql.Driver");
System.out.println("成功加载Mysql驱动程序!");
}
catch (Exception e)
{
System.out.print("加载Mysql驱动程序时出错!");
e.printStackTrace();
}
try
{
Connection connect = DriverManager.getConnection( "jdbc:mysql://localhost:3306/user","root","123");
//连接URL为 jdbc:mysql//服务器地址/数据库名 ,后面的2个参数分别是登陆用户名和密码
System.out.println("成功连接Mysql服务器!");
Statement stmt = connect.createStatement();
ResultSet rs = stmt.executeQuery("select * from user"); //user 为你表的名称
while (rs.next())
{
System.out.println(rs.getString("username"));
}
connect.close();
}
catch (Exception e)
{
System.out.print("获取数据错误!");
e.printStackTrace();
}
%>
</body>
</html>