private void createTable(String tableName) { StringBuilder sql = new StringBuilder(); sql.append( " CREATE TABLE `" + tableName + "` ( "); sql.append( " `ID_` bigint(20) NOT NULL AUTO_INCREMENT, "); sql.append( " `APP_NAME` varchar(20) NOT NULL, "); sql.append( " `SERVICE` varchar(200) NOT NULL, "); sql.append( " `METHOD` varchar(50) NOT NULL, "); sql.append( " `CONSUMER_IP` varchar(15) NOT NULL, "); sql.append( " `PROVIDER_IP` varchar(15) NOT NULL, "); sql.append( " `TIME` datetime NOT NULL, "); sql.append( " `SUCCESS_TIMES` bigint(20) NOT NULL, "); sql.append( " `FAIL_TIMES` bigint(20) NOT NULL, "); sql.append( " `ELAPSED_AVG` int(11) NOT NULL, "); sql.append( " `ELAPSED_MAX` int(11) NOT NULL, "); sql.append( " `SUCCESS_TIMES_DETAIL` text, "); sql.append( " `FAIL_TIMES_DETAIL` text, "); sql.append( " `ELAPSED_TOTAL_DETAIL` text, "); sql.append( " `ELAPSED_MAX_DETAIL` text, "); sql.append( " PRIMARY KEY (`ID_`), "); sql.append( " KEY `IDX_" + tableName + "_1` (`APP_NAME`,`SERVICE`,`METHOD`,`PROVIDER_IP`,`CONSUMER_IP`,`TIME`) "); sql.append( " ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "); Map<String, String> m = new HashMap<String, String>(); m.put("sql", sql.toString()); DBDao dbDao = (DBDao) SpringUtil.getContext().getBean("dbDao"); dbDao.createTable(m); }
private boolean isTableExists(String tableName) { DBDao dbDao = (DBDao) SpringUtil.getContext().getBean("dbDao"); return dbDao.tableExists(tableName); }