Skip to content

Commit 73e7eee

Browse files
authored
Added Project
1 parent e5ae239 commit 73e7eee

File tree

8 files changed

+208
-0
lines changed

8 files changed

+208
-0
lines changed

nb-configuration.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-shared-configuration>
3+
<!--
4+
This file contains additional configuration written by modules in the NetBeans IDE.
5+
The configuration is intended to be shared among all the users of project and
6+
therefore it is assumed to be part of version control checkout.
7+
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
8+
-->
9+
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
10+
<!--
11+
Properties that influence various parts of the IDE, especially code formatting and the like.
12+
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
13+
That way multiple projects can share the same settings (useful for formatting rules for example).
14+
Any value defined here will override the pom.xml file value but is only applicable to the current project.
15+
-->
16+
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
17+
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>Tomcat</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
18+
</properties>
19+
</project-shared-configuration>

pom.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.mycompany</groupId>
5+
<artifactId>mavenproject2</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>war</packaging>
8+
<name>mavenproject2-1.0-SNAPSHOT</name>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<jakartaee>10.0.0</jakartaee>
13+
</properties>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>jakarta.platform</groupId>
18+
<artifactId>jakarta.jakartaee-api</artifactId>
19+
<version>${jakartaee}</version>
20+
<scope>provided</scope>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.glassfish.jersey.containers</groupId>
24+
<artifactId>jersey-container-servlet</artifactId>
25+
<version>3.1.6</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.glassfish.jersey.core</groupId>
29+
<artifactId>jersey-server</artifactId>
30+
<version>3.1.6</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.glassfish.jersey.core</groupId>
34+
<artifactId>jersey-client</artifactId>
35+
<version>3.1.6</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.glassfish.jersey.inject</groupId>
39+
<artifactId>jersey-hk2</artifactId>
40+
<version>3.1.6</version>
41+
</dependency>
42+
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-compiler-plugin</artifactId>
50+
<version>3.8.1</version>
51+
<configuration>
52+
<source>11</source>
53+
<target>11</target>
54+
</configuration>
55+
</plugin>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-war-plugin</artifactId>
59+
<version>3.3.2</version>
60+
</plugin>
61+
</plugins>
62+
</build>
63+
</project>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4+
*/
5+
package com.mycompany.mavenproject2;
6+
7+
import jakarta.ws.rs.GET;
8+
import jakarta.ws.rs.Path;
9+
import jakarta.ws.rs.Produces;
10+
import jakarta.ws.rs.core.Context;
11+
import jakarta.ws.rs.core.UriInfo;
12+
import java.sql.Connection;
13+
import java.sql.DriverManager;
14+
import java.sql.ResultSet;
15+
import java.sql.SQLException;
16+
import java.sql.Statement;
17+
18+
@Path("helloworld")
19+
public class HelloWorld {
20+
21+
private static final String JDBC_URL = "jdbc:mysql://localhost:3306/prenotazioni";
22+
private static final String USERNAME = "root";
23+
private static final String PASSWORD = "";
24+
25+
Connection connection;
26+
27+
@Context
28+
private UriInfo context;
29+
30+
/**
31+
* Retrieves representation of an instance of helloWorld.HelloWorld
32+
*
33+
* @return an instance of java.lang.String
34+
*/
35+
36+
@GET
37+
@Produces("application/json")
38+
public String getJSON() {
39+
return "";
40+
}
41+
42+
@GET
43+
@Produces("text/html")
44+
public String getSQLdata() {
45+
try {
46+
// Establish connection to MySQL database
47+
connection = DriverManager.getConnection(JDBC_URL, USERNAME, PASSWORD);
48+
49+
// Create a statement
50+
Statement statement = connection.createStatement();
51+
52+
String sqlQuery = "SELECT * FROM prenotazioni";
53+
ResultSet resultSet = statement.executeQuery(sqlQuery);
54+
StringBuilder result = new StringBuilder();
55+
while (resultSet.next()) {
56+
// Retrieve data from each row
57+
int id = resultSet.getInt("id_prenotazione");
58+
String data = resultSet.getString("data");
59+
String note = resultSet.getString("note");
60+
// Process the data as needed
61+
result.append("ID: ").append(id).append(" ,Data: ").append(data).append(" ,Note: ").append(note);
62+
}
63+
// Close the result set and statement
64+
resultSet.close();
65+
statement.close();
66+
connection.close();
67+
68+
return "<h1>" + result.toString() + "</h1>";
69+
} catch (SQLException e) {
70+
e.printStackTrace();
71+
}
72+
return "<h1>errore</h1>";
73+
}
74+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
3+
<!-- Define Persistence Unit -->
4+
<persistence-unit name="my_persistence_unit">
5+
6+
</persistence-unit>
7+
</persistence>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Context path="/mavenproject2"/>

src/main/webapp/WEB-INF/beans.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
5+
bean-discovery-mode="all">
6+
</beans>

src/main/webapp/WEB-INF/web.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
5+
version="6.0">
6+
7+
<servlet>
8+
<servlet-name>Jersey REST Service</servlet-name>
9+
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
10+
<init-param>
11+
<param-name>jersey.config.server.provider.packages</param-name>
12+
<param-value>com.mycompany.mavenproject2</param-value>
13+
</init-param>
14+
<load-on-startup>1</load-on-startup>
15+
</servlet>
16+
<servlet-mapping>
17+
<servlet-name>Jersey REST Service</servlet-name>
18+
<url-pattern>/api/*</url-pattern>
19+
</servlet-mapping>
20+
21+
22+
<session-config>
23+
<session-timeout>
24+
30
25+
</session-timeout>
26+
</session-config>
27+
</web-app>

src/main/webapp/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Start Page</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
</head>
7+
<body>
8+
<h1>Hello World!</h1>
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)