package fr.pizzeria.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcHelper {
	private String urlConnection;
	private String userConnection;
	private String passConnection;
	private Connection connection;
	private Statement statement;

	public JdbcHelper(String urlConnection, String userConnection, String passConnection) throws SQLException {
		String driverClassName = "com.mysql.jdbc.Driver";
		try {
			Class.forName(driverClassName);
			this.urlConnection = urlConnection;
			this.userConnection = userConnection;
			this.passConnection = passConnection;
		} catch (ClassNotFoundException e) {
			System.err.println("Erreur : Le driver " + driverClassName + " est introuvable.");
		}
	}

	@Override
	protected void finalize() throws Throwable {
		close();
		super.finalize();
	}

	private void open() throws SQLException {
		connection = DriverManager.getConnection(urlConnection, userConnection, passConnection);
	}

	public void close() throws SQLException {
		if (!statement.isClosed()) {
			statement.close();
		}
		if (!connection.isClosed()) {
			connection.close();
		}
	}

	public ResultSet executeQuery(String request) throws SQLException {
		open();
		statement = connection.createStatement();
		ResultSet results = statement.executeQuery(request);
		return results;
	}

	public int executeUpdate(String request) throws SQLException {
		open();
		statement = connection.createStatement();
		int results = statement.executeUpdate(request);
		return results;
	}
}

@@ -836,106 +836,8 @@
 %0D%0A%0D%0A
-%09@Override%0D%0A%09protected void finalize() throws Throwable %7B%0D%0A%09%09close();%0D%0A%09%09super.finalize();%0D%0A%09%7D%0D%0A%0D%0A
 %09pri
@@ -1278,27 +1278,14 @@
 %0D%0A%09%09
-ResultSet results =
+return
  sta
@@ -1315,35 +1315,16 @@
 uest);%0D%0A
-%09%09return results;%0D%0A
 %09%7D%0D%0A%0D%0A%09p
@@ -1448,21 +1448,14 @@
 %0D%0A%09%09
-int results =
+return
  sta
@@ -1490,27 +1490,8 @@
 );%0D%0A
-%09%09return results;%0D%0A
 %09%7D%0D%0A

Clean code