This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlets with JDBC and MYSQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets with JDBC and MYSQL" Watch "Servlets with JDBC and MYSQL" New topic
Author

Servlets with JDBC and MYSQL

ankita balaji
Greenhorn

Joined: Aug 19, 2004
Posts: 11
Hai Everyone,
Good Evening.Iam new to servlets and Mysql.Iam using Mysql as my backend and servlets as my frontend for the project of storing a group pf users in a particular company.Can i know if a new user enters into company,he must register in a register page and how does his details get automatically enetered into the database table without using any Web.xml file.Can anyone plz drop me a example in this case.Thank you
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
so how did you plan to map your servlet without web.xml?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
135

Ankita,
Since this question is about web.xml, I am moving it to our Servlets forum.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

"Web.xml" is used with Servlets, you don't have Servlets running unless you have your web.xml file, so you can't have one without the other.

This sounds to me like a classwork assignment.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

ankita balaji

For a new comer to Servlets and JDBC, there is not a simple answer to your question. Nor will posting some random code help you out.

How familiar are you with JDBC right now? How familiar with Servlets? Technically, this is a 2 part question..

1. How do I use Servlets without using the web.xml file
2. How do I insert information from a web page into a MySQL database.

As far as #1 goes, Mark said it best in this thread.


using Tomcat's invoker mapping (no longer a default in Tomcat) you can get to a servlet by /servlet/packagename.classname (Works in Resin too).

It's useful for testing, but I wouldn't want to use it in production use.


For #2 getting information from the submitted form is as simple as doing a request.getParameter("formElementName"). Then it's just a matter of doing a little JDBC. However, JDBC is better suited for the JDBC Forum.

What I would recommend is that you begin by getting your servlets running. If you choose not to use the web.xml file, you'll probably have to hunt down some information on the relivent servlet containers (Tomcat, Resin, etc) documentation to find out exactly how they suggest doing it. After you have some basic Servlet work down and you are comfortable with gathering data from a web form, move on to entering that information in a Database and ask those JDBC specific questions in the JDBC forum.

Hope that helps.


GenRocket - A Test Data Generation Platform
sidharth nayak
Greenhorn

Joined: Aug 29, 2004
Posts: 6
hi ankita

u should try jdbc for entering the data into the database
use prepared statment clause instead of execute statement
it ll be helpful

try it


sidharth
Hussam Bamatraf
Greenhorn

Joined: Aug 25, 2003
Posts: 14
Go to the following link http://www.javaranch.com/drive/jdbc/index.jsp
to know how to read MySql database using java.


SCJP 90%<br />FileNet Certified Professional: Content Management Developer 92%<br />FileNet Certified Professional: Business Process Management Developer 92%
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Servlets with JDBC and MYSQL
 
Similar Threads
Registering new servlet
WebSphere Portal Server
making a login system ?
Getting simple JBoss Seam sample to work
Data truncation: Truncated incorrect DOUBLE value: