int capacity, double tonnage)
throws CreateException {
System.out.println("ejbCreate() pk="+id+" name="+name);
if ((id.intValue() < 1) || (name == null))
throw new CreateException("Invalid Parameters");
this.id = id;
this.name = name;
this.capacity = capacity;
this.tonnage = tonnage;
Connection con = null;
PreparedStatement ps = null;
try {
con = this.getConnection();
System.out.println("Obtained Connection: Trying to create statement");
ps = con.prepareStatement("insert into"+"\""+"Ship"+"\""+ " (id, name, capacity, tonnage) values (?,?,?,?)");
ps.setInt(1, id.intValue());
ps.setString(2, name);
ps.setInt(3, capacity);
ps.setDouble(4, tonnage);
if (ps.executeUpdate() != 1) {
throw new CreateException ("Failed to add Ship to database");
}
return id;
}
catch (SQLException se) {
throw new EJBException (se);