• 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

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

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

  •  
    Bartender
    Posts: 1845
    10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the info and the heads up on no java in JSP. I'll get cracking on improving!
     
    Bartender
    Posts: 1810
    28
    jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Are you okay? You look a little big. Maybe this tiny ad will help:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic