NutzCN Logo
问答 【nutz dao问题】执行sql语句不会报错,但是当执行dao.execute(sql)时报无效列索引的问题
发布于 3006天前 作者 jacky013 4686 次浏览 复制 上一个帖子 下一个帖子
标签:

这个代码是其他人写,我刚刚接手过来的,我们总共有100多个pojo类,需要写成通用的处理逻辑因此需要使用拼接字符串的方式来处理,
我直接执行如下的sql,不会报错:
insert into resourcedba.FiberConverter
(RESOURCEID,
ID,
DeviceID,
OriginalID,
Name,
TypeCode,
SubTypeCode,
Status,
IsAsset,
FirstRunningTime,
MaintenanceExpiresTime,
Vendor,
SN,
Brand,
Model,
AreaCode,
UseCorporation,
UseDepartment,
OperateCorporation,
OperateDepartment,
OperateGroup,
Location,
UsePurpose,
TechniqueCode,
TechniQueName,
SetPointCode,
PositionCode,
Description,
CreateBy,
CreateTime,
CreateSource,
UpdateBy,
UpdateTime,
IsFixedAsset,
FixedAssetID,
Administrator,
PortType,
Speed,
PortNum)
values
(RESOURCEDBA.SEQ_RESOURCEID.nextval,
'99-0306-2016-001000',
'99-0306-2016-001000',
'99-0306-2016-001000',
'testNULL',
'03',
'0306',
'00',
'0',
to_date('2016-08-05 15:42:19', 'yyyy-mm-dd hh24:mi:ss'),
to_date('2016-08-05 15:44:55', 'yyyy-mm-dd hh24:mi:ss'),
'供应商供应商供应商供应商供应商',
'产品序列号产品序列号产品序列号产品序列号产品序列号',
'品牌品牌品牌品牌品牌品牌品牌品牌品牌品牌品牌',
'配置型号配置型号配置型号配置型号配置型号',
'99',
'99',
'317BE9B0F04D8DCCE050007F01003E55',
'99',
NULL,
'运维(保管)班组运维(保管)班组运维(保管)班组',
'配置位置配置位置配置位置配置位置配置位置配置位置配',
'用途概述用途概述用途概述用途概述',
'工艺(功能)编码工艺(功能)编码',
'工艺(功能)名称工艺(功能)名称',
'安装点标识码安装点标识码',
'位置标识码位置标识码',
'备注备注备注备注备注备注备注备注备注备注备注备注',
'7D0CC2EB8B87458C833B379903C099BF',
to_date('2016-08-05 15:42:06', 'yyyy-mm-dd hh24:mi:ss'),
NULL,
'4F3FCD5694B040A28E43E52B97684357',
to_date('2016-08-18 17:32:23', 'yyyy-mm-dd hh24:mi:ss'),
'0',
NULL,
'35EE730FB37073A0E050007F0100D26C',
'ST',
'98610549861054986105498610549861054986105498610549',
'98610549861054986105498610549861054986105498610549')

异常信息如下:
2016-08-18 17:34:01,723 DEBUG [dao.impl.sql.run.NutDaoExecutor] - insert into resourcedba.FiberConverter(RESOURCEID,ID,DeviceID,OriginalID,Name,TypeCode,SubTypeCode,Status,IsAsset,FirstRunningTime,MaintenanceExpiresTime,Vendor,SN,Brand,Model,AreaCode,UseCorporation,UseDepartment,OperateCorporation,OperateDepartment,OperateGroup,Location,UsePurpose,TechniqueCode,TechniQueName,SetPointCode,PositionCode,Description,CreateBy,CreateTime,CreateSource,UpdateBy,UpdateTime,IsFixedAsset,FixedAssetID,Administrator,PortType,Speed,PortNum) values(RESOURCEDBA.SEQ_RESOURCEID.nextval,'99-0306-2016-001000','99-0306-2016-001000','99-0306-2016-001000','testNULL','03','0306','00','0',to_date('2016-08-05 15:42:19', 'yyyy-mm-dd hh24:mi:ss'),to_date('2016-08-05 15:44:55', 'yyyy-mm-dd hh24:mi:ss'),'供应商供应商供应商供应商供应商','产品序列号产品序列号产品序列号产品序列号产品序列号','品牌品牌品牌品牌品牌品牌品牌品牌品牌品牌品牌','配置型号配置型号配置型号配置型号配置型号','99','99','317BE9B0F04D8DCCE050007F01003E55','99',NULL,'运维(保管)班组运维(保管)班组运维(保管)班组','配置位置配置位置配置位置配置位置配置位置配置位置配','用途概述用途概述用途概述用途概述','工艺(功能)编码工艺(功能)编码','工艺(功能)名称工艺(功能)名称','安装点标识码安装点标识码','位置标识码位置标识码','备注备注备注备注备注备注备注备注备注备注备注备注','7D0CC2EB8B87458C833B379903C099BF',to_date('2016-08-05 15:42:06', 'yyyy-mm-dd hh24:mi:ss'),NULL,'4F3FCD5694B040A28E43E52B97684357',to_date('2016-08-18 17:32:23', 'yyyy-mm-dd hh24:mi:ss'),'0',NULL,'35EE730FB37073A0E050007F0100D26C','ST','98610549861054986105498610549861054986105498610549','98610549861054986105498610549861054986105498610549')
2016-08-18 17:34:01,724 DEBUG [dao.impl.sql.run.NutDaoExecutor] - SQLException
java.sql.SQLException: Invalid column index
at oracle.jdbc.driver.OraclePreparedStatement.setNullCritical(OraclePreparedStatement.java:4591)
at oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:4578)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setNull(OraclePreparedStatementWrapper.java:1285)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.setNull(DruidPooledPreparedStatement.java:266)
at org.nutz.dao.jdbc.Jdbcs$Adaptor$1.set(Jdbcs.java:251)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:264)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:81)
at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:264)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:64)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:219)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:197)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:967)
at com.nari.nwims.dataloader.biz.resource.service.ConfService.add(ConfService.java:621)
at com.nari.nwims.dataloader.biz.resource.service.ConfService.save(ConfService.java:323)
at com.nari.nwims.dataloader.biz.resource.service.ConfService.saveConf(ConfService.java:134)
at com.nari.nwims.dataloader.biz.resource.ws.ConfSyncImpl.getCIToMonitor(ConfSyncImpl.java:35)
at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:181)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:97)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:69)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInvokerInterceptor.java:126)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:253)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:261)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1088)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1024)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:662)

15 回复

直接拼出来的SQL?

嗯,是的,我们有100多个不同的类,我们是利用反射的原理,获得对应的类及其字段,然后和json串里的值拼接成sql语句
样例json串如下:
其中FiberConverter是类名,像IsAsset这种是字段名
{
"FiberConverter": [
{
"IsAsset": 0,
"Brand": "品牌品牌品牌品牌品牌品牌品牌品牌品牌品牌品牌",
"DeviceID": "99-0306-2016-001000",
"Model": "配置型号配置型号配置型号配置型号配置型号",
"UseCorporation": "99",
"UpdateBy": "4F3FCD5694B040A28E43E52B97684357",
"UsePurpose": "用途概述用途概述用途概述用途概述",
"Action": "add",
"TypeCode": "03",
"CreateBy": "7D0CC2EB8B87458C833B379903C099BF",
"ID": "99-0306-2016-001000",
"TechniQueName": "工艺(功能)名称工艺(功能)名称",
"IsFixedAsset": 0,
"PortType": "ST",
"TechniqueCode": "工艺(功能)编码工艺(功能)编码",
"FirstRunningTime": "2016-08-05 15:42:19",
"Description": "备注备注备注备注备注备注备注备注备注备注备注备注",
"Administrator": "35EE730FB37073A0E050007F0100D26C",
"PortNum": "98610549861054986105498610549861054986105498610549",
"CreateSource": null,
"FixedAssetID": null,
"Location": "配置位置配置位置配置位置配置位置配置位置配置位置配",
"UpdateTime": "2016-08-18 17:32:23",
"SN": "产品序列号产品序列号产品序列号产品序列号产品序列号",
"PositionCode": "位置标识码位置标识码",
"Name": "test@光纤收发器",
"MaintenanceExpiresTime": "2016-08-05 15:44:55",
"Status": "00",
"Speed": "98610549861054986105498610549861054986105498610549",
"AreaCode": "99",
"OperateCorporation": "99",
"Vendor": "供应商供应商供应商供应商供应商",
"SetPointCode": "安装点标识码安装点标识码",
"CreateTime": "2016-08-05 15:42:06",
"OriginalID": "99-0306-2016-001000",
"OperateGroup": "运维(保管)班组运维(保管)班组运维(保管)班组",
"SubTypeCode": "0306",
"UseDepartment": "317BE9B0F04D8DCCE050007F01003E55",
"OpeateDepartment": "317BE9B0F04D8DCCE050007F01003E55"
}
]
}
样例pojo类如下:
package com.nari.nwims.cmdb.resource;

import com.alibaba.fastjson.annotation.JSONField;
import com.nari.nwims.cmdb.abstractmodel.AbstractModel;
import com.nari.nwims.cmdb.annotation.DBField;
import com.nari.nwims.cmdb.annotation.Model;
import java.util.Date;

import org.apache.bval.constraints.NotEmpty;

/**
* FiberConverter generated by shell
*/
@Model("FiberConverter")
public class FiberConverter extends AbstractModel {

private static final long serialVersionUID = 1683537187617398495L;
@DBField(name="RESOURCEID",key=true,autogen=true)
private String resourceid;

//@NotEmpty
@JSONField(name="ID")
@DBField(name="ID")
private String ID;

@JSONField(name="DeviceID")
@DBField(name="DeviceID")
private String DeviceID;

@JSONField(name="OriginalID")
@DBField(name="OriginalID")
private String OriginalID;

//@NotEmpty
@JSONField(name="Name")
@DBField(name="Name")
private String Name;

//@NotEmpty
@JSONField(name="TypeCode")
@DBField(name="TypeCode")
private String TypeCode;

//@NotEmpty
@JSONField(name="SubTypeCode")
@DBField(name="SubTypeCode")
private String SubTypeCode;

//@NotEmpty
@JSONField(name="Status")
@DBField(name="Status")
private String Status;

//@NotEmpty
@JSONField(name="IsAsset")
@DBField(name="IsAsset")
private String IsAsset;

//@NotEmpty
@JSONField(name="FirstRunningTime")
@DBField(name="FirstRunningTime")
private Date FirstRunningTime;

@JSONField(name="MaintenanceExpiresTime")
@DBField(name="MaintenanceExpiresTime")
private Date MaintenanceExpiresTime;

//@NotEmpty
@JSONField(name="Vendor")
@DBField(name="Vendor")
private String Vendor;

//@NotEmpty
@JSONField(name="SN")
@DBField(name="SN")
private String SN;

//@NotEmpty
@JSONField(name="Brand")
@DBField(name="Brand")
private String Brand;

//@NotEmpty
@JSONField(name="Model")
@DBField(name="Model")
private String Model;

//@NotEmpty
@JSONField(name="AreaCode")
@DBField(name="AreaCode")
private String AreaCode;

//@NotEmpty
@JSONField(name="UseCorporation")
@DBField(name="UseCorporation")
private String UseCorporation;

//@NotEmpty
@JSONField(name="UseDepartment")
@DBField(name="UseDepartment")
private String UseDepartment;

//@NotEmpty
@JSONField(name="OperateCorporation")
@DBField(name="OperateCorporation")
private String OperateCorporation;

//@NotEmpty
@JSONField(name="OperateDepartment")
@DBField(name="OperateDepartment")
private String OperateDepartment;

//@NotEmpty
@JSONField(name="OperateGroup")
@DBField(name="OperateGroup")
private String OperateGroup;

//@NotEmpty
@JSONField(name="Location")
@DBField(name="Location")
private String Location;

@JSONField(name="UsePurpose")
@DBField(name="UsePurpose")
private String UsePurpose;

@JSONField(name="TechniqueCode")
@DBField(name="TechniqueCode")
private String TechniqueCode;

@JSONField(name="TechniQueName")
@DBField(name="TechniQueName")
private String TechniQueName;

@JSONField(name="SetPointCode")
@DBField(name="SetPointCode")
private String SetPointCode;

@JSONField(name="PositionCode")
@DBField(name="PositionCode")
private String PositionCode;

@JSONField(name="Description")
@DBField(name="Description")
private String Description;

@JSONField(name="CreateBy")
@DBField(name="CreateBy")
private String CreateBy;

@JSONField(name="CreateTime")
@DBField(name="CreateTime")
private Date CreateTime;

@JSONField(name="CreateSource")
@DBField(name="CreateSource")
private String CreateSource;

@JSONField(name="UpdateBy")
@DBField(name="UpdateBy")
private String UpdateBy;

@JSONField(name="UpdateTime")
@DBField(name="UpdateTime")
private Date UpdateTime;

@JSONField(name="IsFixedAsset")
@DBField(name="IsFixedAsset")
private String IsFixedAsset;

@JSONField(name="FixedAssetID")
@DBField(name="FixedAssetID")
private String FixedAssetID;

@JSONField(name="Administrator")
@DBField(name="Administrator")
private String Administrator;

//@NotEmpty
@JSONField(name="PortType")
@DBField(name="PortType")
private String PortType;

//@NotEmpty
@JSONField(name="Speed")
@DBField(name="Speed")
private String Speed;

//@NotEmpty
@JSONField(name="PortNum")
@DBField(name="PortNum")
private String PortNum;

public void setID(String ID) {
this.ID = ID;
}

public String getID() {
return this.ID;
}

public void setDeviceID(String DeviceID) {
this.DeviceID = DeviceID;
}

public String getDeviceID() {
return this.DeviceID;
}

public void setOriginalID(String OriginalID) {
this.OriginalID = OriginalID;
}

public String getOriginalID() {
return this.OriginalID;
}

public void setName(String Name) {
this.Name = Name;
}

public String getName() {
return this.Name;
}

public void setTypeCode(String TypeCode) {
this.TypeCode = TypeCode;
}

public String getTypeCode() {
return this.TypeCode;
}

public void setSubTypeCode(String SubTypeCode) {
this.SubTypeCode = SubTypeCode;
}

public String getSubTypeCode() {
return this.SubTypeCode;
}

public void setStatus(String Status) {
this.Status = Status;
}

public String getStatus() {
return this.Status;
}

public void setIsAsset(String IsAsset) {
this.IsAsset = IsAsset;
}

public String getIsAsset() {
return this.IsAsset;
}

public void setFirstRunningTime(Date FirstRunningTime) {
this.FirstRunningTime = FirstRunningTime;
}

public Date getFirstRunningTime() {
return this.FirstRunningTime;
}

public void setMaintenanceExpiresTime(Date MaintenanceExpiresTime) {
this.MaintenanceExpiresTime = MaintenanceExpiresTime;
}

public Date getMaintenanceExpiresTime() {
return this.MaintenanceExpiresTime;
}

public void setVendor(String Vendor) {
this.Vendor = Vendor;
}

public String getVendor() {
return this.Vendor;
}

public void setSN(String SN) {
this.SN = SN;
}

public String getSN() {
return this.SN;
}

public void setBrand(String Brand) {
this.Brand = Brand;
}

public String getBrand() {
return this.Brand;
}

public void setModel(String Model) {
this.Model = Model;
}

public String getModel() {
return this.Model;
}

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

public String getAreaCode() {
return this.AreaCode;
}

public void setUseCorporation(String UseCorporation) {
this.UseCorporation = UseCorporation;
}

public String getUseCorporation() {
return this.UseCorporation;
}

public void setUseDepartment(String UseDepartment) {
this.UseDepartment = UseDepartment;
}

public String getUseDepartment() {
return this.UseDepartment;
}

public void setOperateCorporation(String OperateCorporation) {
this.OperateCorporation = OperateCorporation;
}

public String getOperateCorporation() {
return this.OperateCorporation;
}

public void setOperateDepartment(String OperateDepartment) {
this.OperateDepartment = OperateDepartment;
}

public String getOperateDepartment() {
return this.OperateDepartment;
}

public void setOperateGroup(String OperateGroup) {
this.OperateGroup = OperateGroup;
}

public String getOperateGroup() {
return this.OperateGroup;
}

public void setLocation(String Location) {
this.Location = Location;
}

public String getLocation() {
return this.Location;
}

public void setUsePurpose(String UsePurpose) {
this.UsePurpose = UsePurpose;
}

public String getUsePurpose() {
return this.UsePurpose;
}

public void setTechniqueCode(String TechniqueCode) {
this.TechniqueCode = TechniqueCode;
}

public String getTechniqueCode() {
return this.TechniqueCode;
}

public void setTechniQueName(String TechniQueName) {
this.TechniQueName = TechniQueName;
}

public String getTechniQueName() {
return this.TechniQueName;
}

public void setSetPointCode(String SetPointCode) {
this.SetPointCode = SetPointCode;
}

public String getSetPointCode() {
return this.SetPointCode;
}

public void setPositionCode(String PositionCode) {
this.PositionCode = PositionCode;
}

public String getPositionCode() {
return this.PositionCode;
}

public void setDescription(String Description) {
this.Description = Description;
}

public String getDescription() {
return this.Description;
}

public void setCreateBy(String CreateBy) {
this.CreateBy = CreateBy;
}

public String getCreateBy() {
return this.CreateBy;
}

public void setCreateTime(Date CreateTime) {
this.CreateTime = CreateTime;
}

public Date getCreateTime() {
return this.CreateTime;
}

public void setCreateSource(String CreateSource) {
this.CreateSource = CreateSource;
}

public String getCreateSource() {
return this.CreateSource;
}

public void setUpdateBy(String UpdateBy) {
this.UpdateBy = UpdateBy;
}

public String getUpdateBy() {
return this.UpdateBy;
}

public void setUpdateTime(Date UpdateTime) {
this.UpdateTime = UpdateTime;
}

public Date getUpdateTime() {
return this.UpdateTime;
}

public void setIsFixedAsset(String IsFixedAsset) {
this.IsFixedAsset = IsFixedAsset;
}

public String getIsFixedAsset() {
return this.IsFixedAsset;
}

public void setFixedAssetID(String FixedAssetID) {
this.FixedAssetID = FixedAssetID;
}

public String getFixedAssetID() {
return this.FixedAssetID;
}

public void setAdministrator(String Administrator) {
this.Administrator = Administrator;
}

public String getAdministrator() {
return this.Administrator;
}

public void setPortType(String PortType) {
this.PortType = PortType;
}

public String getPortType() {
return this.PortType;
}

public void setSpeed(String Speed) {
this.Speed = Speed;
}

public String getSpeed() {
return this.Speed;
}

public void setPortNum(String PortNum) {
this.PortNum = PortNum;
}

public String getPortNum() {
return this.PortNum;
}

public void setResourceid(String resourceid) {
this.resourceid = resourceid;
}
public String getResourceid() {
return this.resourceid;
}
}

直接拼sql肯定会遇到特殊字符串,拼错逗号括号.

用dao.insert

dao.insert(xxx_tableName, Chain.from(xxx));

再说, 都能映射为一个Pojo类了,还拼SQL干毛线

但是我直接用这个sql,在pl/sql中执行不报错啊,如果有特殊字符的话,应该会报错的啊

自定义SQL不是纯原生SQL, 其中的$和@是占位符.

 "Name": "test@光纤收发器",

好的,谢谢,我试试修改下

Sqls.escapeSqlFieldValue

用这个方法就会处理这种特殊字符吗?

@jacky013 yes,也防止被注入.

我这个方法做了如下处理,但是还是不行
其中fieldValue就是字段的值
fieldValue=Sqls.escapeSqlFieldValue((CharSequence) fieldValue);
if("Name".equals(dBField.name())){
System.out.println(dBField.name()+"--"+fieldValue);
}

sql语句如下:
insert into resourcedba.FiberConverter
(RESOURCEID,
ID,
DeviceID,
OriginalID,
Name,
TypeCode,
SubTypeCode,
Status,
IsAsset,
FirstRunningTime,
MaintenanceExpiresTime,
Vendor,
SN,
Brand,
Model,
AreaCode,
UseCorporation,
UseDepartment,
OperateCorporation,
OperateDepartment,
OperateGroup,
Location,
UsePurpose,
TechniqueCode,
TechniQueName,
SetPointCode,
PositionCode,
Description,
CreateBy,
CreateTime,
CreateSource,
UpdateBy,
UpdateTime,
IsFixedAsset,
FixedAssetID,
Administrator,
PortType,
Speed,
PortNum)
values
(RESOURCEDBA.SEQ_RESOURCEID.nextval,
'99-0306-2016-001000',
'99-0306-2016-001000',
'99-0306-2016-001000',
'test@光纤收发器',
'03',
'0306',
'00',
'0',
to_date('2016-08-05 15:42:19', 'yyyy-mm-dd hh24:mi:ss'),
to_date('2016-08-05 15:44:55', 'yyyy-mm-dd hh24:mi:ss'),
'供应商供应商供应商供应商供应商',
'产品序列号产品序列号产品序列号产品序列号产品序列号',
'品牌品牌品牌品牌品牌品牌品牌品牌品牌品牌品牌',
'配置型号配置型号配置型号配置型号配置型号',
'99',
'99',
'317BE9B0F04D8DCCE050007F01003E55',
'99',
NULL,
'运维(保管)班组运维(保管)班组运维(保管)班组',
'配置位置配置位置配置位置配置位置配置位置配置位置配',
'用途概述用途概述用途概述用途概述',
'工艺(功能)编码工艺(功能)编码',
'工艺(功能)名称工艺(功能)名称',
'安装点标识码安装点标识码',
'位置标识码位置标识码',
'备注备注备注备注备注备注备注备注备注备注备注备注',
'7D0CC2EB8B87458C833B379903C099BF',
to_date('2016-08-05 15:42:06', 'yyyy-mm-dd hh24:mi:ss'),
NULL,
'4F3FCD5694B040A28E43E52B97684357',
to_date('2016-08-18 17:32:23', 'yyyy-mm-dd hh24:mi:ss'),
'0',
NULL,
'35EE730FB37073A0E050007F0100D26C',
'ST',
'98610549861054986105498610549861054986105498610549',
'98610549861054986105498610549861054986105498610549')
这个sql语句可以在数据库中单独执行,但是在代码中还是不可以,还是报无效列索引

那就只能逐个字段排除

现在可以了,谢谢!!!

... 原因是?

转义特殊字符之后,没有放进sql里,但是特殊字符&,这个方法不起作用,报
Unmarshalling Error: Unexpected character '"' (code 34); expected a semi-colon after the reference for entity '光纤收发器'
at [row,col {unknown-source}]: [43,32]

对应的部分json如下:
"Name": "test&光纤收发器"

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