-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuyerDataWriter.java
36 lines (30 loc) · 1.05 KB
/
BuyerDataWriter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* BuyerDataWriter
* Class to edit a buyer data file.
* @author Syed Turab Ali Jafri.
* 4/14/2017
*/
package C212Amazon;
import java.sql.*;
public class BuyerDataWriter extends DataWriter{
/**
* Method to create a new buyer account.
* @param buyer The Buyer object whose account is created.
*/
public boolean createBuyer(Buyer buyer) {
String sqlQuery = "INSERT INTO buyer (buyer.username, buyer.password, buyer.firstname, buyer.lastname, buyer.phone, buyer.email)" +
"VALUES ('" + buyer.getUserName() + "', '" + buyer.getPassword() + "', "
+ "'" + buyer.getFirstName() + "', '" + buyer.getLastName() + "', '"
+ buyer.getPhone() + "', '" + buyer.getEmailAddress() + "');";
try{
Connection conn = databaseConnector();
Statement query = conn.createStatement();
query.executeUpdate(sqlQuery);
conn.close();
}
catch (Exception e){
System.err.println(e.getMessage());
}
return true;
}
}