I use Java to insert some data into mysql. But the presence of an apostrophe (punctuation mark) in the data (near the weekly tracker suggests that the work is growing) gives me a MySQLSyntaxErrorException. Please give me the correct solution to handle this
Code I have isa
void insert(String a1,String a2, String a3) {
String nt = a2;
String pt = a3;
String tb = a1;
query = "insert into "+tb+"(head,des) values('"+nt+"','"+pt+"')";
try {
stmt.executeUpdate(query);
System.out.println("inserted");
} catch (SQLException ex) {
ex.printStackTrace();
}
}
source
share