According to the explanation made in similar questions on the site in English:
The problem seems to be that your database has too many open connections, so it can no longer open more connections. You can check the connections made to your MySQL database using the SHOW PROCESSLIST
command, you can eliminate those connections using the KILL <processid>
command, the <processid>
you get as a result of the command to see the connections.
Now, this problem may reappear because you are not closing the connections in your application properly or because your database is configured to have a very limited number of connections (I very much doubt this unless you have been playing with the settings of my.ini or my.cfg since the default value in MySQL is 150). I recommend you check your application and the places where you use a database connection so that you can properly close it by calling the Connection#close
ALWAYS method (general advice for the readers of this answer).
In your specific case, this is because your method is recursive and infinite, noticed by this pair of lines:
public static Connection ConnecrDb() {
//implementación no necesaria para evaluar que es recursivo infinito
return ConnecrDb(); //retorna el resultado de llamarse a sí mismo
//lo que resulta en una recursividad infinita puesto que
//no hay restricciones para evitar este resultado
}
Your code should be written as follows:
public static Connection ConnecrDb(){
Connection conn = null;
try {
//desde Java 7 y JDBC 4 no necesitas llamar a esta línea
//para abrir una conexión a la base de datos
//Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/prueba1","root","marbella2011");
}
catch (Exception e) {
//es mejor tener todo el stacktrace del error
//no solo el mensaje
//System.out.println(e);
e.printStackTrace(System.out);
}
//return ConnecrDb();
return conn;
}
Likewise, from the above, remember ALWAYS to close your connections to the database, either by calling the Connection#close
method manually or by using try-with-resources
available from Java 7.