我正在尝试使用csvjdbc驱动程序从 csv 文件中选择不同的字段。我有一个 csv 表,如:
id departmentcode fte
223356 DS3G5530DK 1.0
234335 ES4K44343L 0.8
435331 GS2K54534P 1.0
...
我想将列导入为 Integer、String 和 Double,所以我创建了一个 Java.Util.Properties 对象并添加了列类型:
Properties props = new Properties();
props.put("columnTypes", "Integer,String,Double");
之后,我与属性对象建立连接并查询 csv:
Connection conn = DriverManager.getConnection("jdbc:relique:csv:" +getPath()+"/temp/", props);
ResultSet results = stmt.executeQuery("SELECT id, departmentcode, fte FROM tempCSV WHERE ...")
while (results.next()) {
...
System.out.println( results.getInt("id") );
System.out.println( results.getString("departmentcode") );
System.out.println( results.getDouble("fte") );
...
}
但是当我从我的结果中选择 DEPARTMENT-CODE 时,它始终是双精度 (0.0)。对于两者id
,fte
它都按预期进行(如id
int 和fte
double 一样)。我的属性对象有问题吗?