NutzCN Logo
问答 nutz 插入问题用sql语句插入没有问题用dao().insert(ci)插入报错;
发布于 1964天前 作者 qq_6c7a07b7 1443 次浏览 复制 上一个帖子 下一个帖子
标签:
  For example:> "INSERT INTO CREDITINFO(CREDITNAME,CUSTOMER,CLASSCODE,BANKNAME,AREACODE,AREANAME,AMOUNTRANGE,MONTHRANGE,RATERANGE,ADDITIONCOST,USERANGE,GUARANTYWAY,IMAGEURL,HANDLEFLOW,REQUIRECONDITION,PRODUCTFEATURE,PHONENUM) VALUES('优质茶企贷','景德镇市茶叶企业及合作社企业','104','中国银行','360200','景德镇市','0-200','12','4.35%—6.96%','无','流动资金贷款,主要用于企业生产经营、资金周转等等',NULL,NULL,'','','(一)材料收集;(二)资信审查;(三)授信方案;(四)放款。','(一)企业生产经营满2年以上,企业和实际控制人不涉及民间借贷,征信报告和反欺诈调查无负面信息;(二)企业及其实际控制人经营性授信银行不超过3家(含我行),他行授信还本付息情况正常,无恶意逾期现象;(三)基础材料。') "
19:25:24,762 DEBUG  NutDaoExecutor.exec - SQLException
com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-1585, SQLSTATE=54048, SQLERRMC=null, DRIVER=4.16.53
	at com.ibm.db2.jcc.am.fd.a(fd.java:744)
	at com.ibm.db2.jcc.am.fd.a(fd.java:60)
	at com.ibm.db2.jcc.am.fd.a(fd.java:127)
	at com.ibm.db2.jcc.am.to.c(to.java:2771)
	at com.ibm.db2.jcc.am.to.d(to.java:2759)
	at com.ibm.db2.jcc.am.to.a(to.java:2192)
	at com.ibm.db2.jcc.am.uo.a(uo.java:7827)
	at com.ibm.db2.jcc.t4.ab.h(ab.java:141)
	at com.ibm.db2.jcc.t4.ab.b(ab.java:41)
	at com.ibm.db2.jcc.t4.o.a(o.java:32)
	at com.ibm.db2.jcc.t4.tb.i(tb.java:145)
	at com.ibm.db2.jcc.am.to.kb(to.java:2161)
	at com.ibm.db2.jcc.am.uo.Dc(uo.java:3820)
	at com.ibm.db2.jcc.am.Connection.findAutoGeneratedKeysColumn(Connection.java:6734)
	at com.ibm.db2.jcc.am.Connection.prepareStatement(Connection.java:2655)
	at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:516)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:301)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:159)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:126)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:93)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:82)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:56)
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:149)
	at com.iqingmai.base.module.QmFileInfoAction.fileupload(QmFileInfoAction.java:184)
	at com.iqingmai.base.module.QmFileInfoAction$FM$fileupload$cc72b9cbdb995b35d4a95ef891bf8e28.invoke(QmFileInfoAction.java)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:38)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:744)
!Nutz SQL Error: 'INSERT INTO CREDITINFO(CREDITNAME,CUSTOMER,CLASSCODE,BANKNAME,AREACODE,AREANAME,AMOUNTRANGE,MONTHRANGE,RATERANGE,ADDITIONCOST,USERANGE,GUARANTYWAY,IMAGEURL,HANDLEFLOW,REQUIRECONDITION,PRODUCTFEATURE,PHONENUM) VALUES('优质茶企贷','景德镇市茶叶企业及合作社企业','104','中国银行','360200','景德镇市','0-200','12','4.35%—6.96%','无','流动资金贷款,主要用于企业生产经营、资金周转等等',NULL,NULL,'','','(一)材料收集;(二)资信审查;(三)授信方案;(四)放款。','(一)企业生产经营满2年以上,企业和实际控制人不涉及民间借贷,征信报告和反欺诈调查无负面信息;(二)企业及其实际控制人经营性授信银行不超过3家(含我行),他行授信还本付息情况正常,无恶意逾期现象;(三)基础材料。') '
PreparedStatement: 
'INSERT INTO CREDITINFO(CREDITNAME,CUSTOMER,CLASSCODE,BANKNAME,AREACODE,AREANAME,AMOUNTRANGE,MONTHRANGE,RATERANGE,ADDITIONCOST,USERANGE,GUARANTYWAY,IMAGEURL,HANDLEFLOW,REQUIRECONDITION,PRODUCTFEATURE,PHONENUM) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) '
CaseMessage=DB2 SQL Error: SQLCODE=-1585, SQLSTATE=54048, SQLERRMC=null, DRIVER=4.16.53


@At("/file/fileupload")
	@AdaptBy(type = UploadAdaptor.class, args = { "ioc:upload" })
	public Map<String, String> fileupload(
			@Param("file")TempFile tempFile,
			@Param("infoId")String infoId,
			@Param("resCode")String resCode,
			@Param("flag")String flag,
			HttpServletRequest request
		)
	{
		if(Strings.isNotBlank(flag) && flag.equals("1")){
			//清空文件上传表
			dao().clear("qm_file_info", Cnd.where("info_id", "=",infoId));
		}
		Map<String, String> uploadResult = new HashMap<String, String>();
		FileObject fileObj = null;
	    fileObj = FileUploadHelper.uploadFile(tempFile, FileObject.XD_PATH_ATTACHMENTS, IdUtil.uuid());
		
	    if(fileObj==null){
			uploadResult.put("state", "false");
		}
		if("".equals(infoId) && "credit".equals(resCode) || "".equals(infoId) && "dept".equals(resCode)){
			infoId = IdUtil.uuid();
		}
		QmFileInfo fileinfo = new QmFileInfo();
		fileinfo.setId(fileObj.getSaveFileNameNoExt());
		fileinfo.setInfoId(infoId);
		fileinfo.setFileSize((int) tempFile.getSize());
		fileinfo.setFileTitle(fileObj.getShowFileNameNoExt());
		fileinfo.setFileName(fileObj.getSaveFileNameNoExt());
		fileinfo.setFileExt(fileObj.getFileExt());
		fileinfo.setFilePath(fileObj.getRelativeDir());
		fileinfo.setContentType(fileObj.getContentType());
		fileinfo.setUploadTime(new Date());
		fileinfo.setUploadUserid(super.getUserId());
		fileinfo.setUploadUsername(super.getUserName());
		fileinfo.setValidFlag("0");
		fileinfo.setResCode(resCode);
		dao().insert(fileinfo);

		uploadResult.put("state", "true");
		uploadResult.put("contentType", tempFile.getMeta().getContentType());
		
		String fileName = tempFile.getMeta().getFileLocalName();
		fileName = fileName.replaceAll(" ", "");
		uploadResult.put("fileName", fileName);
		uploadResult.put("filePath", fileObj.getRelativeDir().replace("\\", "/")+"/"+fileObj.getSaveFileNameNoExt()+"."+fileObj.getFileExt());
		uploadResult.put("fileId", fileinfo.getId());

		String path = fileObj.getAbsoluteDir().replace("\\", "/");
		String filePath = path.replace("//","/")+"/"+fileObj.getSaveFileNameNoExt()+"."+fileObj.getFileExt();

		try{
			//TODO 读取导入信贷产品信息
			if("credit".equals(resCode)) {
				//TODO 删除已有信贷产品信息
				String str = "delete from CREDITINFO";
				Sql sql = Sqls.create(str);
				sql.setCallback(Sqls.callback.records());
				//ao().execute(sql);
				//dao().clear(CreditInfo.class);

				//TODO 读取导入的文件
				InputStream ist = new FileInputStream(filePath);
				Workbook wb = Workbook.getWorkbook(ist);
				Sheet st = wb.getSheet(0);
				if (st != null) {
					for (int i = 1; i < st.getRows(); i++) {
						String creditName = st.getCell(0, i).getContents().trim();
						if (creditName == null || creditName.equals(""))
							break;
						String customer = st.getCell(1, i).getContents().trim();
						String classCode = st.getCell(2, i).getContents().trim();
						String bankName = st.getCell(3, i).getContents().trim();
						String areaCode = st.getCell(4, i).getContents().trim();
						String areaName = st.getCell(5, i).getContents().trim();
						String amountRange = st.getCell(6, i).getContents().trim();
						String monthRange = st.getCell(7, i).getContents().trim();
						String rateRange = st.getCell(8, i).getContents().trim();
						String additionCost = st.getCell(9, i).getContents().trim();
						String useRange = st.getCell(10, i).getContents().trim();
						String handleFlow = st.getCell(11, i).getContents().trim();
						String requireCondition = st.getCell(12, i).getContents()
								.trim();
						String productFeature = st.getCell(13, i).getContents()
								.trim();
						String phoneNum = st.getCell(14, i).getContents().trim();

						CreditInfo ci = new CreditInfo();
						ci.setCreditName(creditName);
						ci.setCustomer(customer);
						ci.setClassCode(classCode);
						ci.setBankName(bankName);
						ci.setAreaCode(areaCode);
						ci.setAreaName(areaName);
						ci.setAmountRange(amountRange);
						ci.setMonthRange(monthRange);
						ci.setRateRange(rateRange);
						ci.setAdditionCost(additionCost);
						ci.setUseRange(useRange);
						ci.setHandleFlow(handleFlow);
						ci.setRequireCondition(requireCondition);
						ci.setProductFeature(productFeature);
						ci.setPhoneNum(phoneNum);
					//	String str1 = "INSERT INTO CREDITINFO(CREDITNAME,CUSTOMER,CLASSCODE,BANKNAME,AREACODE,AREANAME,AMOUNTRANGE,MONTHRANGE,RATERANGE,ADDITIONCOST,USERANGE,GUARANTYWAY,IMAGEURL,HANDLEFLOW,REQUIRECONDITION,PRODUCTFEATURE,PHONENUM) VALUES('陶瓷电商通宝','景德镇市陶瓷电商企业','104','中国银行','360200','景德镇市','0-200','12','4.35%—6.96%','无','1111111',NULL,NULL,'','','111111','11111111')";
					//	Sql sql1 = Sqls.create(str1);
					//	sql1.setCallback(Sqls.callback.records());
					//	dao().execute(sql1);
						dao().insert(ci);

					}
					wb.close();
					ist.close();
				} else {
					wb.close();
					ist.close();
				}
			}
			//TODO 读取导入债务融资工具信息
			if("dept".equals(resCode)) {

				//TODO 删除已有债务融资工具信息
				String str = "delete from DEBTFACILITY";
				Sql sql = Sqls.create(str);
				sql.setCallback(Sqls.callback.records());
				dao().execute(sql);
				//dao().clear(DebtFacility.class);

				//TODO 读取导入的债务融资工具信息文件
				InputStream ist = new FileInputStream(filePath);
				Workbook wb = Workbook.getWorkbook(ist);
				Sheet st = wb.getSheet(0);
				if (st != null) {
					for (int i = 1; i < st.getRows(); i++) {
						String debtName = st.getCell(0, i).getContents().trim();
						if (debtName == null || debtName.equals(""))
							break;
						String debtDefine = st.getCell(1, i).getContents().trim();
						String productFeature = st.getCell(2, i).getContents()
								.trim();
						String advantage = st.getCell(3, i).getContents().trim();
						String publisher = st.getCell(4, i).getContents().trim();
						String careQues = st.getCell(5, i).getContents().trim();

						DebtFacility df = new DebtFacility();
						df.setDebtName(debtName);
						df.setDebtDefine(debtDefine);
						df.setProductFeature(productFeature);
						df.setAdvantage(advantage);
						df.setPublisher(publisher);
						df.setCareQues(careQues);
						dao().insert(df);
					}
					wb.close();
					ist.close();
				} else {
					wb.close();
					ist.close();
				}
			}
		}catch (Exception e){
			System.out.println(e.getMessage());
		}
		return uploadResult;
		
	}
package com.iqingmai.sjcj.bean;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.Table;

/**
 * 信贷产品信息表
 * @author Administrator
 *
 */
@Table("CREDITINFO")
public class CreditInfo {

	/**
	 *
	 */
	@Id
	@Column("CREDITID")
	private int creditId;

	@Column("CREDITNAME")
	private String creditName;

	@Column("CUSTOMER")
	private String customer;

	@Column("CLASSCODE")
	private String classCode;

	@Column("BANKNAME")
	private String bankName;

	@Column("AREACODE")
	private String areaCode;

	@Column("AREANAME")
	private String areaName;

	@Column("AMOUNTRANGE")
	private String amountRange;

	@Column("MONTHRANGE")
	private String monthRange;

	@Column("RATERANGE")
	private String rateRange;

	@Column("ADDITIONCOST")
	private String additionCost;

	@Column("USERANGE")
	private String useRange;

	@Column("GUARANTYWAY")
	private String guarantyWay;

	@Column("IMAGEURL")
	private String imageUrl;

	@Column("HANDLEFLOW")
	private String handleFlow;

	@Column("REQUIRECONDITION")
	private String requireCondition;

	@Column("PRODUCTFEATURE")
	private String productFeature;

	@Column("PHONENUM")
	private String phoneNum;

	public int getCreditId() {
		return creditId;
	}

	public void setCreditId(int creditId) {
		this.creditId = creditId;
	}

	public String getCreditName() {
		return creditName;
	}

	public void setCreditName(String creditName) {
		this.creditName = creditName;
	}

	public String getCustomer() {
		return customer;
	}

	public void setCustomer(String customer) {
		this.customer = customer;
	}

	public String getClassCode() {
		return classCode;
	}

	public void setClassCode(String classCode) {
		this.classCode = classCode;
	}

	public String getBankName() {
		return bankName;
	}

	public void setBankName(String bankName) {
		this.bankName = bankName;
	}

	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getAmountRange() {
		return amountRange;
	}

	public void setAmountRange(String amountRange) {
		this.amountRange = amountRange;
	}

	public String getMonthRange() {
		return monthRange;
	}

	public void setMonthRange(String monthRange) {
		this.monthRange = monthRange;
	}

	public String getRateRange() {
		return rateRange;
	}

	public void setRateRange(String rateRange) {
		this.rateRange = rateRange;
	}

	public String getAdditionCost() {
		return additionCost;
	}

	public void setAdditionCost(String additionCost) {
		this.additionCost = additionCost;
	}

	public String getUseRange() {
		return useRange;
	}

	public void setUseRange(String useRange) {
		this.useRange = useRange;
	}

	public String getGuarantyWay() {
		return guarantyWay;
	}

	public void setGuarantyWay(String guarantyWay) {
		this.guarantyWay = guarantyWay;
	}

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	public String getHandleFlow() {
		return handleFlow;
	}

	public void setHandleFlow(String handleFlow) {
		this.handleFlow = handleFlow;
	}

	public String getRequireCondition() {
		return requireCondition;
	}

	public void setRequireCondition(String requireCondition) {
		this.requireCondition = requireCondition;
	}

	public String getProductFeature() {
		return productFeature;
	}

	public void setProductFeature(String productFeature) {
		this.productFeature = productFeature;
	}

	public String getPhoneNum() {
		return phoneNum;
	}

	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}
}

2 回复

用写sql的方法dao执行是可以插入的

添加回复
请先登陆
回到顶部