return jsonObj.toString();
} }
public static JSONObject createByMap(final HashMap<String,String> tableInfo,String copyuuid,String username) throws Exception
{
JSONObject jsonObj = new JSONObject();
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
String day = fmt.format(new Date());
Map stormconf = Utils.readStormConfig();
String hdpConf = (String) stormconf.get("hadoop.conf.dir");
String connstr = (String) stormconf.get("higo.download.offline.conn");
String uname = (String) stormconf.get("higo.download.offline.username");
String passwd = (String) stormconf.get("higo.download.offline.passwd");
String store = (String) stormconf.get("higo.download.offline.store")
+ "/" + day + "/" + java.util.UUID.randomUUID().toString();
MySqlConn m_fpsql = new MySqlConn(connstr, uname, passwd);
String tableName=java.util.UUID.randomUUID().toString();
Connection conn = m_fpsql.getConn();
// tableShowName,tableName,colsShowName,colsName,colsType,splitString,txtStorePath,indexStorePath,status,username,createtime,lastuptime,joins,percent,resultkb,download_uuid,copy_uuid
String strSql = "insert into adhoc_joins " +
"(tableShowName,tableName,colsShowName,colsName,colsType,splitString,txtStorePath,indexStorePath,status,username,createtime,lastuptime,joins,percent,resultkb,download_uuid,copy_uuid,memo)" +
"values" +
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement m_fps = conn.prepareStatement(strSql);
try {
int index=1;
m_fps.setString(index++, tableInfo.get("tableShowName"));
m_fps.setString(index++, tableName);
m_fps.setString(index++, tableInfo.get("colsShowName"));
m_fps.setString(index++, tableInfo.get("colsName"));
m_fps.setString(index++, tableInfo.get("colsType"));
m_fps.setString(index++, tableInfo.get("splitString"));
m_fps.setString(index++, tableInfo.get("txtStorePath"));
m_fps.setString(index++, tableInfo.get("indexStorePath"));
m_fps.setString(index++, tableInfo.get("status"));
m_fps.setString(index++, username);
long nowtims=System.currentTimeMillis();
m_fps.setTimestamp(index++, new java.sql.Timestamp(nowtims));
m_fps.setTimestamp(index++, new java.sql.Timestamp(nowtims));
m_fps.setString(index++, tableInfo.get("joins"));
m_fps.setString(index++, tableInfo.get("percent"));
m_fps.setInt(index++, Integer.parseInt(tableInfo.get("resultkb")));
m_fps.setString(index++, tableInfo.get("download_uuid"));
m_fps.setString(index++, copyuuid);
m_fps.setString(index++, tableInfo.get("memo"));
m_fps.executeUpdate();
jsonObj.put("code", "1");
jsonObj.put("tableid", tableName);
jsonObj.put("____debug", m_fps.toString());
} catch (Exception e) {
jsonObj.put("____debug2", m_fps.toString());
jsonObj.put("____debugerror", e.toString());
jsonObj.put("code", "0");
}finally{
m_fps.close();
m_fpsql.close();
}