这是查询
String query =
"SELECT idPlayers
FROM pendu.players
WHERE first= 'Super'AND last='Man' AND pass=12345";
我想将 (first='Super') 更改为 first = tboxFirst.getText() 等
谢谢你帮助我
坦率
这是查询
String query =
"SELECT idPlayers
FROM pendu.players
WHERE first= 'Super'AND last='Man' AND pass=12345";
我想将 (first='Super') 更改为 first = tboxFirst.getText() 等
谢谢你帮助我
坦率
如果您使用的是字符串,则可以像这样创建带有值的字符串:
String query = "SELECT idPlayers FROM pendu.players WHERE first= '" + tboxFirst.getText() + "'AND last='Man' AND pass=12345";
您还应该看一下,PreparedStatement
因为这是一个更好的解决方案。
PreparedStatement pstmt = con.prepareStatement(
"SELECT idPlayers FROM pendu.players WHERE
first= ? AND last= ? AND pass=?");
pstmt.setString(1, tboxFirst.getText());
pstmt.setString(2, ....);
....
String query = "SELECT idPlayers FROM pendu.players WHERE first=('"+tboxFirst.getText()+"') AND pass=12345";
你可以使用
String query =
"SELECT idPlayers
FROM pendu.players
WHERE first='"+tboxFirst.getText()+"'AND last='Man' AND pass=12345";
或者
String query = String.format(SELECT idPlayers
FROM pendu.players WHERE first='%s'AND last='Man' AND pass=12345", tboxFirst.getText());
如果你使用 JDBC,你可以使用 PreparedStatement
PreparedStatement pstmt = con.prepareStatement("SELECT idPlayers FROM pendu.players WHERE first=? AND last=? AND pass=?");
pstmt.setString(1, "Super");
pstmt.setString(2, "Man");
pstmt.setString(3, "12345");