problem with java code and
deal with string
String [] idsArr = bids.split(",");
for (int i = 0; i < idsArr.length; i++) {
ss = ss + "'"+idsArr[i]+"',";
}
deal with code
String sql = DataTools.null2EmptyString(URLDecoder.decode(request
.getParameter("sql"), "utf-8"));
sql query return DataSet
public DataSet executeQuery(String strSQL) throws Exception
{
DataSet ds = null;
try
{
ds = (DataSet) getPM().executeQuery(strSQL);
}
catch (DrmException e)
{
System.out.println("" + e);
LogFactory.getLog(SystemConfig.logCatagroy).error("", e);
throw e;
}
finally
{
close();
}
return ds;
}
other thread send email
private class SendMailThread extends Thread{
ImportToERPR12Dao dao = new ImportToERPR12Dao();
private List<Object[]> list;
private String a ;
public SendMailThread(List<Object[]> l,String s){
list = l;
a = s;
}
public void run(){
System.out.println("Reading email properties....");
String validateName = "";
String validatePswd = "";
String fjrMail = "";
String fjrName = "";
String constantIp = "";
String csr = "";
String sjr = "";
String shje = "";
try {
HashMap<String, String> paramMap = ReadEmailProperties
.getInstance().getPoppertiesMap();
validateName = paramMap.get("emailValidateName");
validatePswd = paramMap.get("emailValidatePassword");
fjrMail = paramMap.get("sendMailPerson");
fjrName = MimeUtility.encodeText(paramMap.get("sendMailShowName"),MimeUtility.mimeCharset("gb2312"), null);
System.out.println(fjrName);
constantIp = paramMap.get("constant_ip");
} catch (Exception e) {
System.out.println("Failed to get mail configuration information. Canceling this operation");
}
Iterator itr = list.iterator();
String[] result = null;
while(itr.hasNext()){
System.out.println("import:"+a);
Object[] o = (Object[])itr.next();
String sql = "select ldap,BILL_AMOUNT from nuip_wsbx.TB_BILL_INF where bill_code=? ";
System.out.println("sql:"+sql);
String[] param_sql = new String[] { (String) o[0] };
try {
result = dao.queryListInFixedCol(sql, param_sql, 2).get(0);
} catch (Exception e1) {
e1.printStackTrace();
}
sjr = result[0]+"@neusoft.com";
System.out.println("recipients:"+sjr);
shje = result[1];
if(!"".equals(sjr)&&null!=sjr&&"null"!=sjr){
List<String> csrList = new ArrayList<String>();
List<String> sjrList = new ArrayList<String>();
sjrList.add(sjr);
String yjzt = "邮件通知";
String mailHtml = "";
NetManagerEmailVO emailVo = new NetManagerEmailVO();
emailVo.setFsr(fjrMail);
emailVo.setFsrMc(fjrName);
emailVo.setSjrList(sjrList);
emailVo.setYjnr(mailHtml);
try {
emailVo.setYjzt(MimeUtility.encodeText(yjzt,MimeUtility.mimeCharset("gb2312"), null));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
emailVo.setUserName(validateName);
emailVo.setPassword(validatePswd);
emailVo.setCsrList(csrList);
boolean flag = NetManagerEmailSendTool.sendEmailWithSjrName(emailVo, false);
System.out.println("Send mail status : true is success false is fail flag=" + flag);
}
}
}
}
deal with \
String osname = System.getProperties().getProperty("os.name");
String path = "";
if (osname.equals("Linux")) {
path = "\\";
}else{
path = "/";
}
path = 目录1+File.separator+目录2
deal with firefox or chrome for ‘event.fromElement’ and ‘event.toElement’
var event = event || window.event;
deal with IE to firefox
window.showModalDialog("<%=path%>/ExpenseAction.do?method=querySpqk&bill_id="+bill_id,"","dialogWidth:610px;dialogHeight:200px");
window.open('<%=path%>/ExpenseAction.do?method=querySpqk&bill_id='+bill_id,'newWin','modal=no,width=610,height=200,resizable=no,scrollbars=no');
idea before saving data delete old (wrong) data
ajax data list
$.ajax({
type: 'POST',
url: path+'/TelephoneAdviserAction.do?method=queryBySale',
async: false,
data: {'where':where},
success: function (msg) {
$("select[name=minority]").children().remove();
if 不为0{
var json = eval (msg.result);
$each(json,function(i,item){
$("<option>"+item.minority_name+"</option>").attr("value",item.id).appendTo($("select[name = minority]"));
})
}else if (...) {
$("select[name=minority]").append("<option>加载失败</option>");
}
}
})
下拉列表
String sql_gw = "select b.xm as codename,UserAccount as codevalue from neuedu_view_uporguser_ygxx a, neuedu_qx_salesxxb b where a.user_account = b.useraccount";
String[] cols_gw = { "CODENAME", "CODEVALUE" };
String zxgw = ca.queryJsonObjectBySql(sql_gw, cols_gw);
JSONObject obj = new JSONObject();
obj.put("zxgw", zxgw);
$.ajax({
type: 'POST',
url: path+'/TelephoneAdviserAction.do?method=queryBySale',
async: false,
data: {'where':where},
success: function (v) {
var obj=eval('('+v+')');
var sfsm = document.getElementById('SFSM');
sfsm.options.length=0;
var opn = document.createElement("OPTION");
opn.value = "";
opn.innerHTML = "----请选择----";
sfsm.appendChild(opn);
for(var i=0;i<obj.sf.length;i++){
var op = document.createElement("OPTION");
op.value = obj.sf[i].CODEVALUE;
op.innerHTML = obj.sf[i].CODENAME;
sfsm.appendChild(op);
}
}
});
export data jxl
public ActionForward doExport(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
String where = request.getParameter("where");
CommonApplogicImpl ca = new CommonApplogicImpl();
String sql = this.queryExportBySql + "and " + where +" order by cjsj desc";
String sqlcol[] = { "XSXM", "SJHM", "EMAIL", "XM", "ZXGW", "SFSM1", "sfcd1", "YYSMSJ","DHXSFPZXGW"};
String[] titles = { "学生姓名","电话","邮箱","电话销售","咨询顾问","是否上门","是否承担","预约上门时间","分配人"};
File tempfile = ca.exportExcel(sql, sqlcol, titles);
if (tempfile.exists()) {
InputStream ins = new FileInputStream(tempfile);
BufferedInputStream bins = new BufferedInputStream(ins);
OutputStream outs = response.getOutputStream();
BufferedOutputStream bouts = new BufferedOutputStream(outs);
response.setContentType("application/x-download");
response.setHeader("Content-disposition",
"attachment;filename=export.xls");
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
bouts.write(buffer, 0, bytesRead);
}
bouts.flush();
ins.close();
bins.close();
outs.close();
bouts.close();
} else {
System.out.println("下载的文件不存在");
}
return null;
}
public File exportExcel(String sql, String[] arr, String[] titles)
{
long time = new Date().getTime();
File a = new File(time + ".xls");
DataSet ds = null;
int count = 0;
try
{
ds = this.DsBySql(sql);
count = ds.getRowCount();
} catch (Exception e1)
{
e1.printStackTrace();
}
try
{
WritableWorkbook workbook = Workbook.createWorkbook(a);
WritableSheet sheet = workbook.createSheet("export", 0);
WritableFont wf_title = new WritableFont(WritableFont.ARIAL, 10);
WritableCellFormat wcf_title = new WritableCellFormat(wf_title);
wcf_title.setAlignment(jxl.format.Alignment.CENTRE);
wcf_title.setBorder(jxl.format.Border.ALL,
jxl.format.BorderLineStyle.THIN);
wcf_title.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
WritableFont wf_cell = new WritableFont(WritableFont.ARIAL, 9);
WritableCellFormat wcf_cell = new WritableCellFormat(wf_cell);
wcf_cell.setAlignment(jxl.format.Alignment.CENTRE);
wcf_cell.setBorder(jxl.format.Border.ALL,
jxl.format.BorderLineStyle.THIN);
wcf_cell.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
for (int i = 0; i < titles.length; i++)
{
Label label = new Label(i, 0, titles[i], wcf_title);
sheet.setColumnView(i, 20);
sheet.addCell(label);
}
int t = 0;
while (ds.next())
{
t++;
for (int p = 0; p < arr.length; p++)
{
Label label = new Label(p, t, ds.getString(arr[p]),
wcf_cell);
sheet.addCell(label);
}
}
workbook.write();
workbook.close();
} catch (Exception e)
{
e.printStackTrace();
}
return a;
}
export data with Color jxl
/**
* 表头带颜色的导出
*
* @param sql
* 查询sql
* @param arr
* 对应的字段
* @param titles
* 表头字段名
* @param formats
* 字段格式
* @return
*/
public File exportExcelCustom(String sql, String[][] arr, String[] titles)
{
long time = new Date().getTime();
File a = new File(time + ".xls");
DataSet ds = null;
try
{
ds = this.DsBySql(sql);
} catch (Exception e1)
{
e1.printStackTrace();
}
try
{
WritableWorkbook workbook = Workbook.createWorkbook(a);
WritableSheet sheet = workbook.createSheet("export", 0);
WritableFont title_head = new WritableFont(WritableFont.TIMES, 10,
WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE,
jxl.format.Colour.BLACK);
WritableCellFormat title_format = new WritableCellFormat(title_head);
title_format.setBackground(jxl.format.Colour.PALE_BLUE);
title_format.setAlignment(jxl.format.Alignment.CENTRE);
title_format.setBorder(jxl.format.Border.ALL,
jxl.format.BorderLineStyle.THIN);
title_format
.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
WritableFont on_head = new WritableFont(WritableFont.TIMES, 10,
WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE,
jxl.format.Colour.BLACK);
WritableCellFormat one_head = new WritableCellFormat(on_head);
one_head.setAlignment(jxl.format.Alignment.CENTRE);
one_head.setBorder(jxl.format.Border.ALL,
jxl.format.BorderLineStyle.THIN);
one_head.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
WritableFont num_head = new WritableFont(WritableFont.ARIAL, 10,
WritableFont.NO_BOLD, false);
NumberFormat nf = new NumberFormat("#,##0.00;-#,##0.00");
WritableCellFormat num_format = new WritableCellFormat(num_head, nf);
num_format.setAlignment(jxl.format.Alignment.CENTRE);
num_format.setBorder(jxl.format.Border.ALL,
jxl.format.BorderLineStyle.THIN);
num_format
.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
for (int i = 0; i < titles.length; i++)
{
Label label = new Label(i, 0, titles[i], title_format);
sheet.setColumnView(i, 20);
sheet.addCell(label);
}
int t = 0;
while (ds.next())
{
t++;
for (int p = 0; p < arr.length; p++)
{
if (arr[p][1].equals("S"))
{
Label label = new Label(p, t, ds.getString(arr[p][0]),
one_head);
sheet.addCell(label);
} else if (arr[p][1].equals("N"))
{
Double Num = Double.valueOf(ds.getString(arr[p][0]));
Number label = new jxl.write.Number(p, t, Num,
num_format);
sheet.addCell(label);
}
}
}
workbook.write();
workbook.close();
} catch (Exception e)
{
e.printStackTrace();
}
return a;
}
Grid
jQuery("#list2").jqGrid({
url : path + "/studentStatusChangeNewAction.do?method=query",
datatype : "json",
colNames : ['姓名', '身份证号', '项目名称', '项目编号', '班级名称','报到时间','是否报到','是否住宿','学籍状态','离司时间','离司状态','详情','合同编号','学号','退班时间','退班原因','学生当前状态码','离司原因','转班时间','转班原因','班级编号','休学状态'],
colModel : [{
name : 'XM',
width : 80,
align : "center"
}, {
name : 'SFZJH',
width : 140,
align : "center"
}, {
name : 'XMMC',
width : 170,
align : "center"
}, {
name : 'XMBH',
width : 110,
align : "center"
}, {
name : 'BJMC',
width : 120,
align : "center"
}, {
name : 'BDSJ',
width : 100,
align : "center"
}, {
name : 'SFBD',
width : 60,
align : "center",
editoptions : {
value : ':;1:是;0:否'
},
formatter : 'select'
},{
name : 'SFZS',
width : 60,
align : "center",
editoptions : {
value : ':;1:是;0:否'
},
formatter : 'select',
hidden:true
},{
name : 'XJZT',
width : 60,
align : "center"
},{
name : 'LSSJ',
width : 100,
align : "center"
},{
name : 'LSZT',
width : 80,
align : "center",
editoptions : {
value : ':;0:未申请;1:待确认;2:已确认'
},
formatter : 'select',
hidden : true
},{
name : 'RID',
width : 50,
align : "center",
hidden : true
},{
name : 'HTBH',
width : 50,
align : "center",
hidden : true
},{
name : 'XH',
width : 50,
align : "center",
hidden : true
},{
name : 'TBRQ',
width : 100,
align : "center"
},{
name : 'TBYY',
width : 180,
align : "center"
},{
name : 'XSDQZTM',
width : 120,
align : "center",
hidden :true
},{
name : 'LSYY',
width : 180,
align : "center"
},{
name : 'ZBRQ',
width : 100,
align : "center"
},{
name : 'ZBYY',
width : 180,
align : "center"
},{
name : 'BJBH',
width : 50,
align : "center",
hidden : true
},{
name : 'XXZT',
width : 50,
align : "center",
hidden : true
}
],
rowNum : 10,
width : 1210,
height : 270,
shrinkToFit : false,
loadtext : '请求数据中.....',
rownumbers : true,
rownumbersWidth : 15,
scrollOffset : 0,
rowList : [10, 20, 30, 50, 100],
postData : {
where : where
},
pager : '#pager2',
sortname : '',
mtype : "post",
viewrecords : true,
multiselect : true,
sortorder : "",
pagerpos : "left",
recordpos : "right",
beforeSelectRow : function(rowid, e, col) {
if (col == "1") {
return true;
} else {
return false;
}
}
});
jQuery("#list2").jqGrid('navGrid', '#pager2', {
position : 'center',
edit : false,
add : false,
del : false,
search : false,
refresh : false
});
<link rel="stylesheet" type="text/css" href="<%=appPath%>/pages/demo/css/ui.jqgrid.css"></link>
<link rel="stylesheet" type="text/css" href="<%=appPath%>/pages/demo/smoothness/jquery-ui-1.8rc3.custom.css"></link>
<script type="text/javascript" src="<%=appPath%>/pages/demo/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="<%=appPath%>/pages/demo/js/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="<%=appPath%>/pages/demo/src/jquery.jqGrid.js"></script>
<script type="text/javascript" src="<%=appPath%>/Resources/common/layer/layer.js"></script>
<script language="JavaScript" src="<%=appPath%>/pages/demo/jquery/jquery-ui.js"></script>
<script language="JavaScript" src="<%=appPath%>/pages/demo/jquery/jquery.multiselect.js"></script>
<script language="JavaScript" src="<%=appPath%>/pages/demo/jquery/jquery.multiselect.filter.js"></script>
<script language="JavaScript" src="<%=appPath%>/pages/demo/jquery/jquery.multiselect.filter.zh-cn.js"></script>
<link rel="stylesheet" href="<%=appPath%>/pages/demo/jquery/jquery.multiselect.css" type="text/css" />
<div id="pager2"></div>
layer
layer.open({
type : 2,
title : '录入离司日期',
shadeClose : false,
shade : 0.8,
area : ['450px', '250px'],
content : temppath,
end : function() {
obj = new Object();
query();
}
});
oracle unlock
select object_name,
machine,
s.sid,
s.serial# from v$locked_object l,
dba_objects o,
v$session s where l.object_id = o.object_id and l.session_id = s.sid;
alter system kill session '263,3213';
//解锁存储过程
select * FROM dba_ddl_locks where name =upper('prc_neu_zj_zjxxxg');
select t.sid,t.serial# from v$session t
where t.sid=257;
alter system kill session '257,3318'
//如果上边的办法杀不掉
SELECT p.SPID, s.OSUSER, p.PROGRAM
FROM v$session s, v$process p
WHERE s.PADDR = p.ADDR
AND s.SID = 2193
//取到SPID,然后再linux下执行一下命令
kill -9 6666(取到的SPID)
//替换临时表空间
查询原表空间位置
select name from v$tempfile;
新建一个
create temporary tablespace temp1 tempfile '/oracle/oradata/ORCL/datafile/temp1.dbf' size 20m;
alter database default temporary tablespace temp1;
alter database tempfile '/oracle/oradata/ORCL/datafile/temp1.dbf' autoextend on next 20m;
删除原来的
drop tablespace TEMP2 including contents and datafiles;
下拉框模糊查询
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<style>
.error {color:red;font-weight:bold;}
</style>
</head>
<body>
<div>
<select id="aid">
<option>上海-浦东</option><option>河南-南阳</option><option>湖北-襄阳</option>
<option>上海-崇明</option><option>河南-郑州</option><option>湖北-荆州</option>
<option>上海-黄浦</option><option>河南-安阳</option><option>湖北-十堰</option>
<option>上海-静安</option><option>河南-濮阳</option><option>湖北-武汉</option>
<option>上海-长宁</option><option>河南-信阳</option><option>湖南-长沙</option>
</select>
<input id="condition">
<input type="button" id="search" value="Filter">
</div>
<script>
$(function(){
$("#search").click(function(){
if($("#condition").val() && $("#condition").val()!=''){
var allOptions = $("#aid").children();
alert(allOptions);
$(allOptions).each(function(i){
if($(allOptions[i]).html().indexOf($("#condition").val()) <= -1){
$("#aid").append(allOptions[i]);
$("#aid option").eq(0).attr('selected', 'true');
}
});
}
});
});
</script>
</body>
<script>
</script>
</html>
Date.prototype.format = function(format){
var o = {
"M+" : this.getMonth()+1,
"d+" : this.getDate(),
"h+" : this.getHours(),
"m+" : this.getMinutes(),
"s+" : this.getSeconds(),
"q+" : Math.floor((this.getMonth()+3)/3),
"S" : this.getMilliseconds()
}
if(/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
for(var k in o) {
if(new RegExp("("+ k +")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
}
}
return format;
}
拼接函数
select wmsys.wm_concat(htqdr||'('||count(1)||')') into from neuedu_gg_xxxt where sfjdn = '是' and jd in('沈阳') and drxys is null group by htqdr
恢复oracle数据
根据scn恢复数据
select current_scn from v$database;
select * from NEU_MENU_USER as of scn 1755187500;
flashback table NEU_MENU_USER to scn 1755187500;
根据时间恢复数据
select sysdate from dual;
select * from NEU_MENU_USER as of timestamp to_timestamp('2015-10-13 15:20:00','yyyy-mm-dd hh24:mi:ss');
flashback table NEU_MENU_USER to timestamp to_timestamp('2013-05-29 15:29:00','yyyy-mm-dd hh24:mi:ss');