2 Commits
r18 ... r19

Author SHA1 Message Date
admin
327784354c db 2022-11-17 10:44:43 +08:00
admin
1bec66a97c db 2022-11-17 10:44:33 +08:00

View File

@@ -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+"?useOldAliasMetadataBehavior=true&autoReconnect=true&useSSL=false";// 连接
String username = ReadTxt.getSetting(null, "setting.ini", "MySqlUserName","root");// 用户名
String password = ReadTxt.getSetting(null, "setting.ini", "MySqlPassWord","cheng355217");// 密码
@@ -47,6 +47,7 @@ public class DBUtil {
try {
Class.forName(driver);
con = DriverManager.getConnection(url, username, password);
con.prepareStatement("set names utf8mb4");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -84,6 +85,7 @@ public class DBUtil {
* @return 影响行数
*/
public int execUpdate(String sql, Object[] params) {
try {
this.getConnection();// 获得连接对象
this.pstmt = this.con.prepareStatement(sql);// 获得预设语句对象
@@ -203,31 +205,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