java - create table user("user_id int auto_increment"); not working in derby (embedded database) -


i new in derby library. why got error when use auto_increment in query?

here java code

 this.conn.createstatement().execute(create table user("user_id int auto_increment, primary key(user_id))"); 

i tried in mysql server , works in derby got error

java.sql.sqlsyntaxerrorexception: syntax error: encountered "auto_increment" @ line 1 

why got error?

derby not have auto_increment keyword. in derby need use identity columns implement auto increment behaviour

for example

create table students ( id integer not null generated identity (start 1, increment 1), name varchar(24) not null, address varchar(1024), constraint primary_key primary key (id) ) ; 

above statement create student table id auto increment column , primary key well.

hope helps


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -