• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.sql.SQLException: ORA-01400: cannot insert NULL into ("SYSTEM"."DESCRIPTION"."TYPE")

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
insert into DESCRIPTION (TYPE,DESCRIPTION,IS_HTML,EVENT_ID) values('','','',41)
java.sql.SQLException: ORA-01400: cannot insert NULL into ("SYSTEM"."DESCRIPTION"."TYPE")

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:112)
at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:474)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1125)
at com.event.struts.InsertDetails.doPost(InsertDetails.java:78)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source

and i my

Action class is


public class InsertDetails extends HttpServlet{

protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
Connection conn = null;
try{
List list = (List) req.getSession().getAttribute("listbean");
InputBean ib = (InputBean) list.get(0);
InputBean ib1 = (InputBean) list.get(1);
InputBean ib2 = (InputBean) list.get(2);
InputBean ib3 = (InputBean) list.get(3);
InputBean ib4 = (InputBean) list.get(4);
InputBean ib5 = (InputBean) list.get(5);
InputBean ib6 = (InputBean) list.get(6);
InputBean ib7 = (InputBean) list.get(7);

conn = ConnectionUtils.getConnection();

Statement stmt = conn.createStatement();

String sql1 = "select seq.nextval from DUAL";

ResultSet rs1 = stmt.executeQuery(sql1);

rs1.next();
int event_id = rs1.getInt(1);

//Advanced and general info
String sql2 = "insert into EVENT_INFO (EVENT_ID,EVENT_NAME,SHORT_NAME,EVENT_START_DATE,EVENT_END_DATE,EVENT_START_TIME,EVENT_END_TIME,event_LOCATION,ADDRESS1,ADDRESS2,CITY,STATE,ZIP_CODE,COUNTRY,event_COMMENT,EVENT_OVERVIEW,EXTRA1,EXTRA2,MEMBERSHIP_OPTION,EXTRA3,EXTRA4,EXTRA5,KID,TEEN,ADULT,SENIOR,SENILE,EVENT_TYPE1,EVENT_TYPE2,DETAILED_DESCRIPTION,IS_DETAILED_DESCRIPTION_HTML,ADDITIONAL_URL,BYPASS_INFORMATION_PAGE,CANCELLATION_POLICY,ADDTIONAL_INFO) values("+event_id+",'"+ib.getName()+"','"+ib.getShortname()+"','"+ib.getStartdate()+
"','"+ib.getEnddate()+"','"+ib.getStarttime()+"','"+ib.getEndtime()+"','"+ib.getLocation()+"','"+ib.getAddress1()+"','"+ib.getAddress2()+"','"+
ib.getCity()+"','"+ib.getState()+"','"+ib.getZip()+"','"+ib.getCountry()+"','"+ib.getComment()+"','"+ib.getTextarea()+"','"+ib.getExtra1()+"','"+
ib.getExtra2()+"','"+ib.getExtra3()+"','"+ib.getExtra4()+"','"+ib.getExtra5()+"','"+ib.getExtra6()+"','"+ib.getExtra7()+"','"+ib.getExtra8()+"','"+
ib.getExtra9()+"','"+ib.getExtra10()+"','"+ib.getExtra11()+"','"+ib.getExtra12()+"','"+ib.getExtra13()+"','"+ib1.getTextarea()+"','"+ib1.getExtra1()+"','"+
ib1.getName()+"','"+ib1.getExtra2()+"','"+ib2.getCancellation_policy()+"','"+ib2.getTextarea()+"')";
stmt.executeQuery(sql2);

//Description
List list1 = (List) ib2.getList();
DescriptionBean db = (DescriptionBean) list1.get(0);
DescriptionBean db1 = (DescriptionBean) list1.get(1);
DescriptionBean db2 = (DescriptionBean) list1.get(2);
DescriptionBean db3 = (DescriptionBean) list1.get(3);
DescriptionBean db4 = (DescriptionBean) list1.get(4);
DescriptionBean db5 = (DescriptionBean) list1.get(5);
DescriptionBean db6 = (DescriptionBean) list1.get(6);



if(db.getDescription()!=" "){
String s1 = "insert into DESCRIPTION (TYPE,DESCRIPTION,IS_HTML,EVENT_ID) values('"+db.getDescription()+"','"+db.getTextarea()+"','"+db.getHtmlbutton()+"',"+event_id+")";
stmt.executeQuery(s1);
}
if(db1.getDescription()!=" "){
String s2 = "insert into DESCRIPTION (TYPE,DESCRIPTION,IS_HTML,EVENT_ID) values('"+db1.getDescription()+"','"+db1.getTextarea()+"','"+db1.getHtmlbutton()+"',"+event_id+")";
stmt.executeQuery(s2);
}
if(db2.getDescription()!=" "){
String s3 = "insert into DESCRIPTION (TYPE,DESCRIPTION,IS_HTML,EVENT_ID) values('"+db2.getDescription()+"','"+db2.getTextarea()+"','"+db2.getHtmlbutton()+"',"+event_id+")";
System.out.println(s3);
stmt.executeQuery(s3);
}
if(db3.getDescription()!=" "){
String s4 = "insert into DESCRIPTION (TYPE,DESCRIPTION,IS_HTML,EVENT_ID) values('"+db3.getDescription()+"','"+db3.getTextarea()+"','"+db3.getHtmlbutton()+"',"+event_id+")";
stmt.executeQuery(s4);
}
if(db4.getDescription()!=" "){
String s5 = "insert into DESCRIPTION (TYPE,DESCRIPTION,IS_HTML,EVENT_ID) values('"+db4.getDescription()+"','"+db4.getTextarea()+"','"+db4.getHtmlbutton()+"',"+event_id+")";
stmt.executeQuery(s5);
}
if(db5.getDescription()!=" "){
String s6 = "insert into DESCRIPTION (TYPE,DESCRIPTION,IS_HTML,EVENT_ID) values('"+db5.getDescription()+"','"+db5.getTextarea()+"','"+db5.getHtmlbutton()+"',"+event_id+")";
stmt.executeQuery(s6);
}
if(db6.getDescription()!=" "){
String s7 = "insert into DESCRIPTION (TYPE,DESCRIPTION,IS_HTML,EVENT_ID) values('"+db6.getDescription()+"','"+db6.getTextarea()+"','"+db6.getHtmlbutton()+"',"+event_id+")";
stmt.executeQuery(s7);
}

//Activity
String sql3 = "insert into ACTIVITY (ACTIVITY_NAME,ACTIVITY_START_DATE,ACTIVITY_END_DATE,ACTIVITY_START_TIME,ACTIVITY_END_TIME,TYPE,CAPACITY,EVENT_ID) values('"+ib3.getName()+"','"+ib3.getStartdate()+"','"+
ib3.getEnddate()+"','"+ib3.getStarttime()+"','"+ib.getEndtime()+"','"+ib3.getExtra1()+"',"+event_id+")";
stmt.executeQuery(sql3);
-------
---------

}

i put condition for null .But if i dont fill the fields,even then the executeQuery is executing without checking the condition.
wht is the problem
what i want to change in my code.
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Connect to the database, type DESC DESCRIPTION
and show us results of this command.
Some of fields in the table are declared with NOT NULL constraint,
the field declared NOT NULL cannot be null/empty and you must always fill it with some content,
otherwise database rejects the whole record with ORA-01400.
 
deepthi malladi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey i have already checking the condition
if(db.description!=null){
-----------
}

why it is not checking the condition.
I want that if the field has null value i dont want to insert that row.
even then it is executing the query.
 
deepthi malladi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey i have already checking the condition
if(db.description!=null){
-----------
}

why it is not checking the condition.
I want that if the field has null value i dont want to insert that row.
even then it is executing the query.
 
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic