なぜ私がいつもこのエラーが発生したのかを特定するのを手伝ってください:
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);
}
}