QTPУ??????????????????
???????????? ???????[ 2014/5/12 15:20:47 ] ????????QTP ????????????
????QTPCommonDao.java???
package com.runqianapp.qtp;
import java.sql.*;
import com.geezn.exception.GeeznException;
import com.runqian.mis2.util.DBAccess;
import com.runqianapp.common.log.GEZLoggerManager;
/**
* QTP?????????????
* @author RAQ
*
*/
public class QTPCommonDao {
/**
* ????洢????????????????????????“;”???
*/
public static StringBuffer columns = new StringBuffer();
/**
* ????洢???????????
*/
public static String tableName = "";
/**
* ?????????????????
*/
public static final String MODULE_QTP = "qtpModule";
/***
* ????????????????????????
* @param sql ??????????sql???
* @param sqlDateNumber ???????????(?????????????????)
* @return ????????????????????? ?磺"short_link;...;link_name||/link1??...?????@_@{};/link2??...?????@_@{}"
* ?????????????????????"||"????????????????????????????????";"??????????????????"#"??"@_@"???
* ????"#"????????????????"@_@"?????????????????json?????
* @throws GeeznException
*/
public static synchronized String getAllDatas(String sql?? String sqlDateNumber)
throws GeeznException {
getTableName(sql); //??????????
PreparedStatement pstmt = null;
DBAccess dba = null;
ResultSet rs = null;
StringBuffer allDatas = new StringBuffer(); //??????????????
try {
dba = new DBAccess();
rs = dba.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
/** ????????????????columns?????????? */
columns = columns.delete(0?? columns.length());
/** ??????????????????????? */
for (int i = 1; i <= columnCount; i++) {
allDatas.append(rsmd.getColumnName(i)).append(";");
columns.append(rsmd.getColumnName(i)).append(";");
}
allDatas.deleteCharAt(allDatas.length() - 1);
columns.deleteCharAt(columns.length() - 1);
String[] column = columns.toString().split(";");
allDatas.append("||");
/** ???????????????????????? */
while (rs.next()) {
for (int i = 0; i < column.length; i++) {
allDatas.append(rs.getString(column[i])).append("#");
}
allDatas.deleteCharAt(allDatas.length() - 1);
allDatas.append("@_@"); //??"@_@"?????????????????????????????????
/**????????????json?????*/
allDatas.append("{");
for (int i = 0; i < column.length; i++) {
allDatas.append(""").append(column[i]).append(""")
.append(":")
.append(""").append(rs.getString(column[i])).append(""")
.append("??");
}
allDatas.deleteCharAt(allDatas.length() - 1);
allDatas.append("}");
allDatas.append(";");
}
allDatas.deleteCharAt(allDatas.length() - 1);
} catch(Exception e){
throw new GeeznException(QTPCommonDao.MODULE_QTP?? GEZLoggerManager.LOGLEVEL_ERROR??"????????sql??????????????????"?? e??"{}");
} finally {
close(dba?? pstmt?? rs);
}
return allDatas.toString();
}
/**
* ??????????sql????н??????????????????tableName??
* @param sql ????????sql???
*/
public static void getTableName(String sql){
if (sql.contains("where") || sql.contains("WHERE")) {
int start = 0;
int end = 0;
if (sql.contains("from")) {
start = sql.indexOf("from");
} else if (sql.contains("FROM")) {
start = sql.indexOf("FROM");
}
if (sql.contains("where")) {
end = sql.indexOf("where");
} else if (sql.contains("WHERE")) {
end = sql.indexOf("WHERE");
}
if (start == 0 || end == 0) {
System.out.println("???????????");
} else {
tableName = sql.substring(start + 5?? end);
}
} else {
int start = 0;
if (sql.contains("from")) {
start = sql.indexOf("from");
} else if (sql.contains("FROM")) {
start = sql.indexOf("FROM");
}
if (start == 0) {
System.out.println("???????????");
} else {
tableName = sql.substring(start + 5?? sql.length());
}
}
}
/**
* ?ж????????????????????????
* @param sql ???????????sql???
* @return ????????????????????????? true???????? false????б????
* @throws GeeznException
*/
public static synchronized Boolean checkDeleteResult(String sql)throws GeeznException{
boolean flag = true; //??????????????
DBAccess dba = null;
ResultSet rs = null;
try{
dba = new DBAccess();
rs = dba.executeQuery(sql);
while(rs.next()){
flag = false;
}
}catch(Exception e){
throw new GeeznException(QTPCommonDao.MODULE_QTP?? GEZLoggerManager.LOGLEVEL_ERROR??"?ж???????????????????????????????"?? e??"{}");
}finally{
close(dba?? null?? rs);
}
return flag;
}
/**???????????
* @throws GeeznException
*/
private static void close(DBAccess dba??Statement ps??ResultSet rs) throws GeeznException{
try{
if(rs!=null){
rs.close();
}
if(ps!=null){
ps.close();
}
if(dba!=null){
dba.close();
}
}catch(Exception e){
throw new GeeznException(QTPCommonDao.MODULE_QTP?? GEZLoggerManager.LOGLEVEL_ERROR??"??????????????????????"?? e??"{}");
}
}
}
|
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????