Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I am trying to migrate a database created in MySQL and used in Netbeans as a Web App

 
M Sparks
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to make a Web App that accesses a MySQL database I created and
hooked up to NetBeans as a desktop app on localhost. I wrote code for a GUI
using a JSP for web and I believe the code works to add records into a table
but cannot see the database (the MySQL one I made and accessed via NetBeans)
to check! I'm very new to all this, so any help would be appreciated. My
code is below:
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65542
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are a newcomer to JSP then you have headed rather badly down the wrong path. There should be no Java code in your JSP. That is a practice that has been obsolete and discredited since 2002. 13 years ago!

You should find a JSP resource or tutorial that shows you how to write modern JSP using the JSTL (JSP Standard Tag Library) and EL (Expression Language).

First step is to refactor your Java code out of the JSP and into Java classes.

I recommended newcomers to JSP read the following articles:
  • The Secret Life of JSPs
  • The Front Man

  •  
    Stefan Evans
    Bartender
    Posts: 1822
    10
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    So if I understand you right, the first thing you need to do is get a tool which will let you connect to the MYSQL database and look at its contents.
    That way you can actually see if anything is getting in there

    Second thing, embedding java code in a JSP is NOT a good idea.
    Put java code in a java class.

    You should have at least three artifacts
    - Customer.java - for the Customer Class
    - JSP page to gather information
    - Servlet to handle the submit from the JSP, and save it.

    Right now you have it all in one big file, which does not lend itself to easy debugging.

    At a quick glance, I can't see anything obviously wrong with the code itself.
    The exception handling of "log all errors and continue as if nothing bad happened" could be improved. Sometimes it makes more sense to not catch the exception if you can't do anything about it.

    hope this helps some,
    Stefan
     
    M Sparks
    Greenhorn
    Posts: 13
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the info and the heads up on no java in JSP. I'll get cracking on improving!
     
    J. Kevin Robbins
    Bartender
    Posts: 1801
    28
    Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Stefan Evans wrote:
    You should have at least three artifacts

    I would add one more to that; a DAO to handle the database interaction.
     
    Danger, 10,000 volts, very electic .... tiny ad:
    the new thread boost feature brings a LOT of attention to your favorite threads
    https://coderanch.com/t/674455/Thread-Boost-feature
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!