NutzCN Logo
问答 sqlserver 批量插入 必须执行该语句才能获得结果。
发布于 2165天前 作者 qq_2a1c6850 4435 次浏览 复制 上一个帖子 下一个帖子
标签:

批量插入时候报这个错误是怎么回事啊

CaseMessage=必须执行该语句才能获得结果。
        at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:96)
        at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:316)
        at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:59)>>>>>>>>>>107998请求页面为:0/1

        at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:239)
        at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:271)
        at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:50)
        at org.nutz.dao.impl.NutDao.fastInsert(NutDao.java:202)
        at com.bds.map.job.thread.AmapGeoThread.getGaodeDataRecord(AmapGeoThread.java:290)
        at com.bds.map.job.thread.AmapGeoThread.run(AmapGeoThread.java:148)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 必须执行该语句才能获得结果。
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getGeneratedKeys(SQLServerStatement.java:2002)
        at org.apache.commons.dbcp.DelegatingStatement.getGeneratedKeys(DelegatingStatement.java:315)>>>>>>>>>>70998请求页面为:1/7

        at org.apache.commons.dbcp.DelegatingStatement.getGeneratedKeys(DelegatingStatement.java:315)
        at org.nutz.dao.impl.sql.NutPojoMaker$GeneratedKeys.invoke(NutPojoMaker.java:103)
        at org.nutz.dao.impl.jdbc.NutPojo.onAfter(NutPojo.java:109)
        at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:293)
        at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:82)
        ... 11 more
15 回复

驱动是最新的吗?sqlserver版本多少

Sqlserver 2016

<dependency>
		    <groupId>com.microsoft</groupId>
		    <artifactId>sqljdbc4</artifactId>
		    <version>3.0</version>
		</dependency>

对应的字段是自增的吗?

表是nutz建的吗?

pojo发一下,需要重现一下才能确定

表不是NUTZ建的

那建表语句发一下

package com.bds.map.model;

import java.util.Date;

import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.ColType;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Table;

@Table("s_amap_geo")
public class AmapGeo {
	/**
	 * 自增的id
	 */
	@Id(auto=true)
	private Long id;
	
	/**
	 * 公司的id
	 */
	@Column
	private String company_id;
	 
	@Column
	private String from_city;
	@Column
	private String from_address;
	@Column
	private String from_typecode;
	@Column
	private String from_lng;
	@Column
	private String from_lat;
	 /**
	  * 任务创建时间
	  */
	  @Column
	  private Date creat_date;
	  
	  /**
	   * 公司的名称
	   */
	 
	  @Column
      private String name;
	  
	  /**
	   * 公司的标签
	   */
	 
	  @Column
      private String tag;
	  
	  /**
	   * 公司服务的类型
	   */
	 
	  @Column
      private String type;
	  
	 
	  @Column
      private String biz_type;
	  
	  /**
	   * 公司的地址
	   */
	 
	  @Column
      private String address;
	  
	  /**
	   * 公司所在位置的经度
	   */
	 
	  @Column
      private String longitude;
	  
	  /**
	   * 公司所在位置的纬度
	   */
	 
	  @Column
      private String latitude;
	  
	  /**
	   * 公司的类型代码
	   */
	 
	  @Column
      private String typecode;
	  
	  /**
	   * 公司的电话
	   */
	 
	  @Column
      private String tel;
	  
	 
	  @Column
      private String postcode;
	  
	  /**
	   * 公司的网站
	   */
	 
	  @Column
      private String website;
	  
	  /**
	   * 公司的email
	   */
	 
	  @Column
      private String email;
	  
	 
	  @Column
      private String pcode;
	  
	 
	  @Column
      private String pname;
	  
	  /**
	   * 城市邮编
	   */
	 
	  @Column
      private String citycode;
	  
	  /**
	   * 公司所在城市的名称
	   */
	 
	  @Column
      private String cityname;
	  
	 
	  @Column
      private String adcode;
	  
	 
	  @Column
      private String adname;
	  
	 
	  @Column
      private String importance;
	  
	 
	  @Column
      private String shopid;
	  
	 
	  @Column
      private String shopinfo;
	  
	 
	  @Column
      private String poiweight;
	  
	 
	  @Column
      private String gridcode;
	  
	 
	  @Column
      private String distance;
	  
	 
	  @Column
      private String navi_poiid;
	  
	 
	  @Column
      private String entr_location;
	  
	 
	  @Column
      private String business_area;
	  
	 
	  @Column
      private String exit_location;
	  
	 
	  @Column
      private String match;
	  
	 
	  @Column
      private String recommend;
	  
	 
	  @Column
      private String timestamp;
	  
	 
	  @Column
      private String alias;
	  
	 
	  @Column
      private String indoor_map;
	  
	 
	  @Column
      private String groupbuy_num;
	  
	 
	  @Column
      private String discount_num;
	  
	 
	  @Column
      private String rating;
	  
	 
	  @Column
      private String cost;
	  
	  
	 
	  @Column
      private String event;
	  
	 
	  @Column
      private String children;
	  
	 
	  @Column
      private String photos;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreat_date() {
		return creat_date;
	}

	public void setCreat_date(Date creat_date) {
		this.creat_date = creat_date;
	}

	public String getName() {
		return name;
	}

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

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getBiz_type() {
		return biz_type;
	}

	public void setBiz_type(String biz_type) {
		this.biz_type = biz_type;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getTypecode() {
		return typecode;
	}

	public void setTypecode(String typecode) {
		this.typecode = typecode;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public String getPostcode() {
		return postcode;
	}

	public void setPostcode(String postcode) {
		this.postcode = postcode;
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPcode() {
		return pcode;
	}

	public void setPcode(String pcode) {
		this.pcode = pcode;
	}

	public String getPname() {
		return pname;
	}

	public void setPname(String pname) {
		this.pname = pname;
	}

	public String getCitycode() {
		return citycode;
	}

	public void setCitycode(String citycode) {
		this.citycode = citycode;
	}

	public String getCityname() {
		return cityname;
	}

	public void setCityname(String cityname) {
		this.cityname = cityname;
	}

	public String getAdcode() {
		return adcode;
	}

	public void setAdcode(String adcode) {
		this.adcode = adcode;
	}

	public String getAdname() {
		return adname;
	}

	public void setAdname(String adname) {
		this.adname = adname;
	}

	public String getImportance() {
		return importance;
	}

	public void setImportance(String importance) {
		this.importance = importance;
	}

	public String getShopid() {
		return shopid;
	}

	public void setShopid(String shopid) {
		this.shopid = shopid;
	}

	public String getShopinfo() {
		return shopinfo;
	}

	public void setShopinfo(String shopinfo) {
		this.shopinfo = shopinfo;
	}

	public String getPoiweight() {
		return poiweight;
	}

	public void setPoiweight(String poiweight) {
		this.poiweight = poiweight;
	}

	public String getGridcode() {
		return gridcode;
	}

	public void setGridcode(String gridcode) {
		this.gridcode = gridcode;
	}

	public String getDistance() {
		return distance;
	}

	public void setDistance(String distance) {
		this.distance = distance;
	}

	public String getNavi_poiid() {
		return navi_poiid;
	}

	public void setNavi_poiid(String navi_poiid) {
		this.navi_poiid = navi_poiid;
	}

	public String getEntr_location() {
		return entr_location;
	}

	public void setEntr_location(String entr_location) {
		this.entr_location = entr_location;
	}

	public String getBusiness_area() {
		return business_area;
	}

	public void setBusiness_area(String business_area) {
		this.business_area = business_area;
	}

	public String getExit_location() {
		return exit_location;
	}

	public void setExit_location(String exit_location) {
		this.exit_location = exit_location;
	}

	public String getMatch() {
		return match;
	}

	public void setMatch(String match) {
		this.match = match;
	}

	public String getRecommend() {
		return recommend;
	}

	public void setRecommend(String recommend) {
		this.recommend = recommend;
	}

	public String getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	public String getAlias() {
		return alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}

	public String getIndoor_map() {
		return indoor_map;
	}

	public void setIndoor_map(String indoor_map) {
		this.indoor_map = indoor_map;
	}

	public String getGroupbuy_num() {
		return groupbuy_num;
	}

	public void setGroupbuy_num(String groupbuy_num) {
		this.groupbuy_num = groupbuy_num;
	}

	public String getDiscount_num() {
		return discount_num;
	}

	public void setDiscount_num(String discount_num) {
		this.discount_num = discount_num;
	}

	public String getRating() {
		return rating;
	}

	public void setRating(String rating) {
		this.rating = rating;
	}

	public String getCost() {
		return cost;
	}

	public void setCost(String cost) {
		this.cost = cost;
	}

	public String getEvent() {
		return event;
	}

	public void setEvent(String event) {
		this.event = event;
	}

	public String getChildren() {
		return children;
	}

	public void setChildren(String children) {
		this.children = children;
	}

	public String getPhotos() {
		return photos;
	}

	public void setPhotos(String photos) {
		this.photos = photos;
	}
	
	

	public String getCompany_id() {
		return company_id;
	}

	public void setCompany_id(String company_id) {
		this.company_id = company_id;
	}


	@Override
	public String toString() {
		return "GaodeComment [id=" + id + ", company_id=" + company_id
				+ ", creat_date=" + creat_date + ", name="
				+ name + ", tag=" + tag + ", type=" + type + ", biz_type="
				+ biz_type + ", address=" + address + ", longitude="
				+ longitude + ", latitude=" + latitude + ", typecode="
				+ typecode + ", tel=" + tel + ", postcode=" + postcode
				+ ", website=" + website + ", email=" + email + ", pcode="
				+ pcode + ", pname=" + pname + ", citycode=" + citycode
				+ ", cityname=" + cityname + ", adcode=" + adcode + ", adname="
				+ adname + ", importance=" + importance + ", shopid=" + shopid
				+ ", shopinfo=" + shopinfo + ", poiweight=" + poiweight
				+ ", gridcode=" + gridcode + ", distance=" + distance
				+ ", navi_poiid=" + navi_poiid + ", entr_location="
				+ entr_location + ", business_area=" + business_area
				+ ", exit_location=" + exit_location + ", match=" + match
				+ ", recommend=" + recommend + ", timestamp=" + timestamp
				+ ", alias=" + alias + ", indoor_map=" + indoor_map
				+ ", groupbuy_num=" + groupbuy_num + ", discount_num="
				+ discount_num + ", rating=" + rating + ", cost=" + cost
				+ ", event=" + event + ", children=" + children + ", photos="
				+ photos + "]";
	}

	public String getFrom_city() {
		return from_city;
	}

	public void setFrom_city(String from_city) {
		this.from_city = from_city;
	}

	public String getFrom_typecode() {
		return from_typecode;
	}

	public void setFrom_typecode(String from_typecode) {
		this.from_typecode = from_typecode;
	}

	public String getFrom_lng() {
		return from_lng;
	}

	public void setFrom_lng(String from_lng) {
		this.from_lng = from_lng;
	}

	public String getFrom_lat() {
		return from_lat;
	}

	public void setFrom_lat(String from_lat) {
		this.from_lat = from_lat;
	}

	public String getFrom_address() {
		return from_address;
	}

	public void setFrom_address(String from_address) {
		this.from_address = from_address;
	}

	  
}

建表语句

CREATE TABLE [dbo].[s_amap_geo] (
[id] bigint NOT NULL IDENTITY(1,1) ,
[company_id] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[creat_date] datetime NULL ,
[name] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[tag] varchar(2048) COLLATE Chinese_PRC_CI_AS NULL ,
[type] varchar(512) COLLATE Chinese_PRC_CI_AS NULL ,
[biz_type] varchar(512) COLLATE Chinese_PRC_CI_AS NULL ,
[address] varchar(1024) COLLATE Chinese_PRC_CI_AS NULL ,
[longitude] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[latitude] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[typecode] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[tel] varchar(64) COLLATE Chinese_PRC_CI_AS NULL ,
[postcode] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[website] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[email] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[pcode] varchar(10) COLLATE Chinese_PRC_CI_AS NULL ,
[pname] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[citycode] varchar(10) COLLATE Chinese_PRC_CI_AS NULL ,
[cityname] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[adcode] varchar(10) COLLATE Chinese_PRC_CI_AS NULL ,
[adname] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[importance] varchar(64) COLLATE Chinese_PRC_CI_AS NULL ,
[shopid] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[shopinfo] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[poiweight] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[gridcode] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[distance] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[navi_poiid] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[entr_location] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[business_area] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[exit_location] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[match] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[recommend] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[timestamp] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[alias] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[indoor_map] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[groupbuy_num] varchar(255) COLLATE 

这个对

CREATE TABLE [dbo].[s_amap_geo] (
[id] bigint NOT NULL IDENTITY(1,1) ,
[company_id] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[creat_date] datetime NULL ,
[name] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[tag] varchar(2048) COLLATE Chinese_PRC_CI_AS NULL ,
[type] varchar(512) COLLATE Chinese_PRC_CI_AS NULL ,
[biz_type] varchar(512) COLLATE Chinese_PRC_CI_AS NULL ,
[address] varchar(1024) COLLATE Chinese_PRC_CI_AS NULL ,
[longitude] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[latitude] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[typecode] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[tel] varchar(64) COLLATE Chinese_PRC_CI_AS NULL ,
[postcode] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[website] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[email] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[pcode] varchar(10) COLLATE Chinese_PRC_CI_AS NULL ,
[pname] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[citycode] varchar(10) COLLATE Chinese_PRC_CI_AS NULL ,
[cityname] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[adcode] varchar(10) COLLATE Chinese_PRC_CI_AS NULL ,
[adname] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[importance] varchar(64) COLLATE Chinese_PRC_CI_AS NULL ,
[shopid] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[shopinfo] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[poiweight] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[gridcode] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[distance] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[navi_poiid] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[entr_location] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[business_area] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[exit_location] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[match] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[recommend] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[timestamp] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[alias] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[indoor_map] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[groupbuy_num] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[discount_num] varchar(255) COLLATE Chinese_PRC_CI_AS NULL ,
[rating] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[cost] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[event] varchar(64) COLLATE Chinese_PRC_CI_AS NULL ,
[children] varchar(32) COLLATE Chinese_PRC_CI_AS NULL ,
[photos] varchar(2048) COLLATE Chinese_PRC_CI_AS NULL ,
[from_city] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[from_address] varchar(128) COLLATE Chinese_PRC_CI_AS NULL ,
[from_typecode] varchar(10) COLLATE Chinese_PRC_CI_AS NULL ,
[from_lng] varchar(20) COLLATE Chinese_PRC_CI_AS NULL ,
[from_lat] varchar(20) COLLATE Chinese_PRC_CI_AS NULL 
)
ON [PRIMARY]
GO

DBCC CHECKIDENT(N'[dbo].[s_amap_geo]', RESEED, 1)
GO


我用2017测试了一下, 可以pass, 也许是驱动问题, 换上这个试试

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>7.0.0.jre10</version>
</dependency>
添加回复
请先登陆
回到顶部