Package com.alimama.mdrill.adhoc

Examples of com.alimama.mdrill.adhoc.MySqlConn


    SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
    Map stormconf = Utils.readStormConfig();
    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");
    MySqlConn m_fpsql = new MySqlConn(connstr, uname, passwd);

    Connection conn = m_fpsql.getConn();
    Statement stmt = conn.createStatement();
   
    String strsqlJoin="select count(*) as cnt" +
        " from adhoc_joins where username='"+username.replaceAll("'", "")+"' and status<>'DEL' and (copy_uuid is null or copy_uuid='') "+joins+" " ;
   
    StringBuffer bufferSql=new StringBuffer();
    if(type==0)
    {
      String strsqlJoin2="select count(*) as cnt" +
      " from adhoc_joins where username='"+username.replaceAll("'", "")+"' and status<>'DEL' and (copy_uuid is not null and copy_uuid<>'')   "+joins+"  " ;
     
      String strsqlDownload="select count(*) as cnt" +
      " from adhoc_download where username='"+username.replaceAll("'", "")+"' and status<>'DEL' ";
 
      bufferSql.append("select sum(cnt) as cnt");
      bufferSql.append(" from ("+strsqlJoin+" union "+strsqlDownload+" union "+strsqlJoin2+") tmp  limit 10 ");
    }if(type==1)//for join
    {
      bufferSql.append(strsqlJoin+" and status='INDEX' and resultkb<=512000  order by createtime desc limit 10 ");
    }
   
   
   
   
    String sql=bufferSql.toString();
    ResultSet res = stmt.executeQuery(sql);
    HashMap<String,String> rtn=new HashMap<String,String>();
    rtn.put("_exehql", sql);

    while (res.next()) {
      rtn.put("cnt", String.valueOf(res.getInt("cnt")));
     }
    m_fpsql.close();
    return rtn;
  }
View Full Code Here


    Map stormconf = Utils.readStormConfig();
    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");

    MySqlConn m_fpsql = new MySqlConn(connstr, uname, passwd);

    Connection conn = m_fpsql.getConn();
    Statement stmt = conn.createStatement();

    String sql="select tableShowName,tableName,colsShowName,colsName,colsType,splitString,txtStorePath,indexStorePath,status,username,createtime,lastuptime,joins,percent,resultkb,download_uuid,copy_uuid,memo from adhoc_joins where tableName='"+uuid.replaceAll("'", "")+"' limit 10";
    ResultSet res = stmt.executeQuery(sql);
    HashMap<String,String> rtn=new HashMap<String,String>();
    rtn.put("_exehql", sql);

    boolean issetup=false;
    while (res.next()) {
      rtn.put("tableShowName", res.getString("tableShowName"));
      rtn.put("tableName", res.getString("tableName"));
      rtn.put("colsShowName", res.getString("colsShowName"));
      rtn.put("colsName", res.getString("colsName"));
      rtn.put("colsType", res.getString("colsType"));
      rtn.put("splitString", res.getString("splitString"));
      rtn.put("memo", String.valueOf(res.getString("memo")));

      rtn.put("txtStorePath", res.getString("txtStorePath"));
      rtn.put("indexStorePath", res.getString("indexStorePath"));
      rtn.put("status", res.getString("status"));
      rtn.put("username", res.getString("username"));
      rtn.put("createtime", res.getString("createtime"));
      rtn.put("lastuptime", res.getString("lastuptime"));
      rtn.put("joins", res.getString("joins"));
      rtn.put("percent", res.getString("percent"));
      rtn.put("resultkb", res.getString("resultkb"));
      rtn.put("download_uuid", res.getString("download_uuid"));
      rtn.put("copy_uuid", res.getString("copy_uuid"));
      issetup=true;
        }
    m_fpsql.close();
   
 
    if(!issetup)
    {
      return null;
View Full Code Here

      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");
      MySqlConn conn = new MySqlConn(connstr, uname, passwd);
      MysqlInfo info = new MysqlInfo(conn);
      HashMap<String, String> result2 = info.get(uuid);
      if(result2!=null)
      {
        tableInfo=new HashMap<String, String>();
View Full Code Here

    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();
    }
   
    return jsonObj;

  }
View Full Code Here

    Map stormconf = Utils.readStormConfig();
    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");

    MySqlConn m_fpsql = new MySqlConn(connstr, uname, passwd);

    Connection conn = m_fpsql.getConn();
    Statement stmt = conn.createStatement();

    String sql="select tab_key,tab_value from tab_infos where tab_key='"+key+"' limit 10";
    ResultSet res = stmt.executeQuery(sql);
    JSONObject jsonObj = new JSONObject();

    HashMap<String,String> rtn=new HashMap<String,String>();
    jsonObj.put("code", "0");

    boolean issetup=false;
    while (res.next()) {
      rtn.put("tab_key", res.getString("tab_key"));
      rtn.put("tab_value", res.getString("tab_value"));
      issetup=true;
        }
    m_fpsql.close();
   
    if(issetup)
{
      jsonObj.put("data", rtn.get("tab_key"));
      jsonObj.put("code", "1");
View Full Code Here

    Map stormconf = Utils.readStormConfig();
    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");
 
    MySqlConn m_fpsql = new MySqlConn(connstr, uname, passwd);
   
    Connection conn = m_fpsql.getConn();
    String strSql = "insert into tab_infos " +
        "(tab_key,tab_value)" +
        "values" +
        "(?,?)";
    PreparedStatement m_fps = conn.prepareStatement(strSql);
    try {
      int index=1;
      m_fps.setString(index++, key);
      m_fps.setString(index++, value);
      m_fps.executeUpdate();
      jsonObj.put("code", "1");
      JSONObject daa = new JSONObject();
      jsonObj.put("data", daa);
      jsonObj.put("____debug", m_fps.toString());
    } catch (Exception e) {
      jsonObj.put("____debug2", m_fps.toString());
      jsonObj.put("message", e.toString());
      jsonObj.put("code", "0");
    }finally{
      m_fps.close();
      m_fpsql.close();
    }
   
    return jsonObj.toString();

  }
View Full Code Here

    Map stormconf = Utils.readStormConfig();
    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");
 
    MySqlConn m_fpsql = new MySqlConn(connstr, uname, passwd);
   
    Connection conn = m_fpsql.getConn();
    String strSql = "delete from tab_infos  where tab_key=? ";
    PreparedStatement m_fps = conn.prepareStatement(strSql);
    try {
      int index=1;
      m_fps.setString(index++, key);
      m_fps.executeUpdate();
      jsonObj.put("code", "1");
    } catch (Exception e) {
      jsonObj.put("message", e.toString());
      jsonObj.put("code", "0");
    }finally{
      m_fps.close();
      m_fpsql.close();
    }
   
    return jsonObj.toString();

  }
View Full Code Here

    Map stormconf = Utils.readStormConfig();
    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");
 
    MySqlConn m_fpsql = new MySqlConn(connstr, uname, passwd);
   
    Connection conn = m_fpsql.getConn();
    String strSql = "update tab_infos set tab_value=? where tab_key=? ";
    PreparedStatement m_fps = conn.prepareStatement(strSql);
    try {
      int index=1;
      m_fps.setString(index++, value);
      m_fps.setString(index++, key);
      m_fps.executeUpdate();
      jsonObj.put("code", "1");
      JSONObject daa = new JSONObject();
      jsonObj.put("data", daa);
      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();
    }
   
    return jsonObj.toString();

  }
View Full Code Here

    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();
    String strSql = "insert into adhoc_joins " +
        "(tableShowName,tableName,colsShowName,colsName,colsType,splitString,txtStorePath,indexStorePath,status,username,createtime,lastuptime,joins,percent,memo)" +
        "values" +
        "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    PreparedStatement m_fps = conn.prepareStatement(strSql);
    try {
      int index=1;
      m_fps.setString(index++, tableShowName);
      m_fps.setString(index++, tableName);
      m_fps.setString(index++, colsShowName);
      StringBuffer colsName=new StringBuffer();
      StringBuffer colsType=new StringBuffer();
      String[] cols=colsShowName.split(",");
      String join="";
      HashMap<String,String> colsNames=new HashMap<String, String>();
      for(int i=0;i<cols.length;i++)
      {
        String colname="cols_"+i+"_s";
        colsName.append(join);
        colsName.append(colname);
        colsType.append(join);
        colsType.append("string");
        colsNames.put(cols[i],colname);
        join=",";
      }
      m_fps.setString(index++, colsName.toString());
      m_fps.setString(index++, colsType.toString());
      m_fps.setString(index++, MakeIndex.parseSplit(splitString));
      m_fps.setString(index++, store+"/txt");
      m_fps.setString(index++, store+"/index");
      m_fps.setString(index++, "init");
      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));
     
      StringBuffer joinbuff=new StringBuffer();
      String joinchar="";
      for(String joindesc:joins.split(","))
      {
        String[] arr=joindesc.split(":");
        joinbuff.append(joinchar);
        joinbuff.append(arr[0]);
        joinbuff.append(":");
        joinbuff.append(arr[1]);
        joinbuff.append(":");
        joinbuff.append(colsNames.get(arr[2]));
        joinchar=",";
      }
      m_fps.setString(index++,joinbuff.toString());
      m_fps.setString(index++,"");
      m_fps.setString(index++,String.valueOf(memo));
      m_fps.executeUpdate();
      jsonObj.put("code", "1");
      JSONObject daa = new JSONObject();

      daa.put("tableid", tableName);
      jsonObj.put("data", daa);
      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();
    }
   
    if (callback != null && callback.length() > 0) {
      return callback + "(" + jsonObj.toString() + ")";
    } else {
View Full Code Here

TOP

Related Classes of com.alimama.mdrill.adhoc.MySqlConn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.