使用JSP连接JDBC-MYSQL时出错

使用JSP连接JDBC-MYSQL时出错,jsp,Jsp,当您使用时,请在解决上述错误之前阅读 <%@ page import="java.sql.*"%> <%@ page import="javax.sql.*"%> <% public static **Connection connectToDB()** { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); r

当您使用时,请在解决上述错误之前阅读
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%
public static **Connection connectToDB()**
    {
        try
        {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            return DriverManager.getConnection("jdbc:mysql://localhost:3306/payroll", "root","");

        }
        catch(Exception e)
        {
            System.out.println("Error: "+e);    
        }
    }

    public static boolean **closeConnection(Connection c)**
    {
        try
        {
        c.close();
        return true;
        }
        catch (Exception e)
        {
        return false;
        }
    }
%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
Connection c=new connectToDB();
out.print(c);
close(c);
%>
</body>
</html>
Multiple annotations found at this line:
    - Line breakpoint:index.jsp [line: 4]
    - Syntax error, insert "enum Identifier" to complete 
     EnumHeaderName
    - Syntax error, insert "EnumBody" to complete BlockStatement
    - Syntax error on token "Connection", @ expected


Multiple annotations found at this line:
    - Syntax error on token ")", ; 
     expected
    - Syntax error on token "(", ; 
     expected
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%!
public static **Connection connectToDB()**
    {
        try
        {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            return DriverManager.getConnection("jdbc:mysql://localhost:3306/payroll", "root","");

        }
        catch(Exception e)
        {
            System.out.println("Error: "+e);    
        }
    }

    public static boolean **closeConnection(Connection c)**
    {
        try
        {
        c.close();
        return true;
        }
        catch (Exception e)
        {
        return false;
        }
    }
%>
<%
Connection c=new connectToDB();
out.print(c);
close(c);
%>
</body>
</html>