即使没有异常,数据也不会插入到表中

时间:2015-09-09 12:12:34

标签: java mysql jdbc

我正在尝试使用JDBC连接将数据推送到数据库。这是架构http://s000.tinyupload.com/?file_id=06524701188448795628。 JDBC连接似乎很好,因为我正确地从另一个表中获取数据。我也不例外。

这是字符串

String sql = "insert into online_orders_hdr (OOH_ONLINE_REFERENCE_NO, OOH_SERVICE_USER_ID, OOH_ORDER_STATUS," +
                 "OOH_TOTAL_QUANTITY, OOH_TOTAL_AMOUNT, OOH_PAYMENT_MODE, OOH_SHIPPING_ID, OOH_SHIPPING_NAME, OOH_SHIPPING_ADDRESS1, " +
                  "OOH_SHIPPING_ADDRESS2, OOH_SHIPPING_PLACE, OOH_SHIPPING_STATE, OOH_SHIPPING_COUNTRY, OOH_SHIPPING_PINCODE, OOH_SHIPPING_MOBILE, "+
                   "OOH_SHIPPING_PHONE, OOH_SHIPPING_EMAIL, OOH_CUSTOMER_ID, OOH_CUSTOMER_NAME, OOH_CUSTOMER_ADDRESS_LINE1, OOH_CUSTOMER_ADDRESS_LINE2,"+
                   "OOH_CUSTOMER_CITY, OOH_CUSTOMER_STATE, OOH_CUSTOMER_PINCODE, OOH_CUSTOMER_COUNTRY, OOH_CUSTOMER_MOBILE, OOH_CUSTOMER_EMAIL, "+
                   "OOH_POS_PUSH_STATUS, OOH_CREATED_AT, OOH_UPDATED_AT, OOH_POS_TIMESTAMP, OOH_ONLINE_PUSH_STATUS, OOH_VENDOR) values  "+
                   "("  + OOH_ONLINE_REFERENCE_NO +","+ OOH_SERVICE_USER_ID +","+ OOH_ORDER_STATUS +","+ OOH_TOTAL_QUANTITY +","+ OOH_TOTAL_AMOUNT +","+
                     OOH_PAYMENT_MODE +","+ OOH_SHIPPING_ID +","+ OOH_SHIPPING_NAME +","+ OOH_SHIPPING_ADDRESS1 +","+ OOH_SHIPPING_ADDRESS2 +","+ OOH_SHIPPING_PLACE  +","+
                     OOH_SHIPPING_STATE +","+ OOH_SHIPPING_COUNTRY +","+ OOH_SHIPPING_PINCODE +","+ OOH_SHIPPING_MOBILE +","+ OOH_SHIPPING_PHONE +","+ OOH_SHIPPING_EMAIL  +","+
                   OOH_CUSTOMER_ID+","+ OOH_CUSTOMER_NAME +","+ OOH_CUSTOMER_ADDRESS_LINE1 +","+ OOH_CUSTOMER_ADDRESS_LINE2 +","+ OOH_CUSTOMER_CITY +","+ OOH_CUSTOMER_STATE +","+
                   OOH_CUSTOMER_PINCODE+","+ OOH_CUSTOMER_COUNTRY +","+ OOH_CUSTOMER_MOBILE +","+ OOH_CUSTOMER_EMAIL +","+ OOH_POS_PUSH_STATUS +","+ OOH_CREATED_AT +","+ OOH_UPDATED_AT+","+
                   OOH_POS_TIMESTAMP+","+ OOH_ONLINE_PUSH_STATUS +","+ OOH_VENDOR + " )";

这是字符串
的SOP

insert into online_orders_hdr (OOH_ONLINE_REFERENCE_NO, OOH_SERVICE_USER_ID, OOH_ORDER_STATUS,OOH_TOTAL_QUANTITY, OOH_TOTAL_AMOUNT, OOH_PAYMENT_MODE, OOH_SHIPPING_ID, OOH_SHIPPING_NAME, OOH_SHIPPING_ADDRESS1, OOH_SHIPPING_ADDRESS2, OOH_SHIPPING_PLACE, OOH_SHIPPING_STATE, OOH_SHIPPING_COUNTRY, OOH_SHIPPING_PINCODE, OOH_SHIPPING_MOBILE, OOH_SHIPPING_PHONE, OOH_SHIPPING_EMAIL, OOH_CUSTOMER_ID, OOH_CUSTOMER_NAME, OOH_CUSTOMER_ADDRESS_LINE1, OOH_CUSTOMER_ADDRESS_LINE2,OOH_CUSTOMER_CITY, OOH_CUSTOMER_STATE, OOH_CUSTOMER_PINCODE, OOH_CUSTOMER_COUNTRY, OOH_CUSTOMER_MOBILE, OOH_CUSTOMER_EMAIL, OOH_POS_PUSH_STATUS, OOH_CREATED_AT, OOH_UPDATED_AT, OOH_POS_TIMESTAMP, OOH_ONLINE_PUSH_STATUS, OOH_VENDOR) values (1262571076,123,pending,1,250.0,COD,11111,22222,sarathy nagar, Velachery,,Chennai,Tamil Nadu,India,600042,7639817688,null,gvpmahesh@gmail.com,33333,Vamsi g,sarathy nagar, Velachery,,Chennai,Tamil Nadu,600042,India,7639817688,gvpmahesh@gmail.com,pending,2015-08-21 06:12:47,2015-08-21 06:13:11,2000-01-01 12:00:00,0,SHOPIFY )

我正在使用statement.executeUpdate(sql) for execution。 // sql String我上面提到的
这是记录器输出

9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_ONLINE_REFERENCE_NO -- 1262571076 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SERVICE_USER_ID -- 123 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_ORDER_STATUS -- pending 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_TOTAL_QUANTITY -- 1 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_TOTAL_AMOUNT -- 250.0 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_PAYMENT_MODE -- COD 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_ID -- 11111 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_NAME -- 22222 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_ADDRESS1 -- sarathy nagar, Velachery 9 Sep, 2015 5:26:53 PM Hello getOrders WARNING: The shipping address2 can fail 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_ADDRESS2-- 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_PLACE -- Chennai 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_STATE -- Tamil Nadu 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_COUNTRY -- India 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_PINCODE -- 600042 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_MOBILE -- 7639817688 9 Sep, 2015 5:26:53 PM Hello getOrders WARNING: This can fail 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_PHONE -- null 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_SHIPPING_EMAIL -- gvpmahesh@gmail.com 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_ID -- 33333 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_NAME --Vamsi g 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_ADDRESS_LINE1 -- sarathy nagar, Velachery 9 Sep, 2015 5:26:53 PM Hello getOrders WARNING: This may fail 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_ADDRESS_LINE2 -- 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_CITY -- Chennai 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_STATE -- Tamil Nadu 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_PINCODE -- 600042 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_COUNTRY -- India 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_MOBILE -- 7639817688 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_CUSTOMER_EMAIL -- gvpmahesh@gmail.com 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_POS_PUSH_STATUS -- pending 9 Sep, 2015 5:26:53 PM Hello getOrders SEVERE: OOH_CREATED_AT -- 2015-08-21 06:12:47 9 Sep, 2015 5:26:53 PM Hello getOrders SEVERE: OOH_UPDATED_AT -- 2015-08-21 06:13:11 9 Sep, 2015 5:26:53 PM Hello getOrders SEVERE: OOH_POS_TIMESTAMP -- 2000-01-01 12:00:00 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_ONLINE_PUSH_STATUS -- 0 9 Sep, 2015 5:26:53 PM Hello getOrders INFO: OOH_VENDOR -- SHOPIFY

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

尝试在连接上将自动提交设置为true:

    connection.setAutoCommit(true);