的Java + MySQL錯誤我編程的Java和Eclipse正顯示出我這個錯誤:上查詢
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''where Name=''and Password=''' at line 1
我試圖修復查詢,但錯誤remains.Can你控制,如果我正確地編寫查詢?我想創建這個類不重複所有類中的連接。但這不是錯誤。
text1,2,3
是文本框。我想通過文本框3.
String name = text1.getText();
String password = text2.getText();
String employment = text3.getText();
try {
ResultSet rs = Connection.Creation().executeQuery("select * from '" + employment +
"'where Name='" + name + "'and Password='" + password + "'");
}
catch
{
//something here
}
這樣你就非常容易受到SQL注入的攻擊。 – Rob
您正在使用Java字符串'employment'的值來命名您的表。這是你的意圖嗎? –
正是,我想探索給出的輸入表 – OiRc