Guest User

Untitled

a guest
Nov 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. public void returInfoClient(userClient) {
  2.  
  3. Connection mConn = (new ConnectionFactory()).getConnection();
  4.  
  5. String sql = "SELECT nameClient, userClient, descriptionClient, passwordClient, birtDate
  6. FROM Client
  7. WHERE userClient LIKE 'userClient%';" //quero que o userClient venha do parametro da função
  8. + "values(?);";
  9.  
  10. try {
  11. PreparedStatement stmt = mConn.prepareStatement(sql);
  12. stmt.setString(1, userClient); //quero usar o userClient do parametro da função para o like do select
  13. stmt.execute();
  14. stmt.close();
  15. System.out.println("retornando informações author");
  16. connection.close();
  17. } catch (SQLException e) {
  18. e.printStackTrace();
  19. }
  20. }
  21.  
  22. String sql = "SELECT nameClient, userClient, descriptionClient, passwordClient, birtDate FROM Client WHERE userClient LIKE '?%';"
  23.  
  24. public void returInfoClient(TipoDoObjeto userClient) {
  25.  
  26. public void returInfoClient(userClient) {
  27.  
  28. Connection mConn = (new ConnectionFactory()).getConnection();
  29.  
  30. String sql = "SELECT nameClient, userClient, descriptionClient, passwordClient, birtDate FROM Client WHERE userClient LIKE ?";
  31.  
  32. try {
  33. PreparedStatement stmt = mConn.prepareStatement(sql);
  34. stmt.setString(1, userClient + "%");
  35. stmt.execute();
  36. stmt.close();
  37. System.out.println("retornando informações author");
  38. connection.close();
  39. } catch (SQLException e) {
  40. e.printStackTrace();
  41. }
  42. }
Add Comment
Please, Sign In to add comment