我正在尝试从 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();