Estou tentando fazer o Exrecício, mas ao executar o programa me returna o erro
Exception in thread "main" java.lang.StackOverflowError
at br.com.caelum.jdbc.DataBase.getConnection(DataBase.java:10)
Segue meu código da classe DataBase:
package br.com.caelum.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DataBase {
static Connection getConnection() throws SQLException {
Connection connection = DataBase.getConnection();
return connection;
}
}
Código da classe com o main:
package br.com.caelum.jdbc;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
public class TestaInsercao {
public static void main(String[] args) throws SQLException {
Connection connection = DataBase.getConnection();
Statement statement = connection.createStatement();
boolean resultado = statement.execute("insert into Produto (nome, descricao) values('Notebook', 'i5')");
System.out.println(resultado);
connection.close();
statement.close();
}
}