I'm trying to make a select in the mysql database, but I'd like to use like
, which should get the value of a java variable. How can I make 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();
}
}