[英]Spark JDBC SQLException
我一直在獲取SQLException,但我懷疑這不是問題。 表是:
create table person (first varchar(30) DEFAULT NULL, last varchar(30) DEFAULT NULL, gender char(1) DEFAULT NULL, age tinyint(4) DEFAULT NULL);
插入語句:
insert into person values('Barack','Obama','M',54);
insert into person values('Hillary','Clinton','f',34);
火花代碼:
public static void main(String[] args) {
SparkConf conf = new SparkConf().setAppName("Stackoverflow")
.setMaster("local[4]");
JavaSparkContext sc = new JavaSparkContext(conf);
SQLContext sqlContext = new SQLContext(sc);
Map<String, String> options = new HashMap<>();
options.put("url", "jdbc:mariadb://localhost:3306/persondb");
options.put("user", "user");
options.put("password", "password333");
options.put("dbtable", "(select * from person where gender = 'M') as someone");
DataFrame jdbcDF = sqlContext.read().format("jdbc"). options(options).load();
jdbcDF.show();
錯誤:
Exception in thread "main" org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 0.0 failed 1 times, most recent failure: Lost task 0.0 in stage 0.0 (TID 0, localhost): java.sql.SQLException: Out of range value for column 'age' : value age is not in Integer range
我嘗試更改表stmt(@jmj):
create table person (first varchar(30) DEFAULT NULL, last varchar(30) DEFAULT NULL, gender char(1) DEFAULT NULL, age int DEFAULT NULL);
然后它可以用於某些查詢,但大多數情況下都可以:
Caused by: java.sql.SQLException: Out of range value for column 'age' : value age is not in Integer range
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.