I am using below JSP code to upload the txt file with 231KB ,
program is working but it upload some lines /half of the file
Please help me tackle the problem
#1 - you have java code in a jsp. Java code belongs in a java class.
#2 - you're reinventing the square wheel. Go look up the apache commons fileupload component Use that instead of interpreting the input stream
#3 - Your program is open to sql injection. Use prepared statements rather than building up sql strings
#4 - Use a pooled JNDI datasource for obtaining database connections from
Dear Sir,
Thanks For your reply ,
But i m new to JAVA please help me to change the source so that i can upload the full text file.
Now. this program upload the file but it taKES ONLY 500 rows in a table. Remaining part is not uploaded
What changes should be done in program to avoid this.
My guess is that you aren't reading the entire upload. I don't see a loop there, so that's probably the problem.
However it's hard to read that code because it has JSP scriptlets embedded in it, so I can't say for sure. Don't put it in a JSP if you want it to be readable. And you do want it to be readable.
And it looks like you're trying to read the data and write it to a file somewhere, then read that file back so you can update the database. Is there any point in having that file, or did you just not know how to take the data and update the database directly? It would be easier if you used the Apache file upload package, then it would be quite clear how to read from the upload and update the database.
So in summary: Stefan has some good advice. Don't just ignore it because you think you can fix what you have there; it's better to get rid of most of that code and replace it by good code.