check data exists already

hi all,

this is my 1st post...My scenario is I need to check whether the user name exists in the database.I get the user name from UI.I'm doing project in struts and mysql using jdbc to sell products online for trial.my web application will give products for trial for free.But it should not allow the same product to be given twice to the same user.

I've created 3 tables in mysql user_table,user_product table and product table..product table contains static data

Now I've problem in writing the code...typically the user will register with his username(username here refers to his email id )

the logic is

1)if the user gives his username and product in the UI,I need to check in the data base if the username exists and if it exists then what is the product?

2)has the user chosen the same product again,if so then I'll send a msg to the user thru UI-"choose another product"

3) If the user has chosen different product then I need to make insertion in the user_product table.The user_product table consists of username as foreign key..so if the user is already registered and has chosen the different product i will make entry in the user_product table.

The whole code should be in java

I'm a new to all this..I can understand the logic..pl help me with the code...

pl...

[1349 byte] By [ela_archua] at [2007-11-26 14:00:25]
# 1

> I'm a new to all this..I can understand the logic..pl

> help me with the code...

> pl...

No one is going to write the code for you. There are many books and tutorials out there that will help you.

http://java.sun.com/docs/books/tutorial/jdbc/index.html

When posting you will get a much better response if you ask specific questions.

zadoka at 2007-7-8 1:41:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

You really have several use cases here.

I would say that you should start by thinking less about the tables and more about objects. Have you written a User class? A Product class? Forget about the tables for now and get those written and tested. Then worry about the persistence stuff.

You're thinking about this problem in a procedural, client-server fashon. Java's an object-oriented language. Start with the objects.

%

duffymoa at 2007-7-8 1:41:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

> 2) has the user chosen the same product again,if so then I'll send a msg to

> the user thru UI-"choose another product"

Then why not only allow the user to choose from products they have not already chosen? I can't understand why people produce designs that allow the users to select things that they shouldn't be selecting.

DrClapa at 2007-7-8 1:41:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
hi 'm writing code..but it doesnt works...as 'm a newbie 'm seeking helpThis forum is to help
ela_archua at 2007-7-8 1:41:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
> hi 'm writing code..but it doesnt works...as 'm a> newbie 'm seeking help> > This forum is to helpWell done, you are correct. We're here to help, not to write your program. That's what people hire consultants for.Ted.
ted_trippina at 2007-7-8 1:41:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

> > hi 'm writing code..but it doesnt works...as 'm a

> > newbie 'm seeking help

> >

> > This forum is to help

>

> Well done, you are correct. We're here to help, not

> to write your program. That's what people hire

> consultants for.

>

> Ted.

There is an outfit called rent-a-coder recommended by the Wall Street Journal where you post your software needs and programmers bid on it. The average price seems to range from $50-200. I have never used it however, but here is the link:

http://www.rentacoder.com/RentACoder/default.asp?txtFromURL=PSC_ShowBidRequest_436043

peacerosetxa at 2007-7-8 1:41:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7

> hi 'm writing code..but it doesnt works...as 'm a

> newbie 'm seeking help

We don't know anything about your code. (Because we can't see any of it.) Maybe you just need a JDBC tutorial? Here:

http://java.sun.com/docs/books/tutorial/jdbc/index.html

Edit: I see somebody already posted that link. So did you read it? Did it help? We can't do anything for you right now because all we know is you have some code that "doesn't work" (and we don't know what that means either).

Message was edited by:

DrClap

DrClapa at 2007-7-8 1:41:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8
> hi 'm writing code..but it doesnt works...Try correcting the typo on line 137.
cotton.ma at 2007-7-8 1:41:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...