Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eac23a64a | ||
|
|
327784354c | ||
|
|
1bec66a97c |
@@ -18,7 +18,7 @@ public class DBUtil {
|
||||
// 四大金刚
|
||||
String dname = ReadTxt.getSetting(null, "setting.ini", "MySqlName","test");
|
||||
String driver = "com.mysql.jdbc.Driver";// 驱动名称
|
||||
String url = "jdbc:mysql://"+ReadTxt.getSetting(null, "setting.ini", "MySqlIP","127.0.0.1")+":"+ReadTxt.getSetting(null, "setting.ini", "MySqlPort","3306")+"/"+dname+"?useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&autoReconnect=true&useSSL=false";// 连接
|
||||
String url = "jdbc:mysql://"+ReadTxt.getSetting(null, "setting.ini", "MySqlIP","127.0.0.1")+":"+ReadTxt.getSetting(null, "setting.ini", "MySqlPort","3306")+"/"+dname+"?useUnicode=false&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&autoReconnect=true&useSSL=false";// 连接
|
||||
String username = ReadTxt.getSetting(null, "setting.ini", "MySqlUserName","root");// 用户名
|
||||
String password = ReadTxt.getSetting(null, "setting.ini", "MySqlPassWord","cheng355217");// 密码
|
||||
|
||||
@@ -84,6 +84,7 @@ public class DBUtil {
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int execUpdate(String sql, Object[] params) {
|
||||
|
||||
try {
|
||||
this.getConnection();// 获得连接对象
|
||||
this.pstmt = this.con.prepareStatement(sql);// 获得预设语句对象
|
||||
@@ -203,31 +204,6 @@ public class DBUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索统计
|
||||
*
|
||||
* @param search
|
||||
* @return
|
||||
*/
|
||||
public boolean searchCount(String search) {
|
||||
String resid = "0";
|
||||
List<Map<String, Object>> res = execQuery(
|
||||
"select id from byx_count where searchstr =?",
|
||||
new String[] { search });
|
||||
if (res != null && res.size() > 0) {
|
||||
resid = res.get(0).get("id").toString();
|
||||
int i = execUpdate(
|
||||
"update byx_count set countsum = countsum+1 where id = "
|
||||
+ resid, null);
|
||||
return i > 0 ? true : false;
|
||||
} else {
|
||||
int i1 = execUpdate(
|
||||
"insert into byx_count(countsum,searchstr) values(1,?)",
|
||||
new String[] { search });
|
||||
return i1 > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象的属性,返回键值对
|
||||
* @param obj
|
||||
|
||||
Reference in New Issue
Block a user