简体   繁体   中英

Not able to persist Spark data set to orientdb

I am trying to fetch data from sql server database and created a spark dataset. When i persisting dataset to orientdb, not able to do that.

Getting below error

Exception in thread "main" java.lang.RuntimeException: Connection Exception Occurred: Error on opening database 'jdbc:orient:REMOTE:localhost/test'

Here is my code:

    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();

At the moment of writing the orientdb's jdbc driver isn't able to persist a spark dataset. It should be patched to improve shark compatibility . It is, although, able to read from orientdb and load a dataset. Please open an issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM