Search in sources :

Example 51 with DBUtil

use of ngse.org.DBUtil in project MSEC by Tencent.

the class SharedobjectUpload method insertTable.

private String insertTable(String firstName, String secondName, String tagName, String memo) {
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        return "DB connect failed.";
    }
    String sql;
    List<Object> params = new ArrayList<Object>();
    sql = "insert into t_sharedobject_tag(first_level_service_name,  " + "second_level_service_name,tag_name, memo) values(?,?,?,?)";
    params.add(firstName);
    params.add(secondName);
    params.add(tagName);
    params.add(memo);
    try {
        int addNum = util.updateByPreparedStatement(sql, params);
        if (addNum >= 0) {
            return "success";
        }
        return "insert failed";
    } catch (SQLException e) {
        return "insert failed";
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList)

Aggregations

DBUtil (ngse.org.DBUtil)51 ArrayList (java.util.ArrayList)36 SQLException (java.sql.SQLException)23 Logger (org.apache.log4j.Logger)20 IPPortPair (beans.request.IPPortPair)12 OddSecondLevelServiceIPInfo (beans.dbaccess.OddSecondLevelServiceIPInfo)7 AccessZooKeeper (ngse.org.AccessZooKeeper)6 JsonRPCResponseBase (ngse.org.JsonRPCResponseBase)6 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)5 SecondLevelService (beans.dbaccess.SecondLevelService)4 OddSecondLevelService (beans.dbaccess.OddSecondLevelService)2 ReleasePlan (beans.request.ReleasePlan)2 IOException (java.io.IOException)2 HttpSession (javax.servlet.http.HttpSession)2 CapacityBaseInfo (beans.dbaccess.CapacityBaseInfo)1 CapacityDetailInfo (beans.dbaccess.CapacityDetailInfo)1 IDL (beans.dbaccess.IDL)1 LibraryFile (beans.dbaccess.LibraryFile)1 MachineInfo (beans.dbaccess.MachineInfo)1 OddFirstLevelService (beans.dbaccess.OddFirstLevelService)1