0

我正在尝试从 sql server 数据库中获取数据并创建了一个 spark 数据集。当我将数据集持久化到 orientdb 时,无法做到这一点。

低于错误

线程“主”java.lang.RuntimeException 中的异常:发生连接异常:打开数据库“jdbc:orient:REMOTE:localhost/test”时出错

这是我的代码:

    Map<String, String> options = new HashMap<>();
    options.put("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
    options.put("url", "jdbc:sqlserver://localhost:1433;databaseName=sample");
    options.put("user", "username");
    options.put("password", "password");    

    DataFrameReader jdbcDF = spark.read().format("jdbc").options(options);
    Dataset<Row> tableDataSet = jdbcDF.option("dbtable", "Table1").load();
    tableDataSet.createOrReplaceTempView("TEMP_V");
    Dataset<Row> tableDataset1 = spark.sql("SELECT ID AS DEPT_ID, NAME AS DEPT_NAME  FROM TEMP_V");        
    tableDataset1.write().format("org.apache.spark.orientdb.graphs")
            .option("dburl", "jdbc:orient:remote:localhost/test")
            .option("user", "root")
            .option("password", "root")
            .option("spark", "true")
            .option("vertextype", "DEPARTMENT")
            .mode(SaveMode.Overwrite)
            .save();
4

1 回答 1

0

在编写 orientdb 的 jdbc 驱动程序时,无法持久化 spark 数据集。应该对其进行修补以提高鲨鱼的兼容性。不过,它能够从 orientdb 读取并加载数据集。请打开一个问题。

于 2017-05-21T05:33:12.033 回答