You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by sam wun <sw...@gmx.com> on 2008/08/25 21:37:53 UTC
how to create domain.Order class
Hi,
I have a java class file CreateOrder.java with the following coding:
package command;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import domain.Order;
/**
* Create Order in the database
*/
public class CreateOrder implements DatabaseCommand {
private Order order;
public CreateOrder(Order o) {
this.order = o;
}
public Object executeDatabaseOperation(Connection conn) throws
SQLException {
// Create order
PreparedStatement sta = conn.prepareStatement("INSERT INTO
ORDERS (ID, CUST_ID, DATE_PLACED, AMOUNT) VALUES (?, ?, ?, ?)");
sta.setInt(1, order.getId());
sta.setInt(2, order.getCustId());
sta.setDate(3, order.getDatePlaced());
sta.setInt(4, order.getOrderAmount());
int rows_inserted = sta.executeUpdate();
sta.close();
return rows_inserted;
}
}
Can anyone tell me how to create domain.Order class?
I am using Eclipse 3.4, the project name is DBTest with the following
structure:
> DBTest
Deployment Descriptor: DBTest
Java Resourse: src
+command
...
CreateOrder.java
...
Libraries
Build
WebContent
JavaScript Support
I am wondering where to create a domain.Order class/java file. Do I have
to create a directory domain under src/ directory and then create
Order.java file inside theh domain folder?
Thanks
Sam
Re: how to create domain.Order class
Posted by Youssef Mohammed <yo...@gmail.com>.
>
> I am wondering where to create a domain.Order class/java file. Do I have
> to create a directory domain under src/ directory and then create
> Order.java file inside theh domain folder?
yes.
Best of luck in your homework :P
>
>
>
>
>
> Thanks
>
> Sam
>
>
>
--
Regards, Youssef