1
I am trying to make a select in mysql database, but would like to use the like
, that should receive the value of a java variable. How can I do this interaction?
public void returInfoClient(userClient) {
Connection mConn = (new ConnectionFactory()).getConnection();
String sql = "SELECT nameClient, userClient, descriptionClient, passwordClient, birtDate
FROM Client
WHERE userClient LIKE 'userClient%';" //quero que o userClient venha do parametro da função
+ "values(?);";
try {
PreparedStatement stmt = mConn.prepareStatement(sql);
stmt.setString(1, userClient); //quero usar o userClient do parametro da função para o like do select
stmt.execute();
stmt.close();
System.out.println("retornando informações author");
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}