日志里面打印出来的sql是带问号的,然后参数另外又打印了一排。通过这个工具可以将带问号的sql与参数整合成可执行的sql。
以下是html代码:
[quote]
<html>
<head>
<style>
textarea{height:120px;width:1000px;
}
</style>
<script type="text/javascript">
function deal() {
var a = document.getElementById("1").value;
var b = document.getElementById("2").value;
var arrayA = a.split("?");
var arrayB = b.split(", ");
var res ='';
// alert(arrayA.length);
//alert(arrayB.length);
if(arrayA.length!=(arrayB.length+1)){
document.getElementById("3").value='参数个数不匹配';
}else {
for (var i=0;i<arrayB.length;i++) {
var tempB = arrayB[i];
if(tempB.indexOf('(String)')>0) {
tempB = tempB.replace("(String)","");
tempB = ' \''+tempB+'\' ';
//alert(tempB);
} if(tempB.indexOf('(Integer)')>0) {
tempB = tempB.replace("(Integer)","");
} if(tempB.indexOf('(BigDecimal)')>0) {
tempB = tempB.replace("(BigDecimal)","");
}
res =res + arrayA[i] +tempB ;
}
res =res + arrayA[arrayA.length-1] ;
}
//alert(res);
document.getElementById("3").value=res;
}
</script>
</head>
<body>
<textarea id="1" form="usrform" >此处录入sql语句...</textarea> <br>
<textarea id="2" form="usrform" >此处录入参数...</textarea> <br>
<textarea id="3" form="usrform" οnfοcus="deal()">此处是输出...</textarea>
<body>
</html>
[/quote]
效果如下图
[img]http://dl2.iteye.com/upload/attachment/0116/0287/34b39c14-d7dc-351d-aa11-360820dd6397.jpg[/img]
以下是html代码:
[quote]
<html>
<head>
<style>
textarea{height:120px;width:1000px;
}
</style>
<script type="text/javascript">
function deal() {
var a = document.getElementById("1").value;
var b = document.getElementById("2").value;
var arrayA = a.split("?");
var arrayB = b.split(", ");
var res ='';
// alert(arrayA.length);
//alert(arrayB.length);
if(arrayA.length!=(arrayB.length+1)){
document.getElementById("3").value='参数个数不匹配';
}else {
for (var i=0;i<arrayB.length;i++) {
var tempB = arrayB[i];
if(tempB.indexOf('(String)')>0) {
tempB = tempB.replace("(String)","");
tempB = ' \''+tempB+'\' ';
//alert(tempB);
} if(tempB.indexOf('(Integer)')>0) {
tempB = tempB.replace("(Integer)","");
} if(tempB.indexOf('(BigDecimal)')>0) {
tempB = tempB.replace("(BigDecimal)","");
}
res =res + arrayA[i] +tempB ;
}
res =res + arrayA[arrayA.length-1] ;
}
//alert(res);
document.getElementById("3").value=res;
}
</script>
</head>
<body>
<textarea id="1" form="usrform" >此处录入sql语句...</textarea> <br>
<textarea id="2" form="usrform" >此处录入参数...</textarea> <br>
<textarea id="3" form="usrform" οnfοcus="deal()">此处是输出...</textarea>
<body>
</html>
[/quote]
效果如下图
[img]http://dl2.iteye.com/upload/attachment/0116/0287/34b39c14-d7dc-351d-aa11-360820dd6397.jpg[/img]