有四個不同的數組字符串,我必須將所有數據插入數據庫,但它只將最后一個字符串數組和第一個、第二個和第三個數組字符串的最后一個值存儲到數據庫中。public class Scrape { private static final String url1 = "jdbc:mysql://localhost/Scraping_Data"; private static final String user = "root"; private static final String password = "root@123"; private String title="",rating="",price="",url=""; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getRating() { return rating; } public void setRating(String rating) { this.rating = rating; } public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public static void main(String[] args)throws IOException { try { List<String> ar1 = new ArrayList<String>(); List<String> ar2 = new ArrayList<String>(); List<String> ar3 = new ArrayList<String>(); List<String> ar4 = new ArrayList<String>(); Class.forName("org.gjt.mm.mysql.Driver"); Connection con = DriverManager.getConnection(url1, user, password);只有評級值被插入到數據庫中。但是 title、price 和 url 的最后一個值存儲在列中
將多個字符串數組插入數據庫
慕田峪9158850
2022-11-30 11:21:21