请帮助我确定为什么我总是收到此错误:
java.lang.NullPointerException
at TaskDAO.TaskDAO.main(TaskDAO.java:34)
注意:DatebaseHelper
是一个使用 JDBC 连接 MySQL 的类。
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import TaskManagement.*;
public class TaskDAO {
DatabaseHelper help;
public static void main(String[] args) throws InstantiationException,
IllegalAccessException, ClassNotFoundException, SQLException {
TaskDAO taskDAO = new TaskDAO();
int taskID = 6;
String subject = "lau cua";
Status status = Status.Completeted;
Priority priority = Priority.High;
Float percentage = 4f;
String tableName = "tasks";
String startDate = "2012/11/11";
String dueDate = "2012/11/12";
String query = "INSERT INTO "
+ tableName
+ "(taskID,subject,status,priority,percentage,startDate,dueDate)"
+ " VALUES ('" + taskID + "'," + "'" + subject + "'," + "'"
+ status + "'," + "'" + priority + "'," + "'" + percentage
+ "'," + "'" + startDate + "'," + "'" + dueDate + "')";
taskDAO.help.executeQuery(query);
}
}