0
How to convert variable string fg
in one whole?
if (connectionIsOpened)
{
String s = "INSERT INTO jogador(nome) VALUES " + "('" + this.playerName + "'" + ")";
connection.executeUpdate(s);
String fg = "SELECT cod_jogador FROM jogador WHERE jogador.nome = " + "'" + this.playerName + "'"; //buscar cod_jogador onde nome_jogador = this.playerName
connection.executeQuery(fg);
int gh = Integer.parseInt(fg);
String a ="INSERT INTO `jogos`( `cod_jogador`, `pontuacao`) VALUES " + "(" + gh + "," + this.points + ")"; //Inserir cod_jogador e pontuação onde nome_jogador = this.playernames
connection.executeUpdate(a);
connection.close();
}
fg
definitely is not whole. You would not like to rescue theResultSet
returned by connection when runningfg
and thenrs.getInt("cod_jogador")
?– Jefferson Quesado
By the code, Voce does not need to convert anything, just redeem the value of cod_player, as it will insert in another query. Although I think that there would be the case of a subquery instead of two queries.
– user28595
Good afternoon Articuno, that’s just what I need. How to do?
– Diogo Neves
your c'Odigo this vulnerable for SQL Injection
– Thiago Loureiro