import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;
public class DataBase {
public static Connection getConnection() throws SQLException { String servidor = "jdbc:mysql://localhost/"; String bancoDeDados = "controle_shows"; String usuario = "root"; String senha = "121212"; Connection connection = DriverManager.getConnection(servidor+bancoDeDados, usuario, senha); return connection; } }
-x-
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List;
public class Teste{
public static void main(String[] args) throws SQLException { List integrantes = new ArrayList <>();
try (Connection connection = new DataBase().getConnection()) { connection.setAutoCommit(false);
...
System.out.println(integrantes);*/ connection.commit(); } } }