我目前正在尝试通过实体管理器将csv文件加载到MySQL数据库中。
请参阅以下代码:
public void CsvLoad(String name, Environment env) throws SQLException {
int r = getEntityManager(env).createNativeQuery("LOAD DATA LOCAL INFILE '" + name + "' INTO TABLE gabstar.tblladetails FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' IGNORE 1 LINES (@UPRN, @Address, @PostCode, @Lat_Long, @region, @Scheme, @Estate, @LocalAuthority, @Bedrooms, @PropertyType, @AssetType, @TenureType, @HousingOffice, @EmptyDays, @Date, @Month, @Year, @GrantLiability, @RentperWeek, @BookValue, @BudgetIncome, @BudgetVoids, @BudgetMajorRepair, @BudgetMaintenance, @BudgetServiceCharge, @BudgetBadDebt, @BudgetManagementCost) \n" +
"SET ID = NULL, \n" +
"UPRN = @UPRN, Address = @Address, PostCode = @PostCode, Lat_Long = @Lat_Long, region = @region, Scheme = @Scheme, LocalAuthority = @LocalAuthority, Bedrooms = @Bedrooms, PropertyType = @PropertyType, AssetType = @AssetType, TenureType = @TenureType,HousingOfficer = @HousingOfficer, EmptyDays = @EmptyDays, Date = @Date, Month = @Month, Year = @Year, GrantLiability = @GrantLiability, RentperWeek = @RentperWeek, BookValue = @BookValue, BudgetIncome = @BudgetIncome, BudgetVoids = @BudgetVoids, BudgetMajorRepair = @BudgetMajorRepair, BudgetMaintenance = @BudgetMaintenance, BudgetServiceCharge = @BudgetServiceCharge, BudgetBadDebt = @BudgetBadDebt, BudgetManagementCosts = @BudgetManagementCosts"
).executeUpdate() ;
}
现在我遇到的问题是我正在尝试返回来自文件的错误消息,但它确实会创建任何异常,即使我知道CSV文件不正确。
我该怎么做?
我基本上想要使用MySQL工作台获得的错误消息。