Ramesh | 8 Jul 00:47 2008
Picon

Primary key is throwing not null error through java


My code goes like this:
//database connection
statement.executeUpdate(" CREATE TABLE if not exists h041 (  h041001
integer PRIMARY KEY , h041002 varchar(10)," +
						"h041003 date,  h041004 integer, h041005 numeric(20,2),  h041006
numeric(20,2), h041007 boolean,  h041008 varchar(15), h041009
timestamp ,  h041010 varchar(250)," +
						"h041011 date,  h041012 text,  h041013 smallint DEFAULT 0,
h041014 smallint,  h041015 boolean DEFAULT false, h041022
varchar(30),  h041023 boolean DEFAULT true," +
						"h041024 timestamp, h041025 varchar(60), h041016 integer,
h041017 integer,h041018 integer, h041019 integer, h041020 integer,
h041021 integer," +
						"h041026 varchar(10),  h041027 date, h041028 numeric(20,2),
h041029 integer DEFAULT -1," +
						"h041030 integer DEFAULT -1  ) ");

					statement.executeUpdate("
 insert into h041 ( h041003 , h041013 , h041004 , h041014 , h041002 ,
h041005 ,h041012 , h041010 , h041016  ,h041017 ) values
( '01/01/2008','insurance','test test test  test test test test test
test ','cash','1234','100' , 'test' , 'test' , '00001' , '00ADJ' )");

it is giving me the error
        java.sql.SQLException: h041.h041001 may not be NULL
	at org.sqlite.DB.execute(DB.java:275)
	at org.sqlite.DB.executeUpdate(DB.java:281)
	at org.sqlite.Stmt.executeUpdate(Stmt.java:103)

(Continue reading)

David Crawshaw | 8 Jul 01:23 2008

Re: Primary key is throwing not null error through java


Your example runs for me here without error. I suspect you are running
it on a database that already contains the table named blah, with a
slightly different primary key column type.

d.

2008/7/7 Ramesh <ramesh.v1210@...>:
>
> My code goes like this:
> //database connection
> statement.executeUpdate(" CREATE TABLE if not exists h041 (  h041001
> integer PRIMARY KEY , h041002 varchar(10)," +
>                                                "h041003 date,  h041004 integer, h041005 numeric(20,2),  h041006
> numeric(20,2), h041007 boolean,  h041008 varchar(15), h041009
> timestamp ,  h041010 varchar(250)," +
>                                                "h041011 date,  h041012 text,  h041013 smallint DEFAULT 0,
> h041014 smallint,  h041015 boolean DEFAULT false, h041022
> varchar(30),  h041023 boolean DEFAULT true," +
>                                                "h041024 timestamp, h041025 varchar(60), h041016 integer,
> h041017 integer,h041018 integer, h041019 integer, h041020 integer,
> h041021 integer," +
>                                                "h041026 varchar(10),  h041027 date, h041028 numeric(20,2),
> h041029 integer DEFAULT -1," +
>                                                "h041030 integer DEFAULT -1  ) ");
>
>
>                                        statement.executeUpdate("
>  insert into h041 ( h041003 , h041013 , h041004 , h041014 , h041002 ,
> h041005 ,h041012 , h041010 , h041016  ,h041017 ) values
(Continue reading)

Ramesh | 8 Jul 09:37 2008
Picon

Re: Primary key is throwing not null error through java


Sorry i am pointing to a different database ...

Thanks for your reply...

On Jul 8, 4:23 am, "David Crawshaw" <da...@...> wrote:
> Your example runs for me here without error. I suspect you are running
> it on a database that already contains the table named blah, with a
> slightly different primary key column type.
>
> d.
>
> 2008/7/7 Ramesh <ramesh.v1...@...>:
>
>
>
> > My code goes like this:
> > //database connection
> > statement.executeUpdate(" CREATE TABLE if not exists h041 (  h041001
> > integer PRIMARY KEY , h041002 varchar(10)," +
> >                                                "h041003 date,  h041004 integer, h041005
numeric(20,2),  h041006
> > numeric(20,2), h041007 boolean,  h041008 varchar(15), h041009
> > timestamp ,  h041010 varchar(250)," +
> >                                                "h041011 date,  h041012 text,  h041013
smallint DEFAULT 0,
> > h041014 smallint,  h041015 boolean DEFAULT false, h041022
> > varchar(30),  h041023 boolean DEFAULT true," +
> >                                                "h041024 timestamp, h041025 varchar(60),
h041016 integer,
(Continue reading)


Gmane