SimpleJdbcInsert to table with dot in name - java

I am trying to use SimpleJdbcInsert to a table that happens to have a dot character in its name with dbo as default schema. I pass in a map of key values to be inserted.
insertMessage = new SimpleJdbcInsert(dataSource).withTableName("Trades.Transaction");
insertMessage.execute((Map)message);
The following exception appears:
PreparedStatementCallback; bad SQL grammar [INSERT INTO Trades.Transaction (Uid, StreamId, Version, ValidFrom, ValidTo, IsLatest, Direction, Quantity, Notional, TradeDate, Status, Action, SettlementAmount, SettlementCurrency, AccruedInterest, BookingAccountType, BookingAccountUid, BookingAccountName, BookingAccountLegalEntityId, BookingAccountLegalEntityShortName, BookingAccountRepUid, BookingAccountRepName, BookingAccountFacilitatorUid, BookingAccountFacilitatorName, BookingAccountFacilitatorTeamCode, ContraAccountType, ContraAccountUid, ContraAccountName, ContraAccountLegalEntityId, ContraAccountLegalEntityShortName, ContraAccountRepUid, ContraAccountRepName, ContraAccountFacilitatorUid, ContraAccountFacilitatorName, ContraAccountFacilitatorTeamCode, FacingAccountType, FacingAccountUid, FacingAccountName, FacingAccountLegalEntityId, FacingAccountLegalEntityShortName, FacingAccountRepUid, FacingAccountRepName, FacingAccountFacilitatorUid, FacingAccountFacilitatorName, FacingAccountFacilitatorTeamCode, OrigSystemIsElectronicChannel, OrigSystem, OrigSystemUid, OrigSystemStatus, OrigSystemType, OrigSystemVersion, OrigSystemErrors, DestSystemUid, DestSystem, DestSystemStatus, DestSystemType, DestSystemVersion, DestSystemErrors, StpSystemUid, StpSystem, StpSystemStatus, StpSystemType, StpSystemVersion, StpSystemErrors, GatewaySystem, GatewaySystemStatus, GatewaySystemType, GatewaySystemVersion, GatewaySystemErrors, SettlementSystemUid, SettlementSystemName, SettlementSystemStatus, SettlementSystemType, SettlementSystemVersion, SettlementSystemErrors, TransactionType, Price, Obligor, Receiver, QuoteDate, EffectiveDate, MaturityDate, UnitSize, MatchedStatus, MatchedTradeId, InstrumentDescription, BookingFacilitatorTeamCode, FxClientRate, Principal, AccruedDays, SalesCommissionCode, SalesCommissionAmount, SalesCommissionRate, SalesCommissionCcy, BrokerCommissionCode, BrokerCommissionAmount, BrokerCommissionRate, BrokerCommissionCcy, MarkupCommissionCode, MarkupCommissionAmount, MarkupCommissionRate, MarkupCommissionCcy, AddOnCommissionCode, AddOnCommissionAmount, AddOnCommissionRate, AddOnCommissionCcy, PhoneConfirmInd, PhoneConfirmBy, PhoneConfirmOn, SalesManagerReview, SalesManagerReviewComments, SalesManagerReviewTime, SalesManagerReviewIndicator, TradeManagerReview, TradeManagerReviewComments, TradeManagerReviewTime, TradeManagerReviewIndicator, EnteredOn, UpdatedOn, EnteredBy, GatewaySystemUid, OrigSystemNote1, OrigSystemNote2, OrigSystemNote3, DestSystemNote1, DestSystemNote2, DestSystemNote3, GatewayAllocFlag, QuotedAmount, LastModifiedBy, OrigTransactionId, OrigMarkitWireId, ContraAccountGlobalBook, BookingAccountGlobalBook, FXSettleAmount, SettlementLocation, AssignmentFeeCd, AssignmentFeeDesc, RiskFlagCd, RiskFlagDesc, FormPurchaseCd, FormPurchaseDesc, AccruedInterestCd, AccruedInterestDesc, EcnName, EcnId, ContraAccountLocation, BookingAccountLocation, isSuppressTrade, ContraAccountTradingSystem, BookingAccountTradingSystem, isAmend, RetailCommissionCode, RetailCommissionAmount, RetailCommissionRate, RetailCommissionCcy, ContraAccountADPAccountNo, AsOfTime, ClientCommission, MarketRate, DayCount, ExecutionStatus, LinkStreamId, Spread, RfqId, isWashGen, FxRateCurrencyPair, FxRateCalcMethod, isApprovedForNewIssueAllocation, TransactionReservationId, isEligibleForTradeSync) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is java.sql.SQLException: Incorrect syntax near the keyword 'Transaction'.
I believe I need a way to surround Trade.Transaction with [ ] characters so it interprets that as complete table name instead of schema.tableName. However, if I specify those in the table name like below
insertMessage = new SimpleJdbcInsert(dataSource).withTableName("[Trades.Transaction]");
a Spring exception occurs stating it can't find meta data and hence can't find column names to generate insert statement.
Does anyone know how I can resolve this?
Thanks

Related

Java Hibernate generating number of select queries while saving the data into Database

Hibernate: select bsp_e_tick0_.primary_doc_number as primary_1_50_0_, bsp_e_tick0_.account_code1 as account_2_50_0_, bsp_e_tick0_.accounting_code as accounti3_50_0_, bsp_e_tick0_.agency_billing_number as agency_b4_50_0_, bsp_e_tick0_.check_digit as check_di5_50_0_, bsp_e_tick0_.coupon_text as coupon_t6_50_0_, bsp_e_tick0_.currency_override as currency7_50_0_, bsp_e_tick0_.current_status as current_8_50_0_, bsp_e_tick0_.current_status_1 as current_9_50_0_, bsp_e_tick0_.destination_city as destina10_50_0_, bsp_e_tick0_.doc_number as doc_num11_50_0_, bsp_e_tick0_.eda_load_datetime as eda_loa12_50_0_, bsp_e_tick0_.electronic_misc_type as electro13_50_0_, bsp_e_tick0_.electronic_misc_type_1 as electro14_50_0_, bsp_e_tick0_.even_exchange_waive as even_ex15_50_0_, bsp_e_tick0_.exchange_category as exchang16_50_0_, bsp_e_tick0_.exchange_transaction_date as exchang17_50_0_, bsp_e_tick0_.exchange_transaction_datetime as exchang18_50_0_, bsp_e_tick0_.exchange_transaction_type as exchang19_50_0_, bsp_e_tick0_.f0_ as f20_50_0_, bsp_e_tick0_.fare_calculation_mode as fare_ca21_50_0_, bsp_e_tick0_.form_number as form_nu22_50_0_, bsp_e_tick0_.frequent_flyer_provider as frequen23_50_0_, bsp_e_tick0_.inclusive_transaction as inclusi24_50_0_, bsp_e_tick0_.international_sale_indicator as interna25_50_0_, bsp_e_tick0_.invoice_number as invoice26_50_0_, bsp_e_tick0_.iso_country_code as iso_cou27_50_0_, bsp_e_tick0_.itinerary_type as itinera28_50_0_, bsp_e_tick0_.last_update_datetime as last_up29_50_0_, bsp_e_tick0_.local_issue_datetime as local_i30_50_0_, bsp_e_tick0_.offer_type_code as offer_t31_50_0_, bsp_e_tick0_.origin_city as origin_32_50_0_, bsp_e_tick0_.pnr_locator_id as pnr_loc33_50_0_, bsp_e_tick0_.price_check_digit as price_c34_50_0_, bsp_e_tick0_.price_code as price_c35_50_0_, bsp_e_tick0_.primary_doc_indicator as primary36_50_0_, bsp_e_tick0_.reason_description as reason_37_50_0_, bsp_e_tick0_.reason_for_issue as reason_38_50_0_, bsp_e_tick0_.reason_type as reason_39_50_0_, bsp_e_tick0_.reservation_provider as reserva40_50_0_, bsp_e_tick0_.sequence_number as sequenc41_50_0_, bsp_e_tick0_.serial_number as serial_42_50_0_, bsp_e_tick0_.service_type as service43_50_0_, bsp_e_tick0_.settlement_authorization as settlem44_50_0_, bsp_e_tick0_.statistical_code as statist45_50_0_, bsp_e_tick0_.system_provider as system_46_50_0_, bsp_e_tick0_.tcn as tcn47_50_0_, bsp_e_tick0_.ticket_system_datetime as ticket_48_50_0_, bsp_e_tick0_.ticket_type as ticket_49_50_0_, bsp_e_tick0_.ticketing_mode as ticketi50_50_0_, bsp_e_tick0_.ticketing_provider as ticketi51_50_0_, bsp_e_tick0_.tour_number as tour_nu52_50_0_, bsp_e_tick0_.transaction_id as transac53_50_0_, bsp_e_tick0_.transaction_type as transac54_50_0_, bsp_e_tick0_.validating_number as validat55_50_0_, bsp_e_tick0_.validating_provider as validat56_50_0_, bsp_e_tick0_.waiver_code as waiver_57_50_0_, bsp_e_tick0_.waiver_indicator as waiver_58_50_0_ from bsp_e_ticket_good bsp_e_tick0_ where bsp_e_tick0_.primary_doc_number=?
Hibernate: insert into bsp_e_ticket_good (account_code1, accounting_code, agency_billing_number, check_digit, coupon_text, currency_override, current_status, current_status_1, destination_city, doc_number, eda_load_datetime, electronic_misc_type, electronic_misc_type_1, even_exchange_waive, exchange_category, exchange_transaction_date, exchange_transaction_datetime, exchange_transaction_type, f0_, fare_calculation_mode, form_number, frequent_flyer_provider, inclusive_transaction, international_sale_indicator, invoice_number, iso_country_code, itinerary_type, last_update_datetime, local_issue_datetime, offer_type_code, origin_city, pnr_locator_id, price_check_digit, price_code, primary_doc_indicator, reason_description, reason_for_issue, reason_type, reservation_provider, sequence_number, serial_number, service_type, settlement_authorization, statistical_code, system_provider, tcn, ticket_system_datetime, ticket_type, ticketing_mode, ticketing_provider, tour_number, transaction_id, transaction_type, validating_number, validating_provider, waiver_code, waiver_indicator, primary_doc_number) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select bsp_e_tick0_.primary_doc_number as primary_1_50_0_, bsp_e_tick0_.account_code1 as account_2_50_0_, bsp_e_tick0_.accounting_code as accounti3_50_0_, bsp_e_tick0_.agency_billing_number as agency_b4_50_0_, bsp_e_tick0_.check_digit as check_di5_50_0_, bsp_e_tick0_.coupon_text as coupon_t6_50_0_, bsp_e_tick0_.currency_override as currency7_50_0_, bsp_e_tick0_.current_status as current_8_50_0_, bsp_e_tick0_.current_status_1 as current_9_50_0_, bsp_e_tick0_.destination_city as destina10_50_0_, bsp_e_tick0_.doc_number as doc_num11_50_0_, bsp_e_tick0_.eda_load_datetime as eda_loa12_50_0_, bsp_e_tick0_.electronic_misc_type as electro13_50_0_, bsp_e_tick0_.electronic_misc_type_1 as electro14_50_0_, bsp_e_tick0_.even_exchange_waive as even_ex15_50_0_, bsp_e_tick0_.exchange_category as exchang16_50_0_, bsp_e_tick0_.exchange_transaction_date as exchang17_50_0_, bsp_e_tick0_.exchange_transaction_datetime as exchang18_50_0_, bsp_e_tick0_.exchange_transaction_type as exchang19_50_0_, bsp_e_tick0_.f0_ as f20_50_0_, bsp_e_tick0_.fare_calculation_mode as fare_ca21_50_0_, bsp_e_tick0_.form_number as form_nu22_50_0_, bsp_e_tick0_.frequent_flyer_provider as frequen23_50_0_, bsp_e_tick0_.inclusive_transaction as inclusi24_50_0_, bsp_e_tick0_.international_sale_indicator as interna25_50_0_, bsp_e_tick0_.invoice_number as invoice26_50_0_, bsp_e_tick0_.iso_country_code as iso_cou27_50_0_, bsp_e_tick0_.itinerary_type as itinera28_50_0_, bsp_e_tick0_.last_update_datetime as last_up29_50_0_, bsp_e_tick0_.local_issue_datetime as local_i30_50_0_, bsp_e_tick0_.offer_type_code as offer_t31_50_0_, bsp_e_tick0_.origin_city as origin_32_50_0_, bsp_e_tick0_.pnr_locator_id as pnr_loc33_50_0_, bsp_e_tick0_.price_check_digit as price_c34_50_0_, bsp_e_tick0_.price_code as price_c35_50_0_, bsp_e_tick0_.primary_doc_indicator as primary36_50_0_, bsp_e_tick0_.reason_description as reason_37_50_0_, bsp_e_tick0_.reason_for_issue as reason_38_50_0_, bsp_e_tick0_.reason_type as reason_39_50_0_, bsp_e_tick0_.reservation_provider as reserva40_50_0_, bsp_e_tick0_.sequence_number as sequenc41_50_0_, bsp_e_tick0_.serial_number as serial_42_50_0_, bsp_e_tick0_.service_type as service43_50_0_, bsp_e_tick0_.settlement_authorization as settlem44_50_0_, bsp_e_tick0_.statistical_code as statist45_50_0_, bsp_e_tick0_.system_provider as system_46_50_0_, bsp_e_tick0_.tcn as tcn47_50_0_, bsp_e_tick0_.ticket_system_datetime as ticket_48_50_0_, bsp_e_tick0_.ticket_type as ticket_49_50_0_, bsp_e_tick0_.ticketing_mode as ticketi50_50_0_, bsp_e_tick0_.ticketing_provider as ticketi51_50_0_, bsp_e_tick0_.tour_number as tour_nu52_50_0_, bsp_e_tick0_.transaction_id as transac53_50_0_, bsp_e_tick0_.transaction_type as transac54_50_0_, bsp_e_tick0_.validating_number as validat55_50_0_, bsp_e_tick0_.validating_provider as validat56_50_0_, bsp_e_tick0_.waiver_code as waiver_57_50_0_, bsp_e_tick0_.waiver_indicator as waiver_58_50_0_ from bsp_e_ticket_good bsp_e_tick0_ where bsp_e_tick0_.primary_doc_number=?
Hibernate: insert into bsp_e_ticket_good (account_code1, accounting_code, agency_billing_number, check_digit, coupon_text, currency_override, current_status, current_status_1, destination_city, doc_number, eda_load_datetime, electronic_misc_type, electronic_misc_type_1, even_exchange_waive, exchange_category, exchange_transaction_date, exchange_transaction_datetime, exchange_transaction_type, f0_, fare_calculation_mode, form_number, frequent_flyer_provider, inclusive_transaction, international_sale_indicator, invoice_number, iso_country_code, itinerary_type, last_update_datetime, local_issue_datetime, offer_type_code, origin_city, pnr_locator_id, price_check_digit, price_code, primary_doc_indicator, reason_description, reason_for_issue, reason_type, reservation_provider, sequence_number, serial_number, service_type, settlement_authorization, statistical_code, system_provider, tcn, ticket_system_datetime, ticket_type, ticketing_mode, ticketing_provider, tour_number, transaction_id, transaction_type, validating_number, validating_provider, waiver_code, waiver_indicator, primary_doc_number) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select bsp_e_tick0_.primary_doc_number as primary_1_50_0_, bsp_e_tick0_.account_code1 as account_2_50_0_, bsp_e_tick0_.accounting_code as accounti3_50_0_, bsp_e_tick0_.agency_billing_number as agency_b4_50_0_, bsp_e_tick0_.check_digit as check_di5_50_0_, bsp_e_tick0_.coupon_text as coupon_t6_50_0_, bsp_e_tick0_.currency_override as currency7_50_0_, bsp_e_tick0_.current_status as current_8_50_0_, bsp_e_tick0_.current_status_1 as current_9_50_0_, bsp_e_tick0_.destination_city as destina10_50_0_, bsp_e_tick0_.doc_number as doc_num11_50_0_, bsp_e_tick0_.eda_load_datetime as eda_loa12_50_0_, bsp_e_tick0_.electronic_misc_type as electro13_50_0_, bsp_e_tick0_.electronic_misc_type_1 as electro14_50_0_, bsp_e_tick0_.even_exchange_waive as even_ex15_50_0_, bsp_e_tick0_.exchange_category as exchang16_50_0_, bsp_e_tick0_.exchange_transaction_date as exchang17_50_0_, bsp_e_tick0_.exchange_transaction_datetime as exchang18_50_0_, bsp_e_tick0_.exchange_transaction_type as exchang19_50_0_, bsp_e_tick0_.f0_ as f20_50_0_, bsp_e_tick0_.fare_calculation_mode as fare_ca21_50_0_, bsp_e_tick0_.form_number as form_nu22_50_0_, bsp_e_tick0_.frequent_flyer_provider as frequen23_50_0_, bsp_e_tick0_.inclusive_transaction as inclusi24_50_0_, bsp_e_tick0_.international_sale_indicator as interna25_50_0_, bsp_e_tick0_.invoice_number as invoice26_50_0_, bsp_e_tick0_.iso_country_code as iso_cou27_50_0_, bsp_e_tick0_.itinerary_type as itinera28_50_0_, bsp_e_tick0_.last_update_datetime as last_up29_50_0_, bsp_e_tick0_.local_issue_datetime as local_i30_50_0_, bsp_e_tick0_.offer_type_code as offer_t31_50_0_, bsp_e_tick0_.origin_city as origin_32_50_0_, bsp_e_tick0_.pnr_locator_id as pnr_loc33_50_0_, bsp_e_tick0_.price_check_digit as price_c34_50_0_, bsp_e_tick0_.price_code as price_c35_50_0_, bsp_e_tick0_.primary_doc_indicator as primary36_50_0_, bsp_e_tick0_.reason_description as reason_37_50_0_, bsp_e_tick0_.reason_for_issue as reason_38_50_0_, bsp_e_tick0_.reason_type as reason_39_50_0_, bsp_e_tick0_.reservation_provider as reserva40_50_0_, bsp_e_tick0_.sequence_number as sequenc41_50_0_, bsp_e_tick0_.serial_number as serial_42_50_0_, bsp_e_tick0_.service_type as service43_50_0_, bsp_e_tick0_.settlement_authorization as settlem44_50_0_, bsp_e_tick0_.statistical_code as statist45_50_0_, bsp_e_tick0_.system_provider as system_46_50_0_, bsp_e_tick0_.tcn as tcn47_50_0_, bsp_e_tick0_.ticket_system_datetime as ticket_48_50_0_, bsp_e_tick0_.ticket_type as ticket_49_50_0_, bsp_e_tick0_.ticketing_mode as ticketi50_50_0_, bsp_e_tick0_.ticketing_provider as ticketi51_50_0_, bsp_e_tick0_.tour_number as tour_nu52_50_0_, bsp_e_tick0_.transaction_id as transac53_50_0_, bsp_e_tick0_.transaction_type as transac54_50_0_, bsp_e_tick0_.validating_number as validat55_50_0_, bsp_e_tick0_.validating_provider as validat56_50_0_, bsp_e_tick0_.waiver_code as waiver_57_50_0_, bsp_e_tick0_.waiver_indicator as waiver_58_50_0_ from bsp_e_ticket_good bsp_e_tick0_ where bsp_e_tick0_.primary_doc_number=?
Hibernate: insert into bsp_e_ticket_good (account_code1, accounting_code, agency_billing_number, check_digit, coupon_text, currency_override, current_status, current_status_1, destination_city, doc_number, eda_load_datetime, electronic_misc_type, electronic_misc_type_1, even_exchange_waive, exchange_category, exchange_transaction_date, exchange_transaction_datetime, exchange_transaction_type, f0_, fare_calculation_mode, form_number, frequent_flyer_provider, inclusive_transaction, international_sale_indicator, invoice_number, iso_country_code, itinerary_type, last_update_datetime, local_issue_datetime, offer_type_code, origin_city, pnr_locator_id, price_check_digit, price_code, primary_doc_indicator, reason_description, reason_for_issue, reason_type, reservation_provider, sequence_number, serial_number, service_type, settlement_authorization, statistical_code, system_provider, tcn, ticket_system_datetime, ticket_type, ticketing_mode, ticketing_provider, tour_number, transaction_id, transaction_type, validating_number, validating_provider, waiver_code, waiver_indicator, primary_doc_number) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
...
Like This it is generating for all elements
private void storeInBadTables(BSP_E_Ticket ticket) {
gson = new Gson();
String data = gson.toJson(ticket);
BSP_E_Ticket_Bad ticketBad = gson.fromJson(data, BSP_E_Ticket_Bad.class);
bsp_e_ticket_bad_repo.flush();
bsp_e_ticket_bad_repo.save(ticketBad);
}
ticketList = bsp_e_ticket_repo.findAll();

Java subsequent DB2 insertions -845 error

I am getting -845 SQL codes on a table insert:
nested exception is org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL
[INSERT INTO PIM30_POL_DETAILS VALUES(PREVIOUS VALUE FOR PIM_ORDER_ID_SEQ, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)];
SQL state [51035]; error code [-845]; DB2 SQL Error: SQLCODE=-845, SQLSTATE=51035, SQLERRMC=SHELTRU.PIM_ORDER_ID_SEQ, DRIVER=4.17.29; nested exception is com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-845, SQLSTATE=51035, SQLERRMC=SHELTRU.PIM_ORDER_ID_SEQ, DRIVER=4.17.29] with root cause
com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-845, SQLSTATE=51035, SQLERRMC=SHELTRU.PIM_ORDER_ID_SEQ, DRIVER=4.17.29
The Java code for this is:
#Transactional
public String insertIntoDatabase(final List<Policy> pols, final InspectionOrder order, final OrderReason reason){
String toReturn = PolicyDAO.transactionTemplate.execute(new TransactionCallback<String>() {
#Override
public String doInTransaction(TransactionStatus status) {
SqlParameterSource params = new BeanPropertySqlParameterSource(order);
PolicyDAO.namedParemeterJdbcTemplate.update(Queries.getInsertInspOrder(), params);
for(Policy p : pols){
params = new BeanPropertySqlParameterSource(p);
PolicyDAO.namedParemeterJdbcTemplate.update(Queries.getInsertPolDetails(), params);
}
return "Successfully ordered inspection(s)";
}
});
if(toReturn.equals("Successfully ordered inspection(s)")) return toReturn;
else return "Failed to order inspection(s)";
}
Both INSERT statements use a sequence, the first one uses NEXT VALUE FOR PIM_ORDER_ID_SEQ and the second one uses PREVIOUS VALUE FOR PIM_ORDER_ID_SEQ. I presume that the second insertion is being called before the first insertion is finished as I only get the error 5-10% of the time.
What can I do to combat this?

Year out of Range Exception

I am intermittently getting an exception while saving records in database. Trigerring re-save of the same object from UI works well but not sure why do I hit the exception first. ALl date fields are good. Has anyone encountered this issue ever?
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Could not execute JDBC batch update; uncategorized SQLException for SQL [insert into t_order (trade_id, product_type, trading_desk, trading_book, trader_portfolio, current_workflow_state, creation_date, trade_date, execution_time, last_modified_date, last_modified_by_sid, sales_desk_id, creator_desk_id, action, vcon_bbg_speed_dial, vcon_comments, vcon_id, vcon_status, marketer_comment, creator_sid, trader_sid, salesperson_sid, on_behalf_of_sid, cpty_id, cpty_client_code, cpty_qib_flag, instrument_id, factor, settlement_date, settlement_date_convention, linked_deal_id, price, notional, real_notional, principal, net_money, accrued_interest, price_mode, buy_sell, yield, grid_cv, total_cv, additonal_cv, markup, additional_cv_units, leg_type_string, issue_type, pair_off, client_clearing, settlement_method, invert_fx_flag, clean_price, fx_ccy, fx_rate, transaction_cost, fx_transaction_cost, fx_principal, fx_net_money, fx_accrued_interest, accrual_days, discount, revenue_cv_rate, revenue_bond_markup_rate, revenue_fx_rate, revenue_cv_total, revenue_bond_markup_total, revenue_fx_total, revenue_split_coverage, revenue_split_execution, fx_customer_branch, nack_message, trade_flat_flag, deal_region, sales_book, rdt_instrument_id, parent_transaction_id, order_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; SQL state [99999]; error code [17268]; Year out of range.; nested exception is java.sql.BatchUpdateException: Year out of range.
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:747)
at com.jpmorgan.salesone.traderouter.dao.DealDaoImpl.saveCashDeal(DealDaoImpl.java:29)
at com.jpmorgan.salesone.traderouter.dao.DealJSPBeanManager.saveNewCashDealBean(DealJSPBeanManager.java:106)

debugging SQL stored procedure call in java

Hi I have a Stored procedure call with around 30+ IN parameters. I need the know the values of the parameters which are in the call to the SP since I am getting incorrect results.
the call is something like this:
return "{call FORECASTS_PKG.GENERATE_FORECAST_TASK(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}";
I have currently set the breakpoint on the above statement. I see the individual parameters having the values, but wondering if the values are set properly since its wrong results. I am sure the order of the parameters matters here and the values must be set accordingly so that its in the same order as in the Database.
How do I see the values inside this call? I do the the XML reperesentation of the in the implemented toString() method but thats just printed in a different default order.
Once I see the values I can compare to the defeinition in the Database and see if the values are set in the correct order as expected.

SQLException - Generated keys not requested (MySQL)

I get this error when im making a new character to my game, in the CreateCharHandler it sends "saveToDb(false);" but when im ingame with another char i manually created i can saveToDb(true); with no error. please help, why is this happening?
http://i56.tinypic.com/oh1pn5.png
SaveToDb method http://pastebin.com/9sT5XBxp
line 3514 is:
ResultSet rs = ps.getGeneratedKeys();
Thanks in advance!
Your SQLException clearly states that:
You need to specify Statement.RETURN_GENERATED_KEYS to the
Statement.executeUpdate() or Connection.prepareStatement().
This can be achieved as follows (adding an additional value on Connection.prepareStatement() method):
String SQL = ""; //whatever my String is
PreparedStatement ps = connection.prepareStatement(SQL, Statement.RETURN_GENERATED_KEYS);
ps.setString(1, "value");
//Other necessary ps.setXXX() methods
//now update
ps.executeUpdate();
ResultSet rs = ps.getGeneratedKeys();
The Statement.RETURN_GENERATED_KEYS is key here.
Hope this helps!
PS: Useful resource.
#Charlie berg, since you prefer being lazy, I changed line 13 of your code to include the Statement.RETURN_GENERATED_KEYS:
ps = con.prepareStatement("INSERT INTO characters (level, fame, str, dex, luk, `int`, exp, hp, mp, maxhp, maxmp, sp, ap, gm, skincolor, gender, job, hair, face, map, meso, hpMpUsed, spawnpoint, party, buddyCapacity, messengerid, messengerposition, mountlevel, mounttiredness, mountexp, equipslots, useslots, setupslots, etcslots, monsterbookcover, watchedcygnusintro, vanquisherStage, dojopoints, lastDojoStage, finishedDojoTutorial, vanquisherKills, matchcardwins, matchcardlosses, matchcardties, omokwins, omoklosses, omokties, givenRiceCakes, partyquestitems, jailtime, accountid, name, world) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
Also, Statement class is of package java.sql (make sure you import correctly). :-)
Oracle Documents:
If there is no indication that auto-generated columns should be made
available for retrieval, a call to Statement.getGeneratedKeys will
return a null ResultSet.
You should explicitly tell to JDBC That you want generated keys.
like this:
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql,Statement.RETURN_GENERATED_KEYS);
or
conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
and then you can use getGeneratedKeys().

Categories

Resources