📄 dbtest.java
字号:
public class DBTest {
public static void main(String[] args) {
try {
ClientBillingDB db = new ClientBillingDB();
//Test transaction insertion, updating, deletion
Transaction t = new Transaction();
t.amount = 5;
t.clientID = 2;
t.date = "04-03-1981";
t.description = "new transaction";
t.transactionID = 24;
db.create(t);
//Update ID
t.transactionID = 112;
db.update(24, t);
//Update a different non-key field
t.description = "updated description";
db.update(t.transactionID, t);
db.delete(t);
Client c = new Client();
c.address = "333 Strad";
c.clientID = 100;
c.dob = "1981-02-04";
c.email = "walt@straf.com";
c.firstName = "Walter";
c.lastName = "Kronk";
c.miscInfo = "He enjoys long walks.";
c.phone = "120-4355";
db.create(c);
c.clientID = 99;
db.update(100, c);
c.firstName = "Albert";
db.update(c.clientID, c);
db.delete(c);
//Display results
//Get clients
Client[] clients = db.retrieveClients();
for (int i = 0; i < clients.length; i++)
System.out.println(clients[i]);
//Get transactions
Transaction[] trans = db.retrieveTransactions(clients[0].clientID);
for (int i = 0; i < trans.length; i++)
System.out.println(trans[i]);
db.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -