Solved

JSP email submit form ..

Posted on 2006-07-10
1
186 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
xjc and jaxb 2 88
'exit' is not valid keyword in java 14 134
spring example errors 33 200
JavaScript parse form with colon separated values 2 63
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now