[ad_1]
public static void add_tickets() throws Exception{
Connection connection = null;
try{
DB_connection1 obj_DB_connection = new DB_connection1();
connection = obj_DB_connection.get_connection();
Statement st = connection.createStatement();
ArrayList<ticket> tickets = new ticket().getGet_all_ticket();
for(int i=0;i<tickets.size();i++){
String sql = "insert into risks(`subject`,`submission_date` ,`status`,`source`,`category`,`owner`,`manager`,`assessment`, `notes`, `mitigation_id`, `mgmt_review`, `project_id`, `close_id`, `submitted_by`, `risk_catalog_mapping`, `threat_catalog_mapping`, `template_group_id`) values('"+tickets.get(i).getName()+"','"+tickets.get(i).getDate()+"','New','0','0','0','0','"+tickets.get(i).getContent()+"','','0','0','0','0','2','','','0')";
st.executeUpdate(sql);
}
}catch(Exception e){
System.out.println(e);
}
finally{
if(connection!=null){
connection.close();
}
}
}
Hello I have a method that returns an array that contains values and i want to add those values in another table but it shows the following exception :
java.sql.SQLSyntaxErrorException: 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 'application JAVA','','0','0','0','0','2','','','0')' at line 1
The prob is in this part : +tickets.get(i).getContent()+ because when i replace it with “test” or whatever it works well
I did a main test to see if +tickets.get(i).getContent()+ and it return the values that i want
also the type of the column that I want to insert in it’s string
[ad_2]