Skip to content
Snippets Groups Projects
Commit 1e23525b authored by Ahmad Faiq's avatar Ahmad Faiq
Browse files

edit pebaikan

parent 6d376bd9
Branches
No related merge requests found
......@@ -38,15 +38,15 @@ public class Buys {
ArrayList<buysObject> items = new ArrayList<>();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection(
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/Marketplace?zeroDateTimeBehavior=convertToNull",
"root",
"");
Statement stmt = connect.createStatement();
Statement stmt = conn.createStatement();
String sql;
sql = "SELECT * FROM buys WHERE id_seller = ?";
PreparedStatement dbStatement = connect.prepareStatement(sql);
PreparedStatement dbStatement = conn.prepareStatement(sql);
dbStatement.setInt(1, sellerID);
/* Get every data returned by SQL query */
ResultSet rs = dbStatement.executeQuery();
......@@ -74,7 +74,7 @@ public class Buys {
}
rs.close();
stmt.close();
connect.close();
conn.close();
} catch (ClassNotFoundException | SQLException ex) {
Logger.getLogger(Items.class.getName()).log(Level.SEVERE, null, ex);
}
......@@ -92,15 +92,15 @@ public class Buys {
ArrayList<buysObject> items = new ArrayList<>();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection(
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/Marketplace?zeroDateTimeBehavior=convertToNull",
"root",
"");
Statement stmt = connect.createStatement();
Statement stmt = conn.createStatement();
String sql;
sql = "SELECT * FROM buys WHERE id_buyer = ?";
PreparedStatement dbStatement = connect.prepareStatement(sql);
PreparedStatement dbStatement = conn.prepareStatement(sql);
dbStatement.setInt(1, buyerID);
/* Get every data returned by SQL query */
ResultSet rs = dbStatement.executeQuery();
......@@ -128,7 +128,7 @@ public class Buys {
}
rs.close();
stmt.close();
connect.close();
conn.close();
} catch (ClassNotFoundException | SQLException ex) {
Logger.getLogger(Items.class.getName()).log(Level.SEVERE, null, ex);
}
......@@ -175,16 +175,16 @@ public class Buys {
try {
Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection(
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/Marketplace?zeroDateTimeBehavior=convertToNull",
"root",
"");
Statement stmt = connect.createStatement();
Statement stmt = conn.createStatement();
String sql;
sql = "INSERT into BUYS (id_item, id_buyer, id_seller, photo, item_name, item_price, quantity, consignee, full_address, postal_code, phone_number, cc_number, verification_code, date, time) "
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement dbStatement = connect.prepareStatement(sql);
PreparedStatement dbStatement = conn.prepareStatement(sql);
dbStatement.setInt(1, id_item);
dbStatement.setInt(2, id_buyer);
dbStatement.setInt(3, id_seller);
......@@ -203,7 +203,7 @@ public class Buys {
/* Get every data returned by SQL query */
int rs = dbStatement.executeUpdate();
stmt.close();
connect.close();
conn.close();
} catch (ClassNotFoundException | SQLException ex) {
Logger.getLogger(Items.class.getName()).log(Level.SEVERE, null, ex);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment