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

Database problems

 
Andrew Lock
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just moved over from Asp and started my writting a small forum (like i did when I learned asp)
1. Trying to pull from a form, in asp I would use:
("INSERT INTO Message (MessageSubject, MessageBody) VALUES ('"&MessageSubject&"' , '"&MessageBody&"' ) ");
How do I do this in jsp?
2. How do I pass the date and time over for when the message was created
3. I think that this can be done by JSP, servlets or beans , is this correct? Which would be the easyest way to learn it, and which would be the best way to do it?
 
Tim Holloway
Bartender
Posts: 18419
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Just as there's more to ASP than the SQL statement you listed, there's also more to J2EE. You'll need to create a connection object and do various other minor tasks. This is normally done in JDBC. The SQL code is the same as it would be for ASP.
2. Java has 2 date/time classes - java.util.Date and java.sql.Date. One is more convenient for general date/time manipulation and formatting, the other is designed to fit into databases better. Conversion from one form to the other is fairly simple.
3. "Best" varies with what you need to do. The simplest way to go from an ASP background is probably JSP, as the translation process is pretty much one-to-one. If you feel more comfortable in a code-only environment or have more logic than HTML, servlets are an alternative route - they both compile down to almost the same thing.
J2EE supports 2 different types of Javabeans - simple Javabeans and Enterprise Javabeans. A simple Javabean is more or less equivalent to a COM object, and an EJB to a DCOM object. Beyond that, I recommend you check out your favorite bookstore for J2EE books. If it's anything like the place where I hang out, the only problem you should have is deciding which book you want - they currently devote as much shelf space to Java as they do to VB, C++ and C# combined.
If you're into online reading and/or frugal living, you can also check out the docs at http://java.sun.com
 
Andrew Lock
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers for that.
think i'm going to aim for jsp and servlets and leave beans for while.
brain was fried with the supper easy instal of tomcat etc.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!