datax 3.0连接不上数据库

问题:
   按照模板改写后,就是报连接不上数据库

原因一:DataX使用的mysql驱动包
解决:
1.替换 datax\plugin\reader\mysqlreader\libs\mysql-connector-java-5.1.34.jar 为mysql-connector-java-8.0.18.jar
  下载地址:https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-8.0.18.zip

原因二:job文件改写错误
    正确示例如下:(注意表名,数据名修改为你定义的名字,jdbc问号后的参数必须带,不然可能报错

{
    "job": {
        "setting": {
            "speed": {
                 "channel": 3
            },
            "errorLimit": {
                "record": 0,
                "percentage": 0.02
            }
        },
        "content": [
            {
                "reader": {
                    "name": "mysqlreader",
                    "parameter": {
                        "username": "root",
                        "password": "mysql",
                        "column": [
                            "id",
                            "name"

                        ],
                        "connection": [
                            {
                                "table": ["表名"],
                                "jdbcUrl": ["jdbc:mysql://127.0.0.1:3306/数据库名?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8"]
                            }
                        ]
                    }
                },
               "writer": {
                    "name": "mysqlwriter",
                    "parameter": {
                        "writeMode": "insert",
                        "username": "root",
                        "password": "mysql",
                        "column": [
                            "id",
                            "name"
                        ],
                        "session": [],
                        "connection": [
                            {
                                "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/数据库名?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8",
                                "table": ["表名"]
                            }
                        ]
                    }
                }
            }
        ]
    }
}

 

你可能感兴趣的:(数据库操作)