mysql ora-1400_oracle错误(二) ORA-01400: 没法将 NULL 插入 ("SL"."TEMP_TEST_TABLE"."ID")的解决方案...

以前都是mysql数据库,如今由于项目须要开始接触oracle数据库,新手上路,不免磕磕碰碰,把本身遇到的问题记录下来,方便查询!html

一 建表脚本:java

DROP TABLE TEMP_TEST_TABLE;

CREATE TABLE TEMP_TEST_TABLE

(

id NUMBER NOT NULL,

author VARCHAR2(200),

publishing VARCHAR2(200),

publish_time TIMESTAMP(6),

word_number VARCHAR2(15),

which_edition VARCHAR2(15),

total_page VARCHAR2(15),

print_time TIMESTAMP(6),

print_number VARCHAR2(15),

isbn VARCHAR2(25),

author_summary VARCHAR2(250),

catalogue VARCHAR2(250)

)

--指定表空间(能够不指定)

tablespace DSW

pctfree 10

pctused 40

initrans 1

maxtrans 255

storage

(

initial 64K

minextents 1

maxextents unlimited

);

-- Add comments to the table

comment on table TEMP_TEST_TABLE is '学习测试表';

-- Add comments to the columns

comment on column TEMP_TEST_TABLE.id is '图书ID';

comment on column TEMP_TEST_TABLE.author is '图书做者';

comment on column TEMP_TEST_TABLE.publishing is '出版社';

comment on column TEMP_TEST_TABLE.publish_time is '出版时间';

comment on column TEMP_TEST_TABLE.word_number is '字数';

comment on column TEMP_TEST_TABLE.which_edition is '版本号码';

comment on column TEMP_TEST_TABLE.total_page is '总页数';

comment on column TEMP_TEST_TABLE.print_time is '印刷时间';

comment on column TEMP_TEST_TABLE.print_number is '印刷次数';

comment on column TEMP_TEST_TABLE.isbn is '版本号';

comment on column TEMP_TEST_TABLE.author_summary is '做者简介';

comment on column TEMP_TEST_TABLE.catalogue is '图书描述';

-- Create/Recreate primary, unique and foreign key constraints

alter table TEMP_TEST_TABLE

add constraint PK_TEMP_TEST_TABLE primary key (ID)

using index

tablespace SYSTEM

pctfree 10

initrans 2

maxtrans 255

storage

(

initial 64K

minextents 1

maxextents unlimited

);结果项目成功启动后,调用接口时,接口逻辑没有问题,做新增操做的时候,一直在报错;

信息以下:mysql

2015-06-05 10:32:43,996 DEBUG [org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator] - Translating SQLException with SQL state '23000', error code '1400', message [ORA-01400: 没法将 NULL 插入 ("SL"."TEMP_TEST_TABLE"."ID")

]; SQL was [] for task [

### Error updating database. Cause: java.sql.SQLException: ORA-01400: 没法将 NULL 插入 ("SL"."TEMP_TEST_TABLE"."ID")

### The error may involve defaultParameterMap

### The error occurred while setting parameters

### Cause: java.sql.SQLException: ORA-01400: 没法将 NULL 插入 ("SL"."TEMP_TEST_TABLE"."ID")

]

2015-06-05 10:32:43,996 DEBUG [org.mybatis.spring.SqlSessionUtils] - Closing no transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@55450411]

2015-06-05 10:32:43,996 DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Returning JDBC Connection to DataSource

org.springframework.dao.DataIntegrityViolationException:

### Error updating database. Cause: java.sql.SQLException: ORA-01400: 没法将 NULL 插入 ("SL"."TEMP_TEST_TABLE"."ID")

### The error may involve defaultParameterMap

### The error occurred while setting parameters

### Cause: java.sql.SQLException: ORA-01400: 没法将 NULL 插入 ("SL"."TEMP_TEST_TABLE"."ID")

; SQL []; ORA-01400: 没法将 NULL 插入 ("SL"."TEMP_TEST_TABLE"."ID")

; nested exception is java.sql.SQLException: ORA-01400: 没法将 NULL 插入 ("SL"."TEMP_TEST_TABLE"."ID")

at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:249)

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:346)

at com.sun.proxy.$Proxy8.insert(Unknown Source)

at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:231)

at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.j

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值