• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting null values in table even after the input

 
rajashree loganayagi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried to insert a data into MS Access Database using jsp. For that i created a HTML program which as the same field as in the dB table.

After i input all the fields using HTML, i found that some of the fields in the table are stored as null.

Please a provide a solution to avoid the null values even i input the field.

Thanks in advance....
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to tell us more about how you do what you are doing for us to be able to help. Can you post your code?
 
rajashree loganayagi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are the following codes i used to insert the data:



</head>
<body>
<%
String project = request.getParameter("project");
String odr = request.getParameter("odr");
String resource = request.getParameter("resource");
String review = request.getParameter("review");
String status = request.getParameter("status");
String reviewcycle = request.getParameter("review_cycle");
String designowner = request.getParameter("design_owner");
String ctiriss= request.getParameter("ctir_iss");
String highiss= request.getParameter("high_iss");
String mediss = request.getParameter("med_iss ");
String score = request.getParameter("score");
String receivedon = request.getParameter("received_on");
String startdate = request.getParameter("start_date ");
String enddate = request.getParameter("end_date");
String remarks = request.getParameter("remarks ");

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("Jdbc:Odbc:ShreeDB");
stmt = conn.createStatement();

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("Jdbc:Odbc:ShreeDB");
stmt = conn.createStatement();

stmt.executeUpdate("Insert into ProjTable (Project,ODR,Resource,Review,Status,Review_Cycle,Design_Owner,Crit_Iss,High_Iss,Med_Iss,Score,Received_On,Start_Date,End_Date,Remarks) values ('"+project+"','"+odr+"','"+resource+"','"+review+"','"+status+"','"+reviewcycle+"','"+designowner+"','"+ctiriss+"','"+highiss+"','"+mediss+"','"+score+"','"+receivedon+"','"+startdate+"','"+enddate+"','"+remarks+"')");
out.println("Data inserted successfully");
}
catch(Exception e)
{
out.println(e.toString());
}

%>

</body>
</html>


I got the null value for 4 fields: ctiriss,mediss,startdate and remarks.....

And rest of the fields are works fine.....
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked the values you have from your request.getParameter() calls? The obvious cause is nothing is included in the request for these.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul is right.

print out your sql and you will probably see some missing values:
or, post the HTML here and you will spot some wrong names in the HTML form
 
rajashree loganayagi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I even tired using out.println() .... It shows "null".

Here are the HTML codes:



Thanks for the valuable suggestions......
 
Swastik Dey
Rancher
Posts: 1602
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Look at the name and argument in getParameter. crit_iss and ctir_iss.
 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rajashree loganayagi wrote:

Your application is highly susceptible to SQL injection. I suggest you start using PreparedStatement instead of Statement.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so, which fields are ending up null?
 
rajashree loganayagi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After rectifying the spell of critiss, i can able to get the values....

But still 3 fields(mediss,startdate,remarks)states only null....
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But still 3 fields(mediss,startdate,remarks)states only null....

well, those three have an extra space at the end of the string when you call getParameter:



 
rajashree loganayagi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much.... Now i can able to get the values exactly....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic