原代码我全部写下面了我这里上传到服务器很慢一个28K的EXECL要20-30分钟才能传好。哪位达人帮我看看是哪里的问题!
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="java.lang.*,java.sql.*,java.util.*" %>
<%@ page import="java.io.*,jxl.*,jxl.read.*,jxl.write.*,jxl.format.*"%>
<%@ page import="com.jspsmart.upload.*"%>
<%String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";//1.加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//2.找开连接
String OracleURL = "jdbc:oracle:thin:@192.168.4.202:1521:ujpcn";
Connection conn=DriverManager.getConnection(OracleURL,"netcool","netcool");
//xxxx这里是数据库的用户名,****这里是数据库的密码。
//3.创建statement
Statement stat=conn.createStatement(); if( request.getParameter("loadfilename") != null) {
System.out.println("upload!");
SmartUpload uploadx = new SmartUpload();
System.out.println("upload! 1");
uploadx.initialize(pageContext);// 设定上传限制
//upload.setAllowedFilesList("xls");
System.out.println("upload! 2");
//upload.setDeniedFilesList("exe,bat,jsp,htm,html,,");// 设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。
uploadx.upload();// 上传文件
System.out.println("upload! 3");
int count = uploadx.save("/upload", uploadx.SAVE_VIRTUAL);// 将上传文件全部保存到指定目录
System.out.println("count!"+count);
/*
for (int i=0; i<uploadx.getFiles().getCount(); i++)// 逐一提取上传文件信息,同时可保存文件。
{
com.jspsmart.upload.File file = upload.getFiles().getFile(i);// 若文件不存在则继续
if (file.isMissing()) continue;// 显示当前文件信息
String strPath=request.getRealPath("");
strPath = strPath + "\\upload\\" + file.getFileName();
out.print(strPath);
}
*/
String sourcefile=(String)request.getParameter("loadfilename");
System.out.println("sourcefile!"+sourcefile);
InputStream is = new FileInputStream(sourcefile);
jxl.Workbook wb = Workbook.getWorkbook(is);
jxl.Sheet st = wb.getSheet(0);//得到工作薄中的第一个工作表
String delsql="delete from ChooseAddressee";
stat.executeQuery(delsql);
for (int i =1;i< st.getRows();i++)
{
Cell cell=st.getCell(0,i);
Cell cell1 = st.getCell(1,i);
String strc00 = cell.getContents();
String strc01 = cell1.getContents();
if (strc00 == ""){
}
else{
String insertsql="insert into ChooseAddressee values('"+strc00+"','"+strc01+"')";
ResultSet rs1 =stat.executeQuery(insertsql);
}
}
}if(request.getParameter("loadfilename1") != null){ String straddressee = null;
straddressee = request.getParameter("loadfilename1");
System.out.println(straddressee);
String form2 = null;
String iphone = null;
form2 = request.getParameter("loadfilename2");
String straddressee1= "";
String url ="jdbc:sybase:Tds:127.0.0.1:2638/sms";
//1.加载驱动
Class.forName("com.sybase.jdbc3.jdbc.SybDriver").newInstance();
//2.找开连接
String userName = "zyw";
String passWord = "zyw";
//xxxx这里是数据库的用户名,****这里是数据库的密码。
Connection conn1= DriverManager.getConnection(url,userName,passWord);
PreparedStatement stmt = null;
straddressee1=new String(straddressee.getBytes("iso-8859-1"),"gb2312");
System.out.println(straddressee1);
String[] a = straddressee1.split(","); for(int i = 0;i<a.length; i++){
ResultSet rs3 = stat.executeQuery("select ChooseAddresseePhone from ChooseAddressee where ChooseAddressee ='"+ a[i]+"'");
while(rs3.next()){
iphone = rs3.getString("ChooseAddresseePhone");
}
System.out.println(iphone);
stmt = conn1.prepareStatement("insert into status(Identifier,Summary,Contact,LinePhone,SMSSummary,SMSSeverity,Engineer1,Engineer1_Phone,Engineer2,Engineer2_Phone,Engineer3,Engineer3_Phone,Engineer4,Engineer4_Phone,Director,Director_Phone,Manager1,Manager1_Phone,Manager2,Manager2_Phone,Manager3,Manager3_Phone,OrgName,LastOccurrence) values('SMSTest "+ iphone + " INSERT','" +new java.util.Date()+ form2 + "','管理员','','"+ form2 +"','5','" + a[i] + "','"+iphone+"','管理员','','管理员','','管理员','','管理员','','管理员','','管理员','','管理员','','省行本部','"+ new java.util.Date()+"')");
stmt.executeUpdate();
}}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<base href="<%=basePath%>">
<title>自由短信发送页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<SCRIPT LANGUAGE=javascript>
<!--
function exit()
{
window.close();
}function checkExport()
{
var filename1 = document.form1.file.value;
alert(filename1);
if (filename1.length <= 0){
//alert(filename1);
alert("请选择文件");
}
else{
alert("upload@!");
document.form1.action = "index.jsp?loadfilename="+ filename1;
document.form1.submit();
}}
function show()
{
alert("dsss");
alert(form1.text.value);
var filename2 = form1.text.value;
var strshoujianren = "";
alert("dsss1");
if (filename2.length <= 0){
//alert(filename1);
alert("请输入内容");
return;
}
if (form1.s2.length <= 0)
{
alert("请选择收件人");
return;
}
for (var i = 0; i < form1.s2.length; i++)
{
if (1 == form1.s2.length)
{
strshoujianren = form1.s2.options[i].text;
}
else
{
if (i == form1.s2.length - 1)
{
strshoujianren += form1.s2.options[i].text;
}
else
{
strshoujianren += form1.s2.options[i].text + ",";
}
}
}
document.form1.action = "index.jsp?loadfilename1="+ strshoujianren +"&loadfilename2="+ filename2 ;
document.form1.submit();
}function transferItem(iDirect)
{
var oListLeft = document.all.s1;
var oListRight = document.all.s2;
if(iDirect<0) {
oListLeft =document.all.s2;
oListRight =document.all.s1;
}
iDirect = iDirect>0?iDirect:-1*iDirect;
for (var i=0;i<oListLeft.options.length;i++)
{ if ((iDirect ==1 && oListLeft.options[i].selected )|| iDirect ==2 )
{ var oldOp = oListLeft.options[i];
var newOp =
new Option(oldOp.text,oldOp.value);
oListRight.options.add(newOp); oListLeft.options[i] = null; i--; } }
checkButtonStatus();
}
function checkButtonStatus()
{ var oListLeft = document.all.s1;
var oListRight = document.all.s2;
var btn1 = document.all.btnLeft;
var btn2 = document.all.btnRight;
var btn3 = document.all.btnAllLeft;
var btn4 = document.all.btnAllRight;
// alert(bHaveCheckedOne(oListLeft));
btn1.disabled =!bHaveCheckedOne(oListRight);
btn2.disabled =!bHaveCheckedOne(oListLeft);
btn3.disabled =oListRight.options.length<=0;
btn4.disabled =oListLeft.options.length<=0; }
function bHaveCheckedOne(obj)
{ for(var i=0;i<obj.options.length;i++)
{ if(obj.options[i].selected)
{ return true; }
} return false;
} //-->
</SCRIPT>
<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="java.lang.*,java.sql.*,java.util.*" %>
<%@ page import="java.io.*,jxl.*,jxl.read.*,jxl.write.*,jxl.format.*"%>
<%@ page import="com.jspsmart.upload.*"%>
<%String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";//1.加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//2.找开连接
String OracleURL = "jdbc:oracle:thin:@192.168.4.202:1521:ujpcn";
Connection conn=DriverManager.getConnection(OracleURL,"netcool","netcool");
//xxxx这里是数据库的用户名,****这里是数据库的密码。
//3.创建statement
Statement stat=conn.createStatement(); if( request.getParameter("loadfilename") != null) {
System.out.println("upload!");
SmartUpload uploadx = new SmartUpload();
System.out.println("upload! 1");
uploadx.initialize(pageContext);// 设定上传限制
//upload.setAllowedFilesList("xls");
System.out.println("upload! 2");
//upload.setDeniedFilesList("exe,bat,jsp,htm,html,,");// 设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。
uploadx.upload();// 上传文件
System.out.println("upload! 3");
int count = uploadx.save("/upload", uploadx.SAVE_VIRTUAL);// 将上传文件全部保存到指定目录
System.out.println("count!"+count);
/*
for (int i=0; i<uploadx.getFiles().getCount(); i++)// 逐一提取上传文件信息,同时可保存文件。
{
com.jspsmart.upload.File file = upload.getFiles().getFile(i);// 若文件不存在则继续
if (file.isMissing()) continue;// 显示当前文件信息
String strPath=request.getRealPath("");
strPath = strPath + "\\upload\\" + file.getFileName();
out.print(strPath);
}
*/
String sourcefile=(String)request.getParameter("loadfilename");
System.out.println("sourcefile!"+sourcefile);
InputStream is = new FileInputStream(sourcefile);
jxl.Workbook wb = Workbook.getWorkbook(is);
jxl.Sheet st = wb.getSheet(0);//得到工作薄中的第一个工作表
String delsql="delete from ChooseAddressee";
stat.executeQuery(delsql);
for (int i =1;i< st.getRows();i++)
{
Cell cell=st.getCell(0,i);
Cell cell1 = st.getCell(1,i);
String strc00 = cell.getContents();
String strc01 = cell1.getContents();
if (strc00 == ""){
}
else{
String insertsql="insert into ChooseAddressee values('"+strc00+"','"+strc01+"')";
ResultSet rs1 =stat.executeQuery(insertsql);
}
}
}if(request.getParameter("loadfilename1") != null){ String straddressee = null;
straddressee = request.getParameter("loadfilename1");
System.out.println(straddressee);
String form2 = null;
String iphone = null;
form2 = request.getParameter("loadfilename2");
String straddressee1= "";
String url ="jdbc:sybase:Tds:127.0.0.1:2638/sms";
//1.加载驱动
Class.forName("com.sybase.jdbc3.jdbc.SybDriver").newInstance();
//2.找开连接
String userName = "zyw";
String passWord = "zyw";
//xxxx这里是数据库的用户名,****这里是数据库的密码。
Connection conn1= DriverManager.getConnection(url,userName,passWord);
PreparedStatement stmt = null;
straddressee1=new String(straddressee.getBytes("iso-8859-1"),"gb2312");
System.out.println(straddressee1);
String[] a = straddressee1.split(","); for(int i = 0;i<a.length; i++){
ResultSet rs3 = stat.executeQuery("select ChooseAddresseePhone from ChooseAddressee where ChooseAddressee ='"+ a[i]+"'");
while(rs3.next()){
iphone = rs3.getString("ChooseAddresseePhone");
}
System.out.println(iphone);
stmt = conn1.prepareStatement("insert into status(Identifier,Summary,Contact,LinePhone,SMSSummary,SMSSeverity,Engineer1,Engineer1_Phone,Engineer2,Engineer2_Phone,Engineer3,Engineer3_Phone,Engineer4,Engineer4_Phone,Director,Director_Phone,Manager1,Manager1_Phone,Manager2,Manager2_Phone,Manager3,Manager3_Phone,OrgName,LastOccurrence) values('SMSTest "+ iphone + " INSERT','" +new java.util.Date()+ form2 + "','管理员','','"+ form2 +"','5','" + a[i] + "','"+iphone+"','管理员','','管理员','','管理员','','管理员','','管理员','','管理员','','管理员','','省行本部','"+ new java.util.Date()+"')");
stmt.executeUpdate();
}}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>
<head>
<base href="<%=basePath%>">
<title>自由短信发送页面</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<SCRIPT LANGUAGE=javascript>
<!--
function exit()
{
window.close();
}function checkExport()
{
var filename1 = document.form1.file.value;
alert(filename1);
if (filename1.length <= 0){
//alert(filename1);
alert("请选择文件");
}
else{
alert("upload@!");
document.form1.action = "index.jsp?loadfilename="+ filename1;
document.form1.submit();
}}
function show()
{
alert("dsss");
alert(form1.text.value);
var filename2 = form1.text.value;
var strshoujianren = "";
alert("dsss1");
if (filename2.length <= 0){
//alert(filename1);
alert("请输入内容");
return;
}
if (form1.s2.length <= 0)
{
alert("请选择收件人");
return;
}
for (var i = 0; i < form1.s2.length; i++)
{
if (1 == form1.s2.length)
{
strshoujianren = form1.s2.options[i].text;
}
else
{
if (i == form1.s2.length - 1)
{
strshoujianren += form1.s2.options[i].text;
}
else
{
strshoujianren += form1.s2.options[i].text + ",";
}
}
}
document.form1.action = "index.jsp?loadfilename1="+ strshoujianren +"&loadfilename2="+ filename2 ;
document.form1.submit();
}function transferItem(iDirect)
{
var oListLeft = document.all.s1;
var oListRight = document.all.s2;
if(iDirect<0) {
oListLeft =document.all.s2;
oListRight =document.all.s1;
}
iDirect = iDirect>0?iDirect:-1*iDirect;
for (var i=0;i<oListLeft.options.length;i++)
{ if ((iDirect ==1 && oListLeft.options[i].selected )|| iDirect ==2 )
{ var oldOp = oListLeft.options[i];
var newOp =
new Option(oldOp.text,oldOp.value);
oListRight.options.add(newOp); oListLeft.options[i] = null; i--; } }
checkButtonStatus();
}
function checkButtonStatus()
{ var oListLeft = document.all.s1;
var oListRight = document.all.s2;
var btn1 = document.all.btnLeft;
var btn2 = document.all.btnRight;
var btn3 = document.all.btnAllLeft;
var btn4 = document.all.btnAllRight;
// alert(bHaveCheckedOne(oListLeft));
btn1.disabled =!bHaveCheckedOne(oListRight);
btn2.disabled =!bHaveCheckedOne(oListLeft);
btn3.disabled =oListRight.options.length<=0;
btn4.disabled =oListLeft.options.length<=0; }
function bHaveCheckedOne(obj)
{ for(var i=0;i<obj.options.length;i++)
{ if(obj.options[i].selected)
{ return true; }
} return false;
} //-->
</SCRIPT>
<form name = "form1" action="" method="post"> <table width="800" border="0" align="center">
<tr >
<td width="805" height="101" align="center" class="Title1">自由短信发送页面</td>
</tr>
<tr>
<td><table width="768" border="0">
<tr>
<td width="575" class="Title2"><div align="center">短信内容编写栏:(每条短信可含60个字符,超出将被拆分)</div></td>
<td width="183">
<label>
<input name="SendMessage" type="submit" class="button1" id="SendMessage" value="发送短信" onclick="show()"/>
</label>
<label>
<input name="exit" type="submit" class="button1" id="exit" value="退出" onclick="exit()"/>
</label>
</td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" ><textarea name="text" cols="80" rows="10" id="text"></textarea></td>
</tr>
<tr>
<td height="92"><table width="724" border="0" align="center">
<tr>
<td width="300"><table width="300" border="0" class="Title2">
<caption>
</caption>
<tr>
<th height="21" scope="col"><div align="right">
<div align="right">可选收件人列表</div>
<select id="s1" onpropertychange="javascript:checkButtonStatus();" multiple style="WIDTH: 147px; HEIGHT: 200px">
<%
//4.执行SQL
ResultSet rs2 =stat.executeQuery("select * from ChooseAddressee");
//最后再把rs里面的值循环取出来
int i = 0;
while(rs2.next())
{
i++;
%>
<option value="<%=i%>"> <%=rs2.getString("ChooseAddressee")%></option>
<% }
rs2.close();
%>
</select>
</div>
</th>
</tr>
</table></td>
<td width="100"><table width="100" border="0">
<tr>
<td align="center"><label>
<INPUT class="btn2" id="btnAllLeft" onclick="transferItem(-2);" type="button" value="< <" name="btnAllLeft2">
</label></td>
</tr>
<tr>
<td align="center"><label>
<INPUT class="btn2" id="btnAllRight" onclick="transferItem(2);" type="button" value="> >" name="btnAllRight">
</label></td>
</tr>
<tr>
<td align="center"><label>
<INPUT class="btn2" id="btnLeft" onclick="transferItem(-1);" type="button" value=" < " name="btnLeft2">
</label></td>
</tr>
<tr>
<td align="center"><label>
<INPUT class="btn2" id="btnRight" onclick="transferItem(1);" type="button" value=" > " name="btnRight2">
</label></td>
</tr>
</table></td>
<td width="310" align="center"><table border="0" class="Title2" align="center">
<caption>
</caption>
<tr>
<th width="300" height="21" scope="col"><div align="left">
<div align="left">已选收件人列表</div>
<select id="s2" multiple style="WIDTH: 147px; HEIGHT: 200px" onpropertychange="javascript:checkButtonStatus();" >
</select>
</div>
</th>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<tr>
<td height="79" class="Title2"><div align="center">导入收信人联系方式
<input name="file" type="file" size="40" />
<input type="button" name="Submit6" onclick="checkExport();" value="导入" />
</div></td>
</tr>
</form>
</body>
</html>