i have written code insert values in mysql ,i have made database connection getting error: com.mysql.jdbc.exceptions.mysqlsyntaxerrorexception
public class javamysql { public static void main(string[] args) { string url = "jdbc:mysql://localhost:3306/bhuwan"; string driver = "com.mysql.jdbc.driver"; string username = "root"; string password = "rpass"; try { class.forname(driver).newinstance(); connection conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/bhuwan","root","rpass"); preparedstatement stmt=conn.preparestatement("insert in xmltable values(?,?)"); stmt.setint(1,101); stmt.setstring(2,"nitish sharma"); stmt.execute(); int i=stmt.executeupdate(); system.out.println(i+"records inserted"); conn.close(); }catch(exception e){system.out.println(e);} } }
the problem have space in into keyword,
insert in xmltable values(?,?) ^ causes error it should be
insert xmltable values(?,?)
Comments
Post a Comment