我正在尝试从数据中解析信息并使用 JDBC 将其插入数据库。但是,尝试这样做时出现java.lang.parseInt(UnknownSource)错误。以下是我整理的代码:
public void testAddStation(String r){
long st = System.currentTimeMillis();
String str = r;
String row[]= str.split(",");
Station s = new Station();
s.setPrimaryID(row[0]);
s.setSecondaryID(row[1]);
s.setStationName(row[2]);
s.setState(row[3]);
s.setCountry(row[4]);
s.setLatitude(Double.parseDouble(row[5]));
s.setLongitude(Double.parseDouble(row[6]));
s.setElevation(Double.parseDouble(row[7]));
s.setMesoNetID(row[8]);
s.setNetworkName(row[9]);
s.setStatus(row[10]);
s.setPrimaryProviderId(Integer.parseInt(row[11]));
s.setPrimaryProvider(row[12]);
s.setSecondaryProviderId(Integer.parseInt(row[13]));
s.setSecondaryProvider(row[14]);
s.setTertiaryProviderId(Integer.parseInt(row[15]));
s.setTertiaryProvider(row[16]);
s.setWims_Id(row[17]);
//System.out.println(s.getStationName());
//System.out.println(s.getPrimaryID());
rep.addStation(s);
N=N+1;
long et = System.currentTimeMillis();
System.out.println("total station created: " + N + "\tinsert per row: "+(et - st));
}
以下是我在控制台窗口中收到的错误消息:
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at karki.jdbc.repo.Check.testAddStation(Check.java:40)
at karki.jdbc.repo.CSVFile.readCSV(CSVFile.java:36)
at karki.jdbc.repo.CSVFile.listFiles(CSVFile.java:20)
at karki.jdbc.repo.CSVFile.listStationCSV(CSVFile.java:59)
at karki.jdbc.repo.CSVFile.main(CSVFile.java:82)
谁能解释一下我在这里可能做错了什么?