| | |
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 启动是模拟每个电池组的内阻数据值
|
| | | * @param gB_MysqlConnPool
|
| | | */
|
| | | public static void MakeMonResDataRandom(MysqlConnPool pool) { |
| | | String sql_str_sel = "SELECT * FROM " + Sql_Mysql.BattRtData_Table; |
| | | ResultSet res = null;
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str_sel);
|
| | | while(res.next()) {
|
| | | int battgroupid = res.getInt("BattGroupId");
|
| | | int mon_num = res.getInt("mon_num");
|
| | | |
| | | sql.sqlMysqlExecute("UPDATE " + Sql_Mysql.BattRtData_Table + " SET mon_res = " + String.format("%1.3f", (float)(0.101+Math.random()*0.298)) + " WHERE BattGroupId = " + battgroupid + " AND mon_num = " + mon_num);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | } |
| | | }
|
| | | |
| | | public static void main(String[] args) {
|
| | | MysqlConnPool pool = new MysqlConnPool("127.0.0.1", 3360, 5);
|
| | | MakeMonResDataRandom(pool);
|
| | | |
| | | // for(int i = 0;i< 100000;i++) {
|
| | | // float ran = (float)(0.101+Math.random()*0.298);
|
| | | // if(ran < 0.101 || ran > 0.4 ) {
|
| | | // System.err.println(ran);
|
| | | // }
|
| | | // System.out.println(String.format("%1.3f", ran));
|
| | | // }
|
| | | }
|
| | | }
|