美好的一天 .我想使用pepraredStatement插入数据库.但是每当我添加数据库部分(连接和pepraredStatement)时,"UPLOAD"按钮就会没有响应.但当我删除任何与数据库相关的内容时,我的所有按钮都正常工作.你可以在这里找到代码http://pastebin.com/euKdWhr2.
我将非常感谢任何帮助或建议.可能我在数据库部分缺少一些东西.
public void actionPerformed(ActionEvent ev)
{
String file = fileField.getText();
SetGetQuestionFileName pattern = new SetGetQuestionFileName(file);
ConnectToDatabase database = new ConnectToDatabase();
try
{
///////// check whether textfile is empty or not
if( ev.getActionCommand().equals("UPLOAD"))
{
if(fileField.getText().isEmpty())
{
JOptionPane.showMessageDialog(null,"File field can not be empty!!! Please try again.","ALERT", JOptionPane.ERROR_MESSAGE);
}
else
{
File fi = new File(fileField.getText());
//////////////// perform upload
try
{
String sql = "INSERT INTO testsystem.questionnaire (category_questions, questions, correct_answer)" + "VALUES (?, ?, ?)";
PreparedStatement st = null; …Run Code Online (Sandbox Code Playgroud)