title: Could not find or load main class when trying to connect MariaDB
body: <p><strong>Error</strong>: Could not find or load main class...</p>
  
  <p>What am I doing wrong when trying to connect Maria DB in java? I'm a novice developer in java so don't be rude...</p>
  
  <p>Am I compiling in a wrong way this file? Also I tried to download mysql and mariaDb drivers but still had no success...I think the driver is not the problem, appreciate all the guidance and help.</p>
  
  <p>This is all my code:</p>
  
  <pre><code>Panaderia.java
  
  package proyecto;
  
  import javax.swing.JFrame;
  import java.awt.event.ActionListener;
  import java.awt.event.ActionEvent;
  import javax.swing.JFrame;
  import javax.swing.JButton;
  import javax.swing.JTextArea;
  import javax.swing.JTextField;
  import java.awt.FlowLayout;
  import java.sql.*;
  
  public class Panaderia extends JFrame implements ActionListener{
      JTextArea tablas_ta;
      JTextArea registros_ta;
      JButton consultarTablas_btn;
      JButton consultarRegistros_btn;
      JTextField textField;
  
      /*
       * Método constructor
       **/
      public Panaderia(){
  
          super("Ejemplo de Java + MySQL");
  
          //Configurar la operación de salida por defecto para JFrame
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          this.setSize(800,750);
  
          setLayout(new FlowLayout());
  
          consultarTablas_btn = new JButton("Consultar tablas");
          consultarTablas_btn.setActionCommand("ConsultarTablas");
          add(consultarTablas_btn); 
  
          tablas_ta = new JTextArea(10, 70);
          add(tablas_ta);
  
          textField = new JTextField(30);
          add(textField);
  
          consultarRegistros_btn = new JButton("Consultar registros");
          consultarRegistros_btn.setActionCommand("ConsultarRegistros");
          add(consultarRegistros_btn); 
  
          registros_ta = new JTextArea(10, 70);
          add(registros_ta);
  
  
          // Usar este objeto como Manejador de eventos 
          consultarTablas_btn.addActionListener(this);
          consultarRegistros_btn.addActionListener(this);
          textField.addActionListener(this);
  
  
          this.setVisible(true);
      }
  
  
      public static void main(String[] args) {
  
          Panaderia mjf = new Panaderia();
      }
  
      @Override
      public void actionPerformed(ActionEvent evento) {
          String db, dbuser, pass;
              db = "ejemplos";//cambiar por el nombre de la base de datos que desean utilizar
              dbuser = "root";
              pass = "";
          if(evento.getActionCommand()=="ConsultarTablas") {  
  
              try {       
                  Class.forName("com.mysql.jdbc.Driver");
  
                  Connection con = DriverManager.getConnection(
                      "jdbc:mysql://localhost:3306/"+db, dbuser, pass);
  
                  Statement stmt = con.createStatement();  
                  ResultSet rs = stmt.executeQuery("SHOW TABLES");  
  
                  while( rs.next() ) {
                      tablas_ta.append( rs.getString(1) + "\n");
                  }
  
                  tablas_ta.append("\n");
  
                  con.close();
  
              } catch(Exception e) { 
                  System.out.println(e);
              }
  
          }
  
          if(evento.getActionCommand()=="ConsultarRegistros") {   
  
              try {       
                  Class.forName("com.mysql.jdbc.Driver");
  
                  Connection con = DriverManager.getConnection(
                      "jdbc:mysql://localhost:3306/"+db, dbuser, pass);
  
                  Statement stmt = con.createStatement(); 
  
                  ResultSet rs = stmt.executeQuery("SELECT * FROM "+textField.getText());  
  
                  String registro = "";
  
                  while( rs.next() ) {
                      for(int i=1;i&lt;=rs.getMetaData().getColumnCount();i++){
                          registro = registro + "\t" + rs.getString(i);
                      }
                      registros_ta.append( registro +"\n");
                      registro = "";
                  }
  
                  registros_ta.append("\n");
  
                  con.close();
  
              } catch(Exception e) { 
                  System.out.println(e);
              }
  
          }
  
  
      }   
  }
  
  
  </code></pre>
  
  <p>The error showing in terminal is: <a href="https://i.stack.imgur.com/sHIWd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sHIWd.png" alt="enter image description here"></a></p>
  
  <p>How should you fix it? </p>