• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Excel upload into MySQL using JSP

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Error:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:213)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:522)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:392)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:399)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
 
Rancher
Posts: 4190
47
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's an incomplete exception.
What is the full exception, including its name, the message and the full stack trace?

I notice you have put code inside a JSP.
That is not the correct place for it, and it should be in a servlet or (preferably) underlying service code so it can be tested outside of a web server.
 
Aneeket Bhatnagar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave please help me for develop the code.
I have not too much experience.
 
Saloon Keeper
Posts: 5718
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like it's related to https://coderanch.com/t/713846/java/Upload-Excel-data-MySQL-Server where you received an answer to which you didn't reply. If it's the same question, please restrict the discussion to a single topic.
 
Aneeket Bhatnagar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya Tim both are same question but I dint get my solution so asked one more time. I don't have any kind of  idea how to do that If you please provide me code , it will great help to me Tim. please Tim write a code for me , Be grateful to you.
 
Tim Moores
Saloon Keeper
Posts: 5718
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nobody here will write the code for you that's not how this site works. But we'll help you write it yourself. If you didn't understand an answer, ask specific questions about it, so we know what to explain in more detail.
 
Aneeket Bhatnagar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK.
Topic is : how can upload excel data into MySQL using JSP(Java) but in CSV format

Q 1. so my first question is which package or jar to be import for this?
Q 2. how can give path to file object by using UI.
Q 3. Is my code right? if yes how can convert it into servlet.
 
Rancher
Posts: 471
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This would be so much more simple if you separate the logic into a servlet and just have the JSP have a form and maybe a message that had the result.


I think maybe you should read a tutorial or book  about jsp/servlet because looking at your code and questions it seems like you have no idea what's going on no offense.
 
Dave Tolls
Rancher
Posts: 4190
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a class that does what the code above does.
Forget about the server.

Just have the code accept a file name (for now) which will be an Excel file, and see if you can read the data in.

Until you've got that working don't even attempt to write the server side of it.

That way, when you do get round to writing it to run on a server you'll have the code that can read in an Excel file from a stream, get the data you want out of it, and save it into a database.

All you'll have to do then is call that code from a servlet.
 
Aneeket Bhatnagar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IDE: Eclipse
I Have Create Java Class

Folder Name: Java Resources-->src-->DB-->ReadExcelDemo.java

ReadExcelDemo.java Class





And This is my upload.jsp Page and how to call my ReadExcelDemo class and method with passing the file location






 
Dave Tolls
Rancher
Posts: 4190
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not a very good Java class.
It's not going to be transferable to a server, or anything else.

Get all that code out of main().

Remove main from that class entirely.

If you want to test it either create a class that only has main() and creates an instance of your new Excel reading class and calls the relevant method with a filename, or use a testing framework like JUnit.

Since you went straight for writing code in main() I have to ask how much Java experience you have?
 
Aneeket Bhatnagar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am fresher for java.
please do change in my code if required it will great help for me.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!