我有一个java web应用程序,我在使用java文件时做了mysql连接,我想在我的Web应用程序中每周安排一个作业。
这是我的java文件示例
public class DbFunction {
public static DataSource dataSource;
public static Connection getConnection_4main() throws SQLException {
Connection connection = null;
System.out.println("Cant create a Connection");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/" + Constants.TC_DB_NAME + "", "root",
"mysql");
return connection;
}
}
我的jsp文件在这里
<%@page import="net.sf.json.JSONArray"%>
<%@ page import= "java.sql.*" %>
<%@ page import= "java.util.*"%>
<%@page trimDirectiveWhitespaces="true"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:useBean id= "dbfunc" scope="session" class= "package.DbFunction" />
<%
try{
String dailyscheduleidlist=request.getParameter("dailyscheduleidlist");
String []dailyscheduleidarray=dailyscheduleidlist.split("_");
boolean b = dbfunc.removeDailyScheduleBulk(dailyscheduleidarray);
out.print(b);
}
catch(Exception ex){
throw ex;
}
finally
{
}
%>