Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test",
"root", "mysecret");
System.out.println("Connected to Database");
Statement stmt1 = conn.createStatement();
ResultSet rs1=null;
String sql="insert into id
values('"+name+"',12,+fs+,+se+,+th+,+ft+,+f+,+si+,+sv+,+ei+)";
System.out.println("sql:"+sql);
stmt1.executeUpdate(sql);
The Name Variable is taken care of in the definition part not included here, the output is
sql:insert into id values('Golum',12,+fs+,+se+,+th+,+ft+,+f+,+si+,+sv+,+ei+);
It also says error in SQL Syntax which refers to the variables fs,se,th,ft,f,si,sv and ei. Basically i am trying to pass integers to MySQL Database using variables. the definition of these variables is as such
int fs = x21;
int se = y21;
x21 and y21 store mouse click co-ordinates x and y respectively. The code below shows that the co-ordinates are passed correctly. The error is in SQL Syntax. I wanna Know what is the correct syntax for passing integers to SQL Database using this technique.
System.out.println(fs);