Hello i want to know the MAX USER CONNECTIONS is because i close the connection? or what this i code i want ask for help because after 4 search, i get the MAX USER CONNECTIONS error ListarClientes.java Here i put the rows and columns to the Table, and i ask for the SQL
public void ListarClients(String consulta, DefaultTableModel modelo) throws SQLException{
String sql = consulta;
Connection con = Conexion.connect();
try {
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(sql);
ResultSetMetaData metaDatos = rs.getMetaData();
// Se obtiene el número de columnas.
int numeroColumnas = metaDatos.getColumnCount();
Object[] etiquetas = new Object[numeroColumnas];
for (int i = 0; i < numeroColumnas; i++){
// Nuevamente, para ResultSetMetaData la primera columna es la 1.
etiquetas[i] = metaDatos.getColumnLabel(i + 1);
}
modelo.setColumnIdentifiers(etiquetas);
while (rs.next()){
Object [] fila = new Object[numeroColumnas];
for (int i=0;i<numeroColumnas;i++)
fila[i] = rs.getObject(i+1); // El primer indice en rs es el 1, no el cero, por eso se suma 1.
modelo.addRow(fila);
cerrar();
rs.close();
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
}
}
1 SEARCH 1 RUN 1 TIME WHEN I OPEN THE SEARCH.JAVA WITH THE METODO ALL(); - WITH THIS WHEN THE FRAME GET OPEN THE DATA IS PREPARE AND IS IN THE TABLE
public void all(){
Usuarios u = new Usuarios();
DefaultTableModel modelo = new DefaultTableModel();
String consulta = "SELECT * FROM clientes";
try {
u.ListarClients(consulta, modelo);
} catch (SQLException ex) {
Logger.getLogger(BuscarCliente.class.getName()).log(Level.SEVERE, null, ex);
}
tabla.setModel(modelo);
}
2.- SEARCH.. IN THE BOX I put the data to search and i click in search button, this button jave this method: IN THIS MOMMENT all is ok..
Usuarios u = new Usuarios();
DefaultTableModel modelo = new DefaultTableModel();
String consulta = "SELECT * FROM clientes WHERE rfc LIKE '"+rfc.getText()+"%'";
try {
u.ListarClients(consulta, modelo);
} catch (SQLException ex) {
Logger.getLogger(BuscarCliente.class.getName()).log(Level.SEVERE, null, ex);
}
tabla.setModel(modelo);
3.- i doe another search with the same method... 4.- i doe another and the error max connections show in this momment the SQLExeception 5.- IF I CLOSE THE PROJECT AND RUN AGAIN THE CONSOLE IS BUG IN THE SQLExecption Max Users Connections and the program cant continue.. What i doe wrong? My code i dont close the connections ? or what?