Overview
This guide will walk you through using MySQL SQL Editor for the first time. You’ll learn how to launch the application, connect to a MySQL database, browse tables, write queries, and view results.Before starting, make sure you’ve completed the Installation steps and have a running MySQL server with at least one non-system database.
Launch the Application
Start MySQL SQL Editor
From your project directory, run the application:On Windows:The login window titled “Conexión a MySQL” will appear with a clean interface styled in the application’s primary color (#0078D7).
Enter MySQL Credentials
In the login window, you’ll see several input fields:
-
Servidor — Select your MySQL server host:
localhost(if MySQL is running on your machine)127.0.0.1(loopback address)- Or a custom remote host (requires modification in
View.java)
-
Usuario — Enter your MySQL username (e.g.,
root,admin, or your custom user) - Contraseña — Enter the password for your MySQL user
Load Available Databases
Before connecting, click the “Actualizar” button next to the Base de datos dropdown.This triggers the After a few seconds, you should see a success message: “Bases de datos actualizadas correctamente”.
cargarBasesDatos() method in Controller.java, which:- Connects to the MySQL server using your credentials
- Executes
SHOW DATABASESto retrieve all available databases - Filters out system databases (
information_schema,mysql,performance_schema,sys) - Populates the dropdown with accessible databases
The application uses SwingWorker to perform database operations asynchronously, keeping the UI responsive during network calls.
Select a Database
From the Base de datos dropdown, select the database you want to work with.If you don’t have any databases yet, create one in MySQL first:
Connect to the Database
Click the “Conectar” button to establish a connection.The application will:Upon successful connection, you’ll see the main SQL Editor window.
- Validate that all required fields are filled
- Call
modelo.conectar()to establish a JDBC connection - Retrieve the list of tables in the selected database using
DatabaseMetaData - Hide the login window and display the SQL Editor view
Explore the SQL Editor Interface
The SQL Editor window (SqlEditorView) is divided into several key areas:Top Section: Connection Info & Controls
- Connection Status Field — Shows “Conectado a: [database_name]” indicating the active database
- Cambiar BD Button — Disconnect and return to the login screen to switch databases
Left Section: SQL Query Editor
- Editor SQL Panel — Large text area with Consolas monospace font for writing SQL queries
- Ejecutar Button (Primary blue button) — Executes the SQL query in the editor
- Limpiar Button — Clears the query editor, results table, and system messages
- Refrescar tablas Button — Refreshes the list of tables in the right panel
Right Section: Table Browser
- Tablas disponibles — A list showing all tables in the connected database
- Double-click functionality — Double-clicking a table name auto-generates a
SELECT * FROM [table] LIMIT 100query
Bottom Section: Results Display
- Resultados Panel — Table view displaying query results with columns and rows
- Mensaje del sistema Label — Shows status messages like “Consulta ejecutada correctamente” or error details
Execute Your First Query
Execute the Query
Click the “Ejecutar” button (primary blue button on the right side).The application will:
- Validate that the query is not empty
- Execute the query using
modelo.ejecutarConsulta() - Parse the
ResultSetand build aDefaultTableModel - Display results in the Resultados table
- Show “Consulta ejecutada correctamente” in the system message label
View Results
The results appear in the Resultados panel with:
- Column headers extracted from the ResultSetMetaData
- All rows returned by your query
- Organized in a clean table format with 22px row height
For large result sets, the table automatically adds a scrollbar. Results are displayed with zero grid spacing for a clean, modern look.
Try Different Query Types
MySQL SQL Editor supports all SQL statement types. Let’s explore common operations:INSERT Query
Add new data to your table:INSERT query, the application automatically:
- Executes the statement using
stmt.executeUpdate() - Extracts the table name from the query
- Re-queries the table with
SELECT * FROM users - Displays the updated table contents
UPDATE Query
Modify existing records:DELETE Query
Remove records from a table:CREATE TABLE Query
Define new table structures:Browse Tables with Quick Select
View Available Tables
The Tablas disponibles panel on the right shows all tables in your connected database.This list is populated by calling
modelo.obtenerTablasDeBaseDatos():Generate Query with Double-Click
Double-click any table name in the list.The application automatically generates and inserts this query into the editor:
The LIMIT 100 clause prevents accidentally loading massive datasets into the UI, keeping the application responsive.
Clear and Reset
To start fresh:- Click the “Limpiar” button
- This clears:
- The SQL query editor
- The results table
- Any system messages
Switch Databases
To connect to a different database:Confirm Disconnection
A confirmation dialog appears: “¿Desea desconectarse y cambiar de base de datos?”Click Yes to proceed.
Return to Login
The SQL Editor window closes, and you return to the login screen.The application calls
modelo.desconectar() to properly close the JDBC connection:Error Handling
The application provides clear error messages for common issues:Empty Query Error
If you click “Ejecutar” without writing a query, you’ll see:SQL Syntax Errors
If your query has syntax errors, the application displays:- An error dialog with the MySQL error message
- The system message label shows: “Error: [error details]“
Connection Issues
If the connection to MySQL is lost, error dialogs appear with detailed messages from the JDBC driver.Tips for Efficient Use
Use Double-Click
Double-click table names to instantly generate SELECT queries—saves typing and reduces errors
Limit Large Queries
Always use LIMIT clauses when querying large tables to keep the UI responsive
Refresh Tables
After CREATE TABLE or DROP TABLE operations, click “Refrescar tablas” to update the table list
Check System Messages
Watch the system message label for execution status and row counts
Next Steps
Now that you’ve mastered the basics, explore more advanced topics:User Guide
Learn advanced connection management and database operations
Architecture
Understand how the MVC pattern powers the application