0

Query :

insert into orders (id, lead_id, user_id, status, purchase_mode, bid_id, amt_charged_buyer, payment_medium, reference_id, referral_id, callcenter_id, reseller_id, reseller_oid, desk_username, desk_type, generation_time, comments, invoice_number, is_accounted, pre_booking_info, order_type, initial_snapshot, reason, payment_fee, misc, supplier_id, approval_code, partner_id, process_time, distributor_id, custom_reference, booker_type, is_excel_accounted, cc_id, departure_time, is_confirmed,is_payment_made, tds_rate, r_department_id, r_band_id, r_administrator_id, is_group_booking,sourcetype,deviceid) values ('9484','-1','326','N','','-1','118','D','DDD00007AUEV','-1','-1','326','','','-','2017-01-03 16:29:26.743000 +04:00:00','::::','','0','','IntlInsuranceOrder','118.00#','','0.0','true:true:false:::-1:::0:','-1','SYSTEM','-1','2017-01-03 16:29:43.049000 +04:00:00','-1','','A','0','-1',NULL,'0','0','0.0','-1','-1','-1','0','1','')

I'm getting Following error when execute the query in PG SQL

org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102) ~[postgresql.jar:na]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835) ~[postgresql.jar:na]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) ~[postgresql.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) ~[postgresql.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) ~[postgresql.jar:na]
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334) ~[postgresql.jar:na]
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ~[tomcat-dbcp.jar:7.0.55]
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ~[tomcat-dbcp.jar:7.0.55]
at com.eos.accounts.orders.Order.storeOrder(Order.java:1239) ~[flightraja.jar:na]

However when i execute same query directly on PG admin, it gives me success

Mukesh Kumar
  • 333
  • 1
  • 5
  • 20
  • 1
    Possible duplicate of [Postgres error on insert - ERROR: invalid byte sequence for encoding "UTF8": 0x00](http://stackoverflow.com/questions/1347646/postgres-error-on-insert-error-invalid-byte-sequence-for-encoding-utf8-0x0) – Val Bonn Jan 03 '17 at 12:47
  • 1
    For one thing, that's notably lacking in bind parameter ("prepared statement") use. So it's almost certainly insecure. This also makes it much harder to spot possible issues. – Craig Ringer Jan 03 '17 at 13:15
  • @CraigRinger right. I was inserting string instead of char – Mukesh Kumar Jan 04 '17 at 15:59

0 Answers0