struts2 - MySQL server: throwing exception regarding syntax of query -


I am creating a project on the Strat Framework, I get an exception from the server when I insert data in the table using SQL And I'm unable to find solutions.

The error is as follows:

  javax.servlet .ServletException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: There is an error in your SQL syntax; Check the manual related to your MySQL server version for the correct syntax to use '  near', ',', ',' 'yes', 'yes', 'admin') . Pre> 

is my code which cause an error as follows: -

  SQL = "field_visit_details (visit_date, block, village, flw_category, flw_name, flw_contact_no, aware_zinc, aware_ors Take, past_zinc, past_ors, qty_avail_zinc_ten, qty_avail_zinc_twe, qty_avail_zinc_syr, qty_avail_ors, qty_disp_zinc_ten, qty_disp_zinc_twe, qty_disp_zinc_syr, qty_disp_ors, stockout_zinc, stockout_ors, diar_cases_seen, diar_cases_reff, diar_deaths_less_than_five, added_by) values ​​( '' + field_visit_date + '', '' + block_row_one + ' '' + Vilej_ro_one + ',' + Flv_ketegri_ro_one + ',' + Flv_nam_ro_one + ',' + Flv_kantekt_no_ro_one + ',' + Aveyr_jink_ro_one + ',' + Aveyr_ors_ro_one + ' '' + Past_zinc_row_one + '', '' + past_ors_row_one + '', '' + qty_avail_zinc_ten_row_one + '', '+ + qty_avail_zinc_t Ve_ro_one + ',' + Kty_aval_jink_sir_ro_one + ',' + Kty_aval_ors_ro_one + ',' + ',' + ',' + '' + '' + '' + '' + + '' + '' + ',' + Qty_disp_ors_row_one + "" + "+ Stokaut_jis_o_on +" ' "' + Stokaut_ors_o_on +", "+ Dayl_ksis_sen_oar_on +" ' "'" + Dayrecasis_ref_oreon + "','" + Dir_deths_o_on + "','" + + Login + '' ') "; Println (sql); Int x = stmt.executeUpdate (SQL); If (x> 0) SUCCESS = "admin";  

The table structure is as follows: -

  (`field_visit_id` make the integer table, not present field_visit_details` (11) No NULL auto_increment,` visit_date `NULL not on,` block` varchar (100) nOT NULL, `village` varchar (100) nOT NULL,` flw_category` varchar (45) nOT NULL, `flw_name` varchar (100) nOT NULL,` flw_contact_no` varchar ( 13) not NULL, `aware_zinc` varchar (10) nOT NULL,` aware_ors` varchar (10) nOT NULL, `past_zinc` varchar (10) nOT NULL,` past_ors` varchar (10) nOT NULL, `qty_avail_zinc_ten` integer ( 11) No NULL, `qty_avail_zinc_twe` integer (11) no null,` qty_avail_zinc_syr` integer (11) not null, `qty_avail_ors` integer (11 ) Not NULL, `qty_disp_zinc_ten` int (11) NOT NULL,` qty_disp_zinc_twe` int (11) NOT NULL, `qty_disp_zinc_syr` int (11) NOT NULL,` qty_disp_ors` int (11) NOT NULL, `stockout_zinc` varchar (11 ) not nULL, `stockout_ors` varchar (11) nOT nULL,` diar_cases_seen` int (11) nOT nULL, `diar_cases_reff` int (11) nOT nULL,` diar_deaths_less_than_five` int (11) nOT nULL, `added_by` varchar (100 ) No NULL, primary key (`field_visit_id`) engine = InnoDB default charset = latin1 AUTO_INCREMENT = 1;  

query when I was first printed in the console: -

  field_visit_details (visit_date, block, village, Flw_category, Flw_name, enter flw_contact_no, aware_zinc, aware_ors, past_zinc, past_ors, qty_avail_zinc_syr, qty_avail_zinc_twe, qty_avail_zinc_ten, qty_avail_ors, qty_disp_zinc_ten, qty_disp_zinc_twe, qty_disp_zinc_syr, qty_disp_ors, stockout_zinc, stockout_ors, diar_cases_seen, diar_cases_reff, diar_deaths_less_than_five, added_by) vALUES ( '2014-07-02', 'asdasd', '' , '12', '12', '12', '12', '12 ','  

But that is, '12', '12', 'yes' , 'Yes', '12', '12', '12', 'admin') that successfully contains data in the query table, but still the server Showing Prokt error.

I even used the printed query above directly in phpmyadmin and worked fine without any problems. Please help me to resolve any ideas are welcome ...

You have SQL There is a syntax exception in the statement that you posted the error message. Therefore, you have to change the SQL statement and fix syntax errors. For this purpose, you should re-write this to use PraparedStatement for example. And use appropriate for database column type set methods when setting the parameters of the prepared statement.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -