<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        MySQLserverversionfortherightsyntaxtousenear''at

        來源:懂視網 責編:小采 時間:2020-11-09 13:59:38
        文檔

        MySQLserverversionfortherightsyntaxtousenear''at

        MySQLserverversionfortherightsyntaxtousenear''at:MySQL server version for the right syntax to use near '' at line 1 問題描述: 線上日志在執行數據庫表insert操作時,出現如下異常: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc
        推薦度:
        導讀MySQLserverversionfortherightsyntaxtousenear''at:MySQL server version for the right syntax to use near '' at line 1 問題描述: 線上日志在執行數據庫表insert操作時,出現如下異常: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc

        MySQL server version for the right syntax to use near '' at line 1 問題描述: 線上日志在執行數據庫表insert操作時,出現如下異常: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:? You have an error

        MySQL server version for the right syntax to use near '' at line 1

        問題描述:

        線上日志在執行數據庫表insert操作時,出現如下異常:

        ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:?

        You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

        問題原因分析:

        一般數據庫SQL 異常會將sql拼寫錯誤的文本解析錯誤地點放在near"" 中間引號中,而恰恰這次near語句出現出錯地點沒有標示,但是可以確定一點就是這個錯誤一定是sql語句錯誤造成的。

        原因查找:

        原因分析唯一可以確定的就是這個sql 拼寫一定是錯誤的,那么是一定要查看源碼拼寫是否正確。

        代碼如下:

        public String batchSave(Map params) {
        	Collection collection = (Collection)params.get("collection");
        	StringBuffer buffer = new StringBuffer("insert into sem_creative(id, platCreativeId, platPlanId, platAdgroupId, planId, adgroupId, " +
        	"title, desc1, desc2, pcDestinationUrl, pcDisplayUrl, mobileDestinationUrl, mobileDisplayUrl," +
        	"pause, status, valid, accountId, platform, opstatus, creator, createTime) values");
        	for(Creative c : collection) {
        	buffer.append("(").append(c.getId()).append(",")
        	.append(StringUtil.emptyToNULL(c.getPlatCreativeId())).append(",")
        	.append(StringUtil.emptyToNULL(c.getPlatPlanId())).append(",")
        	.append(StringUtil.emptyToNULL(c.getPlatAdgroupId())).append(",")
        	.append(c.getPlanId()).append(",")
        	.append(c.getAdgroupId()).append(",")
        	.append(StringUtil.emptyToNULL(c.getTitle())).append(",")
        	.append(StringUtil.emptyToNULL(c.getDesc1())).append(",")
        	.append(StringUtil.emptyToNULL(c.getDesc2())).append(",")
        	.append(StringUtil.emptyToNULL(c.getPcDestinationUrl())).append(",")
        	.append(StringUtil.emptyToNULL(c.getPcDisplayUrl())).append(",")
        	.append(StringUtil.emptyToNULL(c.getMobileDestinationUrl())).append(",")
        	.append(StringUtil.emptyToNULL(c.getMobileDisplayUrl())).append(",")
        	.append(c.getPause()).append(",")
        	.append(c.getStatus()).append(",")
        	.append(c.getValid()).append(",")
        	.append(c.getAccountId()).append(",")
        	.append(c.getPlatform()).append(",")
        	.append(c.getOpstatus()).append(",")
        	.append(StringUtil.emptyToNULL(c.getCreator())).append(",")
        	.append(StringUtil.emptyToNULL(c.getCreateTime().toString())).append("),"); 
        	}
        	buffer.deleteCharAt(buffer.length()-1);
        	return buffer.toString();
        	}

        ?這里可以看到SQL語句,拼寫是正確的,其中每個value值,對于空值的處理也正確。那為什么會報錯呢?

        等等,一定有哪里出錯了!

        for(Creative c : collection) {

        ?再看看這行代碼,如果這個的集合類為空,會怎么樣呢?這個一下錯誤就找到了,在collection為空的情況下,返回的SQL語句就只有前半句,執行就會報上述所描述錯誤。

        問題追蹤:

        這個地方在一般情況下沒有報錯,也很少出現;那么為什么這次會出現呢?

        這個地方還是得從源碼入手

        	public final void syncUpload(String filePath, int segment) throws Exception{
        	if(segment > MAX_SEGMENT) {
        	throw new IllegalArgumentException("分段上傳數據量過大!");
        	}
        	
        	if(segment <= 0) {
        	this.segment = DEFAULT_SEGMENT;
        	}
        	
        	CSVReader csvFileReader = getCSVReader(filePath);
        	
        	Iterator it = csvFileReader.iterator();
        	List segmentList = new ArrayList();
        	while(true) {
        	try {
        	while(it.hasNext()) {
        	if(segmentList.size() == this.segment) {
        	try {
        	syncBatchSave(segmentList);
        	}catch(Exception e) {
        	logger.error("批量添加異常: ", e);
        	}
        	segmentList = new ArrayList(); 
        	}
        	 E e = it.next();
        	 segmentList.add(parse(e));
        	}
        	}catch(Exception e) {
        	logger.error("CSV文件解析異常: ", e);
        	 continue;
        	}
        
        	break;
        	}
        	
        	syncBatchSave(segmentList);
        	}

        ?這里傳入的segmentList看不會為空,但是parse(e)拋出異常時,則會在插入傳入的集合不為null,但是集合的 size為0,所以在如上拼寫SQL語句時,就會出現更新異常。

        總結:

        1.在接口的傳入參數,一定要做邊界校驗,比如判空或者最大最小判斷(如果集合大小超過20W也會出現異常);

        2.團隊代碼規范中,要整理出代碼規范要點,并每周定時review,對于不符合基本要求規范的懲罰5元團隊建設基金;

        1 樓 Engberber 22 小時前 今日決定將以前遇到的問題以及處理方式做一個分享

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        MySQLserverversionfortherightsyntaxtousenear''at

        MySQLserverversionfortherightsyntaxtousenear''at:MySQL server version for the right syntax to use near '' at line 1 問題描述: 線上日志在執行數據庫表insert操作時,出現如下異常: ### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc
        推薦度:
        標簽: at the for
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 免费看一级高潮毛片| 丰满亚洲大尺度无码无码专线| 4hu四虎免费影院www| 免费大黄网站在线观| 成a人片亚洲日本久久| 免费v片视频在线观看视频| 亚洲精品无码av中文字幕| 亚洲AV永久青草无码精品| 二区久久国产乱子伦免费精品| 亚洲日韩精品无码一区二区三区| 人人公开免费超级碰碰碰视频 | 久久九九兔免费精品6| 亚洲国产精品成人久久蜜臀 | 免费观看无遮挡www的视频| 亚洲精品免费在线观看| 成人免费视频69| 亚洲精品久久无码| 亚洲精品色婷婷在线影院| 一级毛片不卡免费看老司机| 九月丁香婷婷亚洲综合色| 91福利免费体验区观看区| 亚洲爽爽一区二区三区| 亚洲国产精品成人综合色在线| 国产一区视频在线免费观看| 亚洲最新黄色网址| 在线看片人成视频免费无遮挡| 免费人成动漫在线播放r18| 亚洲欧洲美洲无码精品VA | 日本免费无遮挡吸乳视频电影| ass亚洲**毛茸茸pics| 99热精品在线免费观看| 亚洲精品国产成人片| selaoban在线视频免费精品| 91亚洲国产成人精品下载| 久久免费观看国产精品| 亚洲一级黄色大片| 亚洲色偷偷狠狠综合网| 精品国产免费人成电影在线观看| 国产精品亚洲综合| 国产91久久久久久久免费| 免费在线看黄网站|