First, I have try to scape data and I succefully done it. Next is store the information to a sqlite databse. I am stuck and not idea . I have using jsoup to web scrape data. I have try to using jdbc sqlite to create table. But I do not know how to connect each them like scaped data store in database. I have stuck in no 3, anyone please help me and guide me.Thanks advanced
The question is below:
You are required to develop a small system using MAVEN and Java programming language. The system should be able to:
1.Read Github-Id from a Github Issue page. Refer to the link below for the testing purpose.
https:
2.Read a list of student from a Github Wiki page. Refer to the link below for the testing purpose.
https:
3.Store the data into Sqlite database using the table format below:
| Matric | Name | GitHub Link | Status |
|--------|------------------------------|---------------------------|--------|
| 243340 | Yu Zhixiong | https:
| 250634 | Ahmad Afham Bin Noor Azizan | | No |
4.Compare the data and produce the following reports:
List all students who have submitted the GitHub account.
List all students who have not submitted the GitHub account.
Reporting format:
List all students who have submitted the GitHub account:
| No. | Matric | Name | GitHub Link |
|-----|--------|---------------------------------|---------------------------|
| 1 | 243340 | Yu Zhixiong | https:
| 2 | 253242 | Umi Madihah Binti Mohamed Raimi | https:
List all students who have NOT submitted the GitHub account:
| No. | Matric | Name |
|-----|--------|---------------------------------|
| 1 | 250634 | Ahmad Afham Bin Noor Azizan |
| 2 | 261307 | Lim Wei Yi |
What I have tried:
package com;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
public class escape {
public static void main (String[] args) {
new escape().list();
}
public void list() {
final String url =
"https://github.com/STIW3054-A202/Main-Data/wiki/List_of_Student";
try {
final Document document = Jsoup.connect(url).get();
for (Element row : document.select(
"div.gollum-markdown-content tr")) {
if (row.select("td:nth-of-type(1)").text().equals("")) {
continue;
} else {
final String ticker =
row.select("td:nth-of-type(1)").text();
final String matric_no =
row.select("td:nth-of-type(2)").text();
final String name =
row.select("td:nth-of-type(3)").text();
System.out.println(ticker + " " + matric_no + " " + name);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
package com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class insert {
private Connection connect() {
String url = "jdbc:sqlite:C://sqlite/db/test.db";
Connection conn = null;
try {
conn = DriverManager.getConnection(url);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return conn;
}
public void insertdata (String name, double capacity) {
String sql = "INSERT INTO warehouses(name,capacity) VALUES(?,?)";
try (Connection conn = this.connect();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, name);
pstmt.setDouble(2, capacity);
pstmt.executeUpdate();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
public static void main(String[] args) {
insert app = new insert();
app.insertdata("Raw Materials", 3000);
app.insertdata("Semifinished Goods", 4000);
app.insertdata("Finished Goods", 5000);
}
}
1.This code that I scrape data, and succefull run out a list student .Now i want store this in a sqlite table. I donnt know how to connect scrapped data to store in sqlite.
2.I have try do sqlite databse .But i can do in normal way and not idea how to the use scaped data to store.
3. According question there i have link is about githublink .we need this github link and join the student list to make a table ,like in the no 3 question output.