add database connexion
This commit is contained in:
8
pom.xml
8
pom.xml
@ -18,7 +18,13 @@
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.18.1</version> </dependency>
|
||||
<version>1.18.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -6,11 +6,35 @@ import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class Crawler {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
|
||||
String dbUrl = "jdbc:mariadb://localhost:3306/Crawler";
|
||||
String user = "root";
|
||||
String password = "";
|
||||
|
||||
System.out.println("Tentative de connexion à la base de données...");
|
||||
|
||||
try (Connection connection = DriverManager.getConnection(url, user, password)) {
|
||||
if (connection != null) {
|
||||
System.out.println("✅ SUCCÈS : Connexion établie avec brio !");
|
||||
System.out.println("Serveur distant : " + connection.getMetaData().getDatabaseProductName());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
System.err.println("❌ ÉCHEC : Impossible de se connecter.");
|
||||
System.err.println("Erreur : " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
String url = "https://www.amazon.fr/Victool-temp%C3%A9rature-professionnel-r%C3%A9paration-%C3%A9lectronique/dp/B0FP2D7TBY/?_encoding=UTF8&pd_rd_w=UWXHj&content-id=amzn1.sym.5633189b-a269-4b24-8a80-52a48568a326%3Aamzn1.symc.752cde0b-d2ce-4cce-9121-769ea438869e&pf_rd_p=5633189b-a269-4b24-8a80-52a48568a326&pf_rd_r=G56TKFERTQ9WS62C7WY4&pd_rd_wg=mtTBQ&pd_rd_r=519dfa29-c58c-41b3-89ca-4d01e27bfc2e&ref_=pd_hp_d_atf_ci_mcx_mr_ca_hp_atf_d";
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user