[英]Create DataSet From JDBC Source in Flink using Scala
我正在嘗試使用 Flink 中的 Scala 從 JDBC 源創建數據集,所有文檔/其他 SO 問題似乎都使用 Java。 我在泛型類型方面遇到了一些問題。
到目前為止,我有:
val inputFormat = JDBCInputFormat.buildJDBCInputFormat()
.setDrivername(driver)
.setDBUrl(url)
.setUsername(username)
.setPassword(password)
.setQuery("select col_a,col_b from my_table")
.finish()
env.createInput(inputFormat)
這給出了一個錯誤:
error: could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[?0]
env.createInput(inputFormat)
我也試過
var tuple = ("",0)
inputFormat.nextRecord(tuple)
這給出了錯誤:
error: type mismatch;
found : (String, Int)
required: ?0
最后我試過:
inputFormat.nextRecord(_)
這導致:
found : x$1.type (with underlying type ?0)
required: ?0
所以問題是如何使用Scala在Flink中設置JDBC連接/我錯在哪里?
解決第一個問題:
error: could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[?0]
env.createInput(inputFormat)
您需要添加以下導入語句
import org.apache.flink.api.scala._
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.