# 多数据源使用事物失效
本文作者:程序员飞云
# 出现问题
使用多数据源请求B数据库开启Transactional事物控制,导致读取不到数据库B的数据
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-00942: 表或视图不存在
### The error may exist in com/hmifo/modules/map/mapper/ShipVoyageMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id, ship_id, ship_num, voyage_type, ship_type, hl_codes_id, hl_name, contract_num, ys_contract_num, ysgs_name, gys_name, ship_linkman, telephone, start_port, end_port, plan_quantity, berth_maybe_time, anchorage_time, berth_time, load_start_time, load_end_time, departures_time, ship_state, remark, create_time, user_id, update_time, update_user_id, disable, zx_type, trade_type, parent_id, zyl, delivery_no, cd_linkman, cd_telephone, ysgs_id, gys_id, voyage, berth_name, working_pro, work_process, hatch, open_hatch, foreman, captain, visa_state, sb_codes, unit_price, sum_money, charge_state, grid_check_state, grid_start_time, grid_end_time, foreman_id, visa_time, gzs_telephone, gzs_state, gzs_time, sys_type, table_type_des, table_id, formid, inputcode, is_virtual, type, sale_class_no, prodclassno, voyage_no, sum_money_zxf, charge_state_zxf, gang_hang_dj_ship_id, print_state, print_gate_state, print_cpmxqd_state, load_boats_no, work_state, hui_zhi_dan_state, default_measuring, goods_quantity, longitude, latitude, photo_url, arrival_time, confluence_state, confluence_no, confluence_time, confluence_user_id, belt_unload_state, belt_unload_time, belt_unload_weight, is_fgzy, issue_no FROM ZT.SHIP_VOYAGE WHERE disable = 0 AND (ship_type = ? AND ship_state = ? AND zx_type = ? AND voyage_type = ?)
### Cause: java.sql.SQLSyntaxErrorException: ORA-00942: 表或视图不存在
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: 表或视图不存在
', 'SQLErrorCodeSQLExceptionTranslator.java' , 239, 'hm-api', '172.16.218.16:80', 'LAPTOP-MBNRQP2U', 'dev' , 'org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator', 'doTranslate', 'scheduler', TIMESTAMP '2024-10-22 10:06:04.314')
Execute Time: 124.365ms
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
# 参考网址
@Transactional和@DS避免数据源冲突及保证原子性的解决方案(提供gitee源码) (opens new window)