MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 求一将Excel的数据导到数据库中的程序,紧急待中

求一将Excel的数据导到数据库中的程序,紧急待中(5)

www.MyException.Cn  网友分享于:2013-01-31  浏览:17次

fs=null;
File f=new File(fileToBeRead);
if (f.exists())
f.delete();
return new ActionForward(mapping.getInput());
}





try
{ int intOrg=-3;
SimpleDateFormat df=new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss ");
Date curDate=new Date(System.currentTimeMillis());
String currentDate=df.format(curDate);
conn=DataBaseMgr.getSalesConnection();
Statement s=null; ///////////
// s=conn.createStatement();//////////
HSSFCell tempCell=null;

st=conn.prepareStatement( "insert into CMM_SHOP_IMPORT (orgid,shopid,shoplevel,checkdate,state,prodid,value,createuserid,createdate) values(?,?,?,?,?,?,?,?,?) ");
stmt=conn.prepareStatement( "select org_ID from SYS_organization where org_name=? ");
stmt1=conn.prepareStatement( "select sh_id from EB_shop where sh_name=? ");


numOfSheets=workbook.getNumberOfSheets();
for(int numSheets = 0; numSheets < numOfSheets; numSheets++)
{
if(null != workbook.getSheetAt(numSheets))
{
HSSFSheet aSheet = workbook.getSheetAt(numSheets);
for(int rowNumOfSheet = 1; rowNumOfSheet <=aSheet.getLastRowNum(); rowNumOfSheet++)

{
if(null != aSheet.getRow(rowNumOfSheet))
{
try{
aRow = aSheet.getRow(rowNumOfSheet);

short ps0=0,ps1=1,ps2=2,ps3=3,ps4=4;

cell0 =aRow.getCell(ps0);
cell1 =aRow.getCell(ps1);
cell2 =aRow.getCell(ps2);
cell3=aRow.getCell(ps3);
// cell4=aRow.getCell(ps4);
if ((cell0==null)&&(cell1==null)&&(cell2==null)){
continue;
}
// if (cell0!=null)
// checkDate=cell0.getStringCellValue().trim();
// else
// checkDate=null;
if (cell0!=null)
orgId=cell0.getStringCellValue().trim();
else
orgId= "-1 ";
if (cell1!=null)
shopId=cell1.getStringCellValue().trim();
else
shopId= "-1 ";

if (cell2!=null)
shopLevel=cell2.getStringCellValue().trim();
else
shopLevel= " ";



if (cell3!=null)
state=cell3.getStringCellValue();
else
state= " ";


stmt.setString(1,orgId);
rs=stmt.executeQuery();
if (rs.next()){
intOrg= rs.getInt( "org_id ");
}else
continue;

stmt1.setString(1,shopId);
rs=stmt1.executeQuery();
if (rs.next()){

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有