我正在努力解決這個問題,並且出於某種原因,我無法解決它。SQL準備好的語句不起作用
Connection conn = null;
PreparedStatement ps = null;
String query = "INSERT INTO " + "tags" + "(Name, Income, Expense) VALUES(?,?,?)";
ps = conn.prepareStatement(query);
ps.setString(1, tag);
ps.setString(2, amount_);
ps.setString(3, "0");
ps.executeQuery();
Tag
是用戶輸入的字符串,用戶還可以發送SQL注入!爲什麼?? 另外我得到這個Eclipse錯誤:Null pointer access: The variable conn can only be null at this location
。
什麼是'conn'?這裏是'null'。 –
'connection con = drivermanager.getconnection;' – mjosh