I'm trying to make a search function in JTable in my program, but i got sql syntax error when i use this syntax. I've been read much question and answer in this problem and i never got the right syntax. Hope you can help me.
private void fillTable(String keyword) throws SQLException{
if (!keyword.equals("")){
try( Connection con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/inventory?zero"
+ "DateTimeBehavior=convertToNull","root","");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM basis"
+ "WHERE barcode LIKE '%"+keyword+"%' or "
+ "namaProduk LIKE '% "+keyword+" %'");
){
jTable1.setModel(buildTableModel(rs));
}
}
else fillTable();
}