Solved

JSP email submit form ..

Posted on 2006-07-10
1
189 Views
Last Modified: 2010-04-01
Hi there,

I have a database set up with an ip, database name, user and password. The table then has a field for website id, email and a timestamp.

The question is .. what is the easiest way to connect and post an entry to this database checking if the email already exists ?

The websiteid can be hardcoded but obviously the email needs to be posted from the form to another page and then put in a sting and a timestamp needs to be added.

thanks for your time.
0
Comment
Question by:Eternal_Student
1 Comment
 
LVL 9

Accepted Solution

by:
riaancornelius earned 250 total points
ID: 17072117
Look at:

http://www.duffyinfodesign.com/support/support_jspdb.html

For your specific application you'll use: //Get SQL Statement.
//Replace TableName to your table's name.
java.sql.ResultSet rs=connection.createStatement().executeQuery("select count(*) AS cnt from $TableName where email = 'emailAddressFromForm' ");

int count = 0;
 //For each row, get the first column and print it out
if(rs.first()){
    count = rs.getInt("cnt");
}
if( count==0 ){
    connection.createStatement().executeUpdate("INSERT INTO $TableName(websiteID,email) VALUES('$id', '$emailAddress') ");
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java beans and EJBs 5 196
some methods private some are not 8 220
How to Make JSP Pages Responsive ? details are below 3 925
oracle fusion vs MQ 2 122
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Use Windows Task Scheduler to print a Word document weekly so your printer ink won't dry out.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question