跑步时我遇到错误
java.sql.SQLException:无法转换为内部表示。从数据库读取数据并在xls文件中写入时获取此信息。
HSSFWorkbook workbook = new HSSFWorkbook(); // creating a workbook
HSSFSheet spreadsheet = workbook.createSheet("non_unified"); // creating sheet in workbook named non_unified
HSSFRow row=spreadsheet.createRow(0); // creating rows
HSSFCell cell; // creating cells of each row
cell=row.createCell((short) 0);
cell.setCellValue("AIRLINE");
cell=row.createCell((short) 1);
cell.setCellValue("CLASS_CODE");
cell=row.createCell((short) 2);
cell.setCellValue("CLASS_NAME");
cell=row.createCell((short) 3);
cell.setCellValue("MEAL_TYPE");
cell=row.createCell((short) 4);
cell.setCellValue("MEAL_TYPE_NAME");
cell=row.createCell((short) 5);
cell.setCellValue("SPML_CODE");
cell=row.createCell((short) 6);
cell.setCellValue("SPML_NAME");
cell=row.createCell((short) 7);
cell.setCellValue("SPML_SUBCODE_CODE");
cell=row.createCell((short) 8);
cell.setCellValue("SPML_SUBCODE_NAME");
cell=row.createCell((short) 9);
cell.setCellValue("MATERIAL_NBR");
cell=row.createCell((short) 10);
cell.setCellValue("MATERIAL_NAME");
cell=row.createCell((short) 11);
cell.setCellValue("EFF_DATE");
cell=row.createCell((short) 12);
cell.setCellValue("EXP_DATE");
cell=row.createCell((short) 13);
cell.setCellValue("SERVICE_LEVEL");
cell=row.createCell((short) 14);
cell.setCellValue("CYCLE_NO");
cell=row.createCell((short) 15);
cell.setCellValue("HAULAGE_CODE");
cell=row.createCell((short) 16);
cell.setCellValue("SALES_ORG_CODE");
cell=row.createCell((short) 17);
cell.setCellValue("PLANT_CODE");
cell=row.createCell((short) 18);
cell.setCellValue("SPML_ASSIGNMENT");
ResultSet rs = stmt.executeQuery("select * from V_SPML_ASSIGNMENT ");
int i=1;
while(rs.next()){ // setting value of each cell using database
HSSFRow rows= spreadsheet.createRow((short)i);
rows.createCell((short) 0).setCellValue(rs.getString("AIRLINE"));
rows.createCell((short) 1).setCellValue(rs.getString("CLASS_CODE"));
rows.createCell((short) 2).setCellValue(rs.getString("CLASS_NAME"));
rows.createCell((short) 3).setCellValue(rs.getInt("MEAL_TYPE"));
rows.createCell((short) 4).setCellValue(rs.getString("MEAL_TYPE_NAME"));
rows.createCell((short) 5).setCellValue(rs.getString("SPML_CODE"));
rows.createCell((short) 6).setCellValue(rs.getString("SPML_NAME"));
rows.createCell((short) 7).setCellValue(rs.getString("SPML_SUBCODE_CODE"));
rows.createCell((short) 8).setCellValue(rs.getInt("SPML_SUBCODE_NAME"));
rows.createCell((short) 9).setCellValue(Integer.toString(rs.getInt("MATERIAL_NBR")));
rows.createCell((short) 10).setCellValue(rs.getString("MATERIAL_NAME"));
rows.createCell((short) 11).setCellValue(rs.getString("EFF_DATE"));
rows.createCell((short) 12).setCellValue(rs.getString("EXP_DATE"));
rows.createCell((short) 13).setCellValue(rs.getInt("SERVICE_LEVEL"));
rows.createCell((short) 14).setCellValue(rs.getString("CYCLE_NO"));
rows.createCell((short) 15).setCellValue(rs.getString("HAULAGE_CODE"));
rows.createCell((short) 16).setCellValue(Integer.toString(rs.getInt("SALES_ORG_CODE")));
rows.createCell((short) 17).setCellValue(Integer.toString(rs.getInt("PLANT_CODE")));
rows.createCell((short) 18).setCellValue(Integer.toString(rs.getInt("SPML_ASSIGNMENT")));
i++;
}
FileOutputStream out = new FileOutputStream(new File("E:/Spml/exceldatabase.xls")); // creating a file to store
workbook.write(out); //writing into file