Can anyone help me with an example where from start to finish you can explain how I can create a database, the POJO, then put it in JSP format which can send to the database. Something with like 1 table, 1 set/get method, 1 field in JSP inputText, and 1 commandButton which will send it to the database?
I’ve been working on an application for hours. I am able to manually put a field in a mySQL database and query that database so I can login with the credentials manually put into the database. But how do I add a field (like a user) to the database?
I may be a bit optimistic, but isn’t that the stuff that every average Java EE5 tutorial teaches you?
Anyways, I’d start with the chapter Persistence in the Web Tier from the Sun/Oracle Java EE 5 tutorial, because in version 5 they still talked about JSP’s. This chapter walks your through all the steps you describe.
There is 1 catch (or at least something that’s not immediately obvious imo): if you manipulate data from the web tier, you have to manually wrap the update section in a UserTransaction, as explained here, their example code looks like this:
Another remark: modern IDEs reduce the amount of boilerplate you have to write, eg they can generate the entity classes starting from an existing db, handle the setup of the persistence unit for you, etc. It may be interesting to write all that stuff once to know how it’s done but in “production” contexts that’s something your IDE should do.