Good afternoon, there is such a task - You need to create a simple server application to call the three stored procedures from the MySQL database. And fasten to this html page to display the data.

I made a database, a simple table and three stored procedures too. Maven created a project in the idea, for example Hello World application zapperpil on the server, he gave me what I need. I even tied a servlet to a JSP page. Separately, I made another maven project and tested the connection to MySQL using JDBC with this program:

import com.mysql.fabric.jdbc.FabricMySQLDriver; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.sql.SQLException; public class Main { private static final String URL = "jdbc:mysql://localhost:3306/test"; private static final String USERNAME = "root"; private static final String PASSWORD = "root"; public static void main (String[] args) { Connection connection; try { Driver driver = new FabricMySQLDriver(); DriverManager.registerDriver(driver); connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); if (!connection.isClosed()) { System.out.println("Соединение с БД установлено!"); } connection.close(); if (connection.isClosed()) { System.out.println("Соединение с БД закрыто!"); } } catch (SQLException e) { System.err.println("Не удалось загрузить класс драйвера!"); } } } 

But the trouble is that I cannot understand how I can connect the database with the local server and attach the HTML page to this whole interface page. Maybe I use something extra? Help to deal with this porridge that I do not need, what is lacking? Maybe you need to add a database connection and a procedure call from it to the MyServlet class? It seems that I am somewhere nearby, but still does not work.

  • one
    you can use persistence.xml, then work with JPA, and for working with HTML, you can use Servlet and then respond to the request on the JSP page, Or you can use Rest service - Aslan Kussein

1 answer 1

It is necessary to create one project in which there will be a server with a database of data and a webcam. When creating a maven project you can use maven-archetype-webapp enter image description here

  • and how to prescribe dependencies? - Hev
  • one
    @Hev there will be pom.xml - you will pom.xml in it - Bohdan Korinnyi