while(rs5.next())
{
String id=rs5.getString("id"); //(NOT NULL)
String unitid=rs5.getString("unitid");
if(unitid==null)
   unitid="";
String unitname=rs5.getString("unitname");
if(unitname==null)
   unitname="";
String name=rs5.getString("name");
if(name==null)
   name="";
String sex=rs5.getString("sex");
if(sex==null)
   sex="";
String folkcode=rs5.getString("folkcode");
if(folkcode==null)
   folkcode="";
String birth=rs5.getString("birth");
if(birth==null)
   birth="";
String personcode=rs5.getString("personcode");
if(personcode==null)
   personcode="";
String duty=rs5.getString("duty");
if(duty==null)
   duty="";
String politycode=rs5.getString("politycode");
if(politycode==null)
   politycode="";
String degreecode=rs5.getString("degreecode");
if(degreecode==null)
   degreecode="";
String post=rs5.getString("post");
if(post==null)
   post="";
String workcode=rs5.getString("workcode");
if(workcode==null)
   workcode="";
String officetel=rs5.getString("officetel");
if(officetel==null)
   officetel="";
String hometel=rs5.getString("hometel");
if(hometel==null)
  hometel="";
String movetel=rs5.getString("movetel");
if(movetel==null)
   movetel="";
String notes=rs5.getString("notes");
if(notes==null)
   notes="";
conn5.close();
String sql="insert into sec_bwglry (id,unitid,unitname,name,sex,folkcode,birth,personcode,duty,politycode,degreecode,post,workcode,officetel,hometel,movetel,notes)"+"values('"+bwglid+"','"+unitid+"','"+unitname+"','"+name+"','"+sex+"','"+folkcode+"','"+birth+"','"+personcode+"','"+duty+"','"+politycode+"','"+degreecode+"','"+post+"','"+workcode+"','"+officetel+"','"+hometel+"','"+movetel+"','"+notes+"')";
try
{
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
stmt2.executeUpdate(tmp2);
conn2.close();
}
catch(SQLException e)
{
out.print("SQL异常!");
}
用这样的处理后,只能向数据库了增加一条记录!!
谢谢,给出具体点的说明!

解决方案 »

  1.   

    String tmp2try
    {
    Connection conn2= DriverManager.getConnection(url,user,password);
    Statement stmt2=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
    stmt2.executeUpdate(tmp2);
    conn2.close();
    }
    catch(SQLException e)
    {
    out.print("SQL异常!");
    }
      

  2.   

    public int insertT_KSLKYTHND(ShowDetaileEntDAOData data) throws DAOException {
            if (log.isTraceEnabled()) {
                log.trace("entering ShowDetaileEntDAO.insertT_KSLKYTHND()");
            }        String createSql = getInsertT_KSLKYTHNDSql(data);
            PreparedStatement stmt = null;
            int retNo = 0;
            try {
                String realSql = rdbmsStrategy.convertInsertSql(createSql, ShowDetaileEntDAO.class, "insertT_KSLKYTHND");
                if (log.isDebugEnabled()) {
                    log.debug(realSql);
                }
                stmt = getConnection().prepareStatement(realSql);
                JDBCUtil.setTimestamp(stmt, 1, data.getCREATED_DATE());
                JDBCUtil.setString(stmt, 2, data.getCREATED_BY(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 3, data.getCREATED_PRG_NM(), rdbmsStrategy);
                JDBCUtil.setTimestamp(stmt, 4, data.getUPDATED_DATE());
                JDBCUtil.setString(stmt, 5, data.getUPDATED_BY(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 6, data.getUPDATED_PRG_NM(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 7, data.getCOR_CDE(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 8, data.getTAN_CDE(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 9, data.getNEW_KYT_CDE(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 10, data.getNEW_KYT_NAM_SEI(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 11, data.getNEW_KYT_NAM_RYK(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 12, data.getNEW_BMN_CDE(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 13, data.getNEW_BMN_NAM_SEI(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 14, data.getNEW_BMN_NAM_RYK(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 15, data.getNEW_YKO_SDY(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 16, data.getGEN_KYT_CDE(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 17, data.getGEN_KYT_NAM_SEI(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 18, data.getGEN_KYT_NAM_RYK(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 19, data.getGEN_BMN_CDE(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 20, data.getGEN_BMN_NAM_SEI(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 21, data.getGEN_BMN_NAM_RYK(), rdbmsStrategy);
                JDBCUtil.setString(stmt, 22, data.getGEN_YKO_SDY(), rdbmsStrategy);
                long startTime = 0;
                if (log.isInfoEnabled()) {
                    startTime = System.currentTimeMillis();
                }
                retNo = stmt.executeUpdate();
                if (log.isInfoEnabled()) {
                    long finishTime = System.currentTimeMillis();
                    log.info("elapsed time: " + (finishTime - startTime) + "ms");
                }
                if (log.isDebugEnabled()) {
                    log.debug("insertT_KSLKYTHND: inserted count: " + retNo);
                }
            } catch (SQLException ex) {
                throw new DAOException("SQLException occured. ", ex);
            } finally {
                JDBCUtil.closeAll(stmt);
            }
            if (log.isTraceEnabled()) {
                log.trace("exiting ShowDetaileEntDAO.insertT_KSLKYTHND()");
            }
            return retNo;
        }
    *******************************************************
    public LogicData execute(AP01LogicData inputLogicData)throws LogicException {
    Transaction tx = getTransaction();
    int i = 0;
    try {
    for (i = 0; i < intDetailsSize; i++) {
    objApDao.insertT_KSLKYTHND(daoDataInput);
    }
    tx.commit();
    ret.setERROR("success");
    } catch (Exception t) {
    int intExceptionType = DBUtil.getExceptionType(t);
    switch (intExceptionType) {
    case ConstantUtil.UNIQUE_ERR:
    ret.setERROR("unique_error");
    ret.setRowNo(String.valueOf(i));
    break;
    default:

    ret.setERROR("error");
    LogicUtil.throwWrappedLogicException(t);
    break;
    }
    } finally {
    if (tx.isTransactionActive()) {
    tx.rollback();
    }
    }
    return ret;
    }*********************************************************************************
    只是一个思路,具体方法自己干!