aspose file tools*
The moose likes Servlets and the fly likes saved records in a database from servlet. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "saved records in a database from servlet. " Watch "saved records in a database from servlet. " New topic
Author

saved records in a database from servlet.

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
i am beginner .

1-i have created servlet program which takes username,password,hobby,gender and saved in a database .
but except username all saved(username column is blank for every entry and all other column filled).

2-i have commented on the statement of(if(password.equals("cnfrmPassword")) and at last i wrote a else statement) matching password and conform password and when i uncommented then always output come that (password and confrmpassword didn't match)even i give same password..
please help me.
thanks



nir sharma
Ranch Hand

Joined: Sep 11, 2012
Posts: 72

post your jsp file also.


(if(password.equals("cnfrmPassword"))
here cnfrmPassword is treated as a string and not a variable.
this should be :


Also try to debug and check whether you are getting username value in servlet from jsp or not.
Saket Kumar Sinha
Ranch Hand

Joined: Aug 04, 2011
Posts: 31


Just a suggestion
setting DataSource in web.xml and then using getDataSource method for javax.sql.DataSource is better way for connecting to DataBase
Ashwin Sridhar
Ranch Hand

Joined: Jul 09, 2011
Posts: 272

Probably the name of the username field and the one you are using in the getParameter may be different. Try debugging by using System.out after you receive the parameters in your servlet.


Ashwin Sridhar
SCJP | SCWCD | OCA
Ashwin Sridhar
Ranch Hand

Joined: Jul 09, 2011
Posts: 272



Just a suggestion
setting DataSource in web.xml and then using getDataSource method for javax.sql.DataSource is better way for connecting to DataBase



Using a datasource would be efficient in case of multiple connections. in the sense when you have a pool of connections and want them to be used judiciously.

In case of single connection, I would connect using DriverManager.

Correct me if am wrong.
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
thank you so much its working...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: saved records in a database from servlet.
 
Similar Threads
Unable to direct to page after login
about hidden from fields
I Have Problem To Separate Business Logic From Front Controller
problem with while loop when ResultSet.next() is called
Code error