suppose it is ur callback method for creating customer instances.
But dont forget to create connection first. I hope it will be a good example for u. This time i am in hurry if u still find any problem post it here i will reply (inshaallah).
public
String ejbCreate(String id, String name,
String address, String telephone){
try{
System.out.println("in ejbCreate()");
addCustomer(id, name, address, telephone);
}
catch(Exception e){
throw new EJBException(e.getMessage());
}
this.id = id;
this.name = name;
this.address = address;
this.telephone = telephone;
return id;
}
////////////////////DATABASE/////////////////////
public void addCustomer(String id, String name,
String address, String telephone)
throws SQLException{
String query = "INSERT INTO CUSTOMER VALUES(?, ?, ?, ?)";
PreparedStatement ps = connection.prepareStatement(query);
ps.setString(1, id);
ps.setString(2, name);
ps.setString(3, address);
ps.setString(4, telephone);
ps.executeUpdate();
ps.close();
}