-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
17
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Setting a nullable Date field to Null value in Derby embedded database always gets error.
sample:
cached_RowSet.updateDate("Start_Date", null); // ---> gets error!!!
i always get this issue some 10years ago. please help.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
//This is my sample Table in Apache Derby Database 16.1:
CREATE TABLE Projects
(
PROJECT_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1),
PROJECT_TITLE VARCHAR(100),
START_DATE DATE
)
INSERT INTO Projects(Project_Title,Start_Date) Values ("Test Project 1000", '2023-01-15')
INSERT INTO Projects(Project_Title,Start_Date) Values ("Test Project 2000", '2023-02-21')
//This is how the Cached_RowSet is created:
RowSetFactory myRowSetFactory;
CachedRowSet cached_RowSet;
myRowSetFactory = RowSetProvider.newFactory();
cached_RowSet = myRowSetFactory.createCachedRowSet();
cached_RowSet.setUrl(DATABASE_URL);
cached_RowSet.setUsername(USERNAME);
cached_RowSet.setPassword(PASSWORD);
int [] keys = {1};
cached_RowSet.setKeyColumns(keys);
cached_RowSet.setCommand("Select * from Projects");
cached_RowSet.execute();
//This is how updating the database is done:
cached_RowSet.absolute(1);
cached_RowSet.updateString("Project_Title","Project Title Update 1000");
cached_RowSet.updateDate("Start_Date", null); // ---> gets error!!!
cached_RowSet.acceptChanges();
this will give error!!!
this is using OpenJDK 17.
However, if i use Statement like "UPDATE Projects SET Start_Date = null WHERE Project_ID = 1",
it works. I think there is a bug in Java CachedRowSet. Please help.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
cached_RowSet.updateDate("Start_Date", null); // ---> This should not get any error. This should push through.
ACTUAL -
cached_RowSet.updateDate("Start_Date", null); // ---> this will get error.
---------- BEGIN SOURCE ----------
//This is my sample Table in Apache Derby Database 16.1:
CREATE TABLE Projects
(
PROJECT_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1),
PROJECT_TITLE VARCHAR(100),
START_DATE DATE
)
INSERT INTO Projects(Project_Title,Start_Date) Values ("Test Project 1000", '2023-01-15')
INSERT INTO Projects(Project_Title,Start_Date) Values ("Test Project 2000", '2023-02-21')
//This is how the Cached_RowSet is created:
RowSetFactory myRowSetFactory;
CachedRowSet cached_RowSet;
myRowSetFactory = RowSetProvider.newFactory();
cached_RowSet = myRowSetFactory.createCachedRowSet();
cached_RowSet.setUrl(DATABASE_URL);
cached_RowSet.setUsername(USERNAME);
cached_RowSet.setPassword(PASSWORD);
int [] keys = {1};
cached_RowSet.setKeyColumns(keys);
cached_RowSet.setCommand("Select * from Projects");
cached_RowSet.execute();
//This is how updating the database is done:
cached_RowSet.absolute(1);
cached_RowSet.updateString("Project_Title","Project Title Update 1000");
cached_RowSet.updateDate("Start_Date", null); // ---> gets error!!!
cached_RowSet.acceptChanges();
this will give error!!!
this is using OpenJDK 17.
However, if i use Statement like "UPDATE Projects SET Start_Date = null WHERE Project_ID = 1",
it works. I think there is a bug in Java CachedRowSet. Please help.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
UPDATE Projects SET Start_Date = null WHERE Project_ID = 1
FREQUENCY : always
Setting a nullable Date field to Null value in Derby embedded database always gets error.
sample:
cached_RowSet.updateDate("Start_Date", null); // ---> gets error!!!
i always get this issue some 10years ago. please help.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
//This is my sample Table in Apache Derby Database 16.1:
CREATE TABLE Projects
(
PROJECT_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1),
PROJECT_TITLE VARCHAR(100),
START_DATE DATE
)
INSERT INTO Projects(Project_Title,Start_Date) Values ("Test Project 1000", '2023-01-15')
INSERT INTO Projects(Project_Title,Start_Date) Values ("Test Project 2000", '2023-02-21')
//This is how the Cached_RowSet is created:
RowSetFactory myRowSetFactory;
CachedRowSet cached_RowSet;
myRowSetFactory = RowSetProvider.newFactory();
cached_RowSet = myRowSetFactory.createCachedRowSet();
cached_RowSet.setUrl(DATABASE_URL);
cached_RowSet.setUsername(USERNAME);
cached_RowSet.setPassword(PASSWORD);
int [] keys = {1};
cached_RowSet.setKeyColumns(keys);
cached_RowSet.setCommand("Select * from Projects");
cached_RowSet.execute();
//This is how updating the database is done:
cached_RowSet.absolute(1);
cached_RowSet.updateString("Project_Title","Project Title Update 1000");
cached_RowSet.updateDate("Start_Date", null); // ---> gets error!!!
cached_RowSet.acceptChanges();
this will give error!!!
this is using OpenJDK 17.
However, if i use Statement like "UPDATE Projects SET Start_Date = null WHERE Project_ID = 1",
it works. I think there is a bug in Java CachedRowSet. Please help.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
cached_RowSet.updateDate("Start_Date", null); // ---> This should not get any error. This should push through.
ACTUAL -
cached_RowSet.updateDate("Start_Date", null); // ---> this will get error.
---------- BEGIN SOURCE ----------
//This is my sample Table in Apache Derby Database 16.1:
CREATE TABLE Projects
(
PROJECT_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1,
INCREMENT BY 1),
PROJECT_TITLE VARCHAR(100),
START_DATE DATE
)
INSERT INTO Projects(Project_Title,Start_Date) Values ("Test Project 1000", '2023-01-15')
INSERT INTO Projects(Project_Title,Start_Date) Values ("Test Project 2000", '2023-02-21')
//This is how the Cached_RowSet is created:
RowSetFactory myRowSetFactory;
CachedRowSet cached_RowSet;
myRowSetFactory = RowSetProvider.newFactory();
cached_RowSet = myRowSetFactory.createCachedRowSet();
cached_RowSet.setUrl(DATABASE_URL);
cached_RowSet.setUsername(USERNAME);
cached_RowSet.setPassword(PASSWORD);
int [] keys = {1};
cached_RowSet.setKeyColumns(keys);
cached_RowSet.setCommand("Select * from Projects");
cached_RowSet.execute();
//This is how updating the database is done:
cached_RowSet.absolute(1);
cached_RowSet.updateString("Project_Title","Project Title Update 1000");
cached_RowSet.updateDate("Start_Date", null); // ---> gets error!!!
cached_RowSet.acceptChanges();
this will give error!!!
this is using OpenJDK 17.
However, if i use Statement like "UPDATE Projects SET Start_Date = null WHERE Project_ID = 1",
it works. I think there is a bug in Java CachedRowSet. Please help.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
UPDATE Projects SET Start_Date = null WHERE Project_ID = 1
FREQUENCY : always
- duplicates
-
JDK-8316332 cachedrowset.updateNull("DateColumn") always gets error
- Open