When running the program, everything works but when searching for the subject, it generates the following error
you have an error in your sql syntax check the manual that corresponds to your mysql server version for the right syntax to use near "[ 95,40,163x28, layout = javax.swing.plaf.basic.BasicTextUI $ UpdateHandler, alignment "at line 1
the following code is a part of what I carry
private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {
String sSQL;
String clavematerias = null, nombre = null, creditos = null, horasC = null, horasT = null, horasL = null, programaeducativo = null;
ConexionMySQL mysql = new ConexionMySQL();
Connection cn = mysql.conectar();
sSQL = "SELECT * FROM tbl_materias Where clavematerias= " + CMtext;
try {
Statement st = cn.createStatement();
ResultSet rs = st.executeQuery(sSQL);
while (rs.next()) {
clavematerias = rs.getString("clavematerias");
nombre = rs.getString("nombre");
creditos = rs.getString("creditos");
horasC = rs.getString("horasC");
horasT = rs.getString("horasT");
horasL = rs.getString("horasL");
programaeducativo = rs.getString("programaeducativo");
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
}
jLabel2.setText(programaeducativo);
// TODO add your handling code here:
}
and for the tables believe this
create table tbl_materias(
clavematerias varchar(100),
nombre varchar(100),
creditos varchar(200),
horasC varchar(20),
horasT varchar(20),
horasL varchar(20),
programaeducativo varchar(20),
primary key(clavematerias)
);
I have only been able to decipher where it is but I still do not understand the reason