语法错误:在第 1 行第 54 列遇到"t"



我得到一个错误,说"语法错误:遇到"t"在第1行,第54列"

这似乎只发生在历史列表的增强for循环迭代不止一次时。当我添加一行项目时,它工作得很好,但当我添加更多时,它会给我这个错误

下面是我的代码:
public void databaseSave( ArrayList <Patient> pList )
{
    try
    {
        stmt = getConnection().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        //Statement stmt = con.createStatement();
        //Deletes all records from the Patient Table.
        deleteAllFromPatientTable();
        //Selects all the records from the Patient table.
        selectAllFromPatient();

        System.out.println("Before loop");
        for ( Patient p: pList )
        {
            patientInsertSQL = "Insert Into SHAUN.PATIENT VALUES (" + p.getPatientNum() + ", '"
            + p.getPatientName() + "', '" + p.getPatientAddress() + "', '"
            + p.getPatientPhone() + "')";
            res = stmt.executeUpdate(patientInsertSQL); 
            System.out.println(res);

            ArrayList <History> tempHistList = p.getHistory();
            //Deletes all the records from the history table.
            deleteAllFromHistoryTable();
            //Selects all the records from the history table.
            selectAllFromHistory();
            for ( History h: tempHistList )
            {                   
                historyInsertSQL = "Insert Into SHAUN.HISTORY VALUES (" + h.getHistID() + ", '" + h.getConditionName() + "', '" + h.getMedication() + "', '" + h.getDateOccured() + "', " + p.getPatientNum() + ")";
                res = stmt.executeUpdate(historyInsertSQL); 
                System.out.println(res);
                //Loop Checker
                int i = 1;
                System.out.println("In the History Loop " + i);
                i++;
            }
            System.out.println("In the loop!");
        }
        stmt.close();
        result.close();
        con.commit();
        System.out.println("After Loop and close");
    }
    catch (SQLException err)
    {
        System.out.print(err.getMessage());
    }
}

您可能有SQL注入问题,并且在您的错误中提到的t来自类似

的东西
INSERT INTO .....'Can't Tolerate X'
                     ^---

相关内容

  • 没有找到相关文章

最新更新