Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

模式名为空 #19

Closed
wangfujungit opened this issue Jul 2, 2016 · 2 comments
Closed

模式名为空 #19

wangfujungit opened this issue Jul 2, 2016 · 2 comments
Labels

Comments

@wangfujungit
Copy link

流程是这样的

  1. 新建表ORACLE
    CREATE TABLE "XT_BASECOURSE" (
    "COURSE_ID" NUMBER(16) NOT NULL ,
    "NAME" NVARCHAR2(150) NULL ,
    "SORT_NUM" NUMBER NULL ,
    "DESCRIPTION" NVARCHAR2(1000) NULL ,
    "CREATE_TIME" DATE NULL ,
    "UPDATE_TIME" DATE NULL ,
    "CREATE_USER" NUMBER(16) NULL ,
    "UPDATE_USER" NUMBER(16) NULL
    )tablespace UECHNDB;
    2.插入表
    INSERT INTO "XT_BASECOURSE" VALUES ('1', '语文', '1', null, null, null, null, null);
    INSERT INTO "XT_BASECOURSE" VALUES ('2', '数学', '2', null, null, null, null, null);
    3.新建表MYSQL
    DROP TABLE IF EXISTS T_BASE_COURSE;
    CREATE TABLE T_BASE_COURSE (
    BASE_COURSE_ID int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    BASE_COURSE_NAME varchar(32) DEFAULT NULL COMMENT '名称',
    SORT_NUM smallint(2) unsigned DEFAULT NULL COMMENT '排序',
    CREATE_TIME datetime DEFAULT NULL COMMENT '创建时间',
    PRIMARY KEY (BASE_COURSE_ID)
    ) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COMMENT='基础学科';
    4.配制文件
    yugong.database.source.username=uechn2_db
    yugong.database.source.password=123
    yugong.database.source.type=ORACLE
    yugong.database.source.url=jdbc:oracle:thin:@192.168.*.21:1521:orcl
    yugong.database.source.encode=UTF-8
    yugong.database.source.poolSize=30

yugong.database.target.url=jdbc:mysql://192.168.*.204:3306/ue
yugong.database.target.username=root
yugong.database.target.password=root
yugong.database.target.type=MYSQL
yugong.database.target.encode=UTF-8
yugong.database.target.poolSize=30

yugong.table.white=uechn2_db.XT_BASECOURSE

5.XTBASECOURSEDataTranslator.java
public class XTBASECOURSEDataTranslator extends AbstractDataTranslator implements DataTranslator {

public boolean translator(Record record) {
    // 1. schema/table名不同
     record.setSchemaName("ue");
    record.setTableName("T_BASE_COURSE");
    // 源表为XT_BASECOURSE,目标表为T_BASE_COURSE

6.结果:/usr/local/yugong/conf/translator/table.log
[YuGongInstance-UECHN2_DB.XT_BASECOURSE] ERROR com.taobao.yugong.controller.YuGongInstance - retry 1 ,something error happened. caused by java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.taobao.yugong.exception.YuGongException: table[null.XT_BASECOURSE] is not found

@spidersq
Copy link
Contributor

spidersq commented Jul 2, 2016

XTBASECOURSEDataTranslator 类名不对,没找到类,所以自定义的转换没有生效。
根据你的表名,应该是XtBasecourse 或者XtBasecourseDataTranslator 才行

@agapple
Copy link
Member

agapple commented Jul 4, 2016

楼上理解正确

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants