<%@ 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>
// These are the following errors in the functions which are in bold lines.
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