db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@debrunners.com>
Subject Re: can derby have a "sequence" column?
Date Sat, 17 Sep 2005 15:15:55 GMT
firstname lastname wrote:

> Good example but, how do insert a row to this table from JDBC ? Using
> ij, it's
> just a matter of using the DEFAULT parameter, however, the JDBC
> preparedstatement
> class has no setDefault() method. 

The DEFAULT keyword is part of SQL, not ij. These SQL statements should
all work in JDBC as a PreparedStatement

INSERT INTO GROUPS(ID, NAME, DESCRIPTION) VALUES (DEFAULT, ?, ?)

INSERT INTO GROUPS(NAME, DESCRIPTION) VALUES (?, ?)

INSERT INTO GROUPS VALUES (DEFAULT, ?, ?)

Dan.

> 
> On Fri, 16 Sep 2005 20:18:04 -0700, "Ali Demir" <demir4@yahoo.com> said:
> 
>>Yes. For example:
>>
>>CREATE TABLE GROUPS(
>>   ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (start with 0, 
>>increment by 1),
>>   NAME VARCHAR(25) NOT NULL,
>>   DESCRIPTION VARCHAR(255),
>>   PRIMARY KEY (ID)
>>)

>>



Mime
View raw message