快死人了,大家帮忙看看吧
我的action如下:
public class AgentAction extends Action {
Agentbean agentbean;
public Agentbean getAgentbean() {
return agentbean;
}
public void setAgentbean(Agentbean agentbean) {
this.agentbean = agentbean;
}
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
String l_id=Util.filter(request.getParameter("login_id"));
String c_id=Util.filter(request.getParameter("call_id"));
String work_id=Util.filter(request.getParameter("work_id"));
String r_name=agentbean.RecordName(work_id);
if(!r_name.equals("")){
agentbean.InsertRecord(l_id,c_id,work_id,r_name,work_id);
}else{
RecordNameThread rnt = new RecordNameThread(l_id,c_id,work_id);
rnt.start();
}
return null;
}
}
class RecordNameThread extends Thread{
private String l_id;
private String c_id;
private String w_id;
private String r_name;
private boolean flag = true;
private int num = 0;
public RecordNameThread(String l_id,String c_id,String w_id){
this.w_id = w_id;
this.l_id = l_id;
this.c_id = c_id;
this.w_id = w_id;
}
public void run(){
while(flag){
r_name = (new Agentbean()).RecordName(w_id);
if(!r_name.equals("")){
(new Agentbean()).InsertRecord(l_id,c_id,w_id,r_name,w_id);
flag = false;
}else{
if(++num<4){
flag = false;
}
}
try {
this.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
javabean如下:
public String RecordName(String w_id){
String ip="195.67.44.83";
String time = new SimpleDateFormat("\\1\\0\\yyyyMMdd").format(new Date());
String url = "\\\\"+ip+""+time+"\\"+w_id+"\\";
System.out.println("url:"+url);
File ftpfile= new File(url);
//File ftpfile = new File("e:\\f");
String [] filenames = ftpfile.list();
System.out.println("filenames:"+filenames);
String filename="";
if(filenames!=null){
filename = filenames[filenames.length - 1] + "";
}
System.out.println("filename:"+filename);
return filename;
}
/*
*将CALLID和录音文件名插入数据库
*/
public boolean InsertRecord(String l_id,String c_id,String work_id,String r_name,String w_id){
boolean return_value=false;
try {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
//if(jdbcTemplate.update(sql)>0)
return_value=true;
String time = new SimpleDateFormat("yyyyMMdd").format(new Date());
String url = ""+time+"/"+w_id+"/"+r_name+"";
String sql="update t_agent_call_log set record_file_name ='"+url+"' where t_agent_login_id='"+l_id+"' and t_agent_call_id='"+c_id+"'";
jdbcTemplate.update(sql);
System.out.println("InsertRecord:"+sql);
} catch (Exception ex) {
ex.printStackTrace();
}
return return_value;
}、
当有多用户访问这个action的时候,打印出的update语句,有时候没有提交,不知道为是么,应该是多线程的牙,怎么可能没提交呢,有高手帮我解决下码?我在这里谢过了,我的MSN:directionwang◎hotmail.com,或者email:chenggong_3738◎163。com