I'm trying to insert data into mysql db from java GUI , however there is an exception stating
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: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 '?,?,?,?.?)' at line 1
String sql = "INSERT INTO ugc VALUES (?,?,?,?,?)";
try {
pst=conn.prepareStatement(sql);
pst.setString(1, univ_name.getText());
pst.setString(2, reg_no.getText());
pst.setString(3,affiliation);
String naac_grade=naac.getSelectedItem().toString();
pst.setString(4, naac_grade);
pst.setString(5, country.getText());
pst.executeUpdate(sql);
?which is an error but in you code there is no dotpst.executeUpdate(sql);because you have already prepared the statement then there is no need to provide it again