I am new to use mysql with JAVA API. Now the way I send query or update is that I simply create a String containing all lines, and then pass it to executeQuery() or executeUpdate(). I found it annoy because to pass variables from Java I would have to end quote put in variable another quote, and I had to work carefully around spaces and inner quotes.
I was wondering:
- Is there a better way to send queries or updates? I tried to do some research on reasons for PreparedStatement but didn't learn much.
- Is there a better way to pass variables?
Also, if you have got some advice for newbies please also include it. Thanks