{"id":22503125,"url":"https://github.com/afa-farkhod/login-load-data-swing-desktop-application","last_synced_at":"2026-04-28T01:33:16.358Z","repository":{"id":153819099,"uuid":"610529054","full_name":"afa-farkhod/Login-Load-Data-Swing-Desktop-Application","owner":"afa-farkhod","description":"This desktop application shows the login process and loading the data from database","archived":false,"fork":false,"pushed_at":"2023-07-02T00:45:10.000Z","size":205,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-30T05:41:07.692Z","etag":null,"topics":["desktop-application","java","jdbc","mysql","mysql-database","swing","windowbuilder"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afa-farkhod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-07T00:29:17.000Z","updated_at":"2024-04-03T18:30:55.000Z","dependencies_parsed_at":"2023-10-03T17:27:29.306Z","dependency_job_id":null,"html_url":"https://github.com/afa-farkhod/Login-Load-Data-Swing-Desktop-Application","commit_stats":null,"previous_names":["af4092/login-load-data","afa-farkhod/login-load-data-swing-desktop-application"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/afa-farkhod/Login-Load-Data-Swing-Desktop-Application","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogin-Load-Data-Swing-Desktop-Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogin-Load-Data-Swing-Desktop-Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogin-Load-Data-Swing-Desktop-Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogin-Load-Data-Swing-Desktop-Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afa-farkhod","download_url":"https://codeload.github.com/afa-farkhod/Login-Load-Data-Swing-Desktop-Application/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afa-farkhod%2FLogin-Load-Data-Swing-Desktop-Application/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32362781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["desktop-application","java","jdbc","mysql","mysql-database","swing","windowbuilder"],"created_at":"2024-12-06T23:29:18.173Z","updated_at":"2026-04-28T01:33:16.340Z","avatar_url":"https://github.com/afa-farkhod.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Login-Load-Data-Swing-Desktop-Application\nThis desktop application shows the login process and loading the data from database\n\n## [Java JDBC API](https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/)\n\n- The Java Database Connectivity (JDBC) API provides universal data access from the Java programming language. Using the JDBC API, you can access virtually any data source, from relational databases to spreadsheets and flat files. JDBC technology also provides a common base on which tools and alternate interfaces can be built.\n- The JDBC API is comprised of two packages:\n  - java.sql\n  - javax.sql\n\n## JDBC is the Java API for accessing relational database.\n\n- The Java API for developing Java database applications is called JDBC. JDBC is the trademarked name of a Java API that supports Java programs that access relational databases. JDBC is not an acronym, but it is often thought to stand for Java Database Connectivity. \n\n- JDBC provides Java programmers with a uniform interface for accessing and manipulating relational databases. Using the JDBC API, applications written in the Java programming language can execute SQL statements, retrieve results, present data in a user-friendly interface, and propagate changes back to the database. The JDBC API can also be used to interact with multiple data sources in a distributed, heterogeneous environment.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/af4092/Login-Load-Data/assets/24220136/95edfd62-ded5-4da3-9b41-afe332c6d5bb\" alt=\"Image\"\u003e\n\u003c/p\u003e\n\n- The JDBC API is a Java application program interface to generic SQL databases that enables Java developers to develop DBMS-independent Java applications using a uniform interface.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/af4092/Login-Load-Data/assets/24220136/a9e05456-954e-4c74-b9b2-d0e8d5864d8a\" alt=\"Image\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/af4092/Login-Load-Data/assets/24220136/644bc12b-8e94-4492-9d20-f320d263353d\" alt=\"Image\"\u003e\n\u003c/p\u003e\n\n--------------------\n\n## [Implementation](https://github.com/af4092/Login-Load-Data-Swing-Desktop-Application/tree/main/Login/src)\n\n- Demo Run, which shows the main Login view. In the UI User name and Password is entered, and if Username and Password matches window displays \"Login Successful\" message, otherwise it displays \"Wrong Password\" message:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/24220136/223287669-af34fd7d-7635-4454-b724-7d02d21e0c28.png\" alt=\"Image\"\u003e\n\u003c/p\u003e\n\n- After successful login, on the left side of the Window we can save new information with the following parameters: Id, Name, Country Code, District and Population to DB table (MySQL). With `Clear` button we can easily clear any data from the DB and `Logout` button logouts to the main window. `Exit` button exits from the application.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://user-images.githubusercontent.com/24220136/223287701-7dfd2f44-3732-4115-8960-800fd9f44e02.png\" alt=\"Image\"\u003e\n\u003c/p\u003e\n\n- `Login.java` code explanation:\n  \n  - Program imports necessary classes for `GUI components`, database connectivity, and image handling.\n\n  - The code declares a public class named Login that extends the JFrame class. It represents the login form window.\n\n  - The main method serves as the entry point of the program. It creates an instance of the Login class and makes it visible on the screen.\n\n  - The constructor of the Login class initializes the frame properties such as title, size, and layout. It creates a panel (`JPanel`) named contentPane and sets it as the content pane of the frame.\n\n  - Various GUI components are declared and initialized, including labels, text fields, buttons, and password fields. These components represent the elements of the login form.\n\n  - An action listener is added to the \"Login\" button (`btnLogin`). When the button is clicked, the code inside the actionPerformed method is executed, handling the login functionality.\n\n  - The code establishes a connection to a `MySQL` database using `JDBC`. It loads the MySQL driver, creates a connection, and a statement for executing SQL queries. It constructs a SQL query to check if the entered username and password match any records in the database. If a match is found, it displays a success message using JOptionPane.showMessageDialog(). Otherwise, it displays a \"Wrong password\" message.\n\n  - Image objects are created from image files to set icons for the login button and a label in the GUI.\n\n- `EmployeeInfo.java` code explanation:\n\n  - The code imports necessary classes for GUI components, database connectivity, and table handling.\n\n  - The main method serves as the entry point of the program. It creates an instance of the EmployeeInfo class and makes it visible on the screen.\n\n  - The constructor of the EmployeeInfo class initializes the frame properties such as size and layout. It creates a panel (JPanel) named contentPane and sets it as the content pane of the frame.\n\n  - Various GUI components are declared and initialized, including labels, buttons, a table, and text fields. These components represent the elements of the employee information management system.\n\n  - An action listener is added to the `Logout` button (btnLogout). When the button is clicked, the code inside the actionPerformed method is executed, handling the logout functionality. It disposes of the current frame and creates a new instance of the Login class to display the login form.\n\n  - The code creates a scroll pane and a table to display the employee information. It also creates buttons for loading data, clearing the table, saving data, and exiting the application.\n\n  - When the `Load Data` button (btnLoad) is clicked, the code establishes a connection to a MySQL database using JDBC. It executes a SELECT query to fetch data from the \"city\" table and populates the table component with the retrieved data using a DefaultTableModel.\n\n  - When the `Save` button (btnSave) is clicked, the code establishes a connection to the database and prepares an INSERT query to add a new employee record to the \"city\" table. The text field values entered by the user are used as parameters for the query.\n\n  - The `Clear` button (btnClear) clears the table by setting a new empty DefaultTableModel.\n\n  - The `Exit` button (btnExit) terminates the application by calling `System.exit()`.\n\n- Following is a complete example that demonstrates `JDBC` (Java Database Connectivity) connecting to a database, executing a simple query, and processing the query result with JDBC. The program connects to a local MySQL database and displays the students whose last name is Smith.\n\n  - The code imports the necessary classes for JDBC and SQL operations.\n\n  - The main method serves as the entry point of the program.\n\n  - The code loads the JDBC driver by calling Class.forName(`com.mysql.jdbc.Driver`). This step is necessary to load the driver class for the specific database you are connecting to. In this case, it loads the MySQL JDBC driver.\n\n  - It establishes a connection to a MySQL database using DriverManager.getConnection. The connection URL specifies the database location (`jdbc:mysql://localhost/javabook`), the username (scott), and the password (tiger).\n\n  - After successfully connecting to the database, it prints \"Database connected\" to the console.\n\n  - A Statement object is created using the connection. The statement is used to execute SQL queries on the database.\n\n  - The code executes a SELECT query using the executeQuery method of the statement. The query retrieves the columns firstName, mi, and lastName from the Student table where the lastName is equal to \"Smith\".\n\n  - The ResultSet object holds the result of the executed query. It represents a set of rows retrieved from the database.\n\n  - The code iterates through the result set using a while loop and retrieves the values of the columns for each row. It then prints the student names (values of firstName, mi, and lastName) to the console.\n\n  - Finally, the code closes the database connection using `connection.close()`.\n    \n```\n import java.sql.*;\n \n public class SimpleJdbc {\n    public static void main(String[] args) throws SQLException, ClassNotFoundException {\n  // Load the JDBC driver\n  Class.forName(\"com.mysql.jdbc.Driver\");\n  System.out.println(\"Driver loaded\");\n \n // Connect to a database\n Connection connection = DriverManager.getConnection\n (\"jdbc:mysql://localhost/javabook\" , \"scott\", \"tiger\");\n System.out.println(\"Database connected\");\n\n// Create a statement\nStatement statement = connection.createStatement();\n\n// Execute a statement\nResultSet resultSet = statement.executeQuery\n(\"select firstName, mi, lastName from Student where lastName \" + \" = 'Smith'\");\n\n// Iterate through the result and print the student names\nwhile (resultSet.next())\n  System.out.println(resultSet.getString(1) + \"\\t\" + resultSet.getString(2) + \"\\t\" + resultSet.getString(3));\n\n// Close the connection\n connection.close();\n      }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafa-farkhod%2Flogin-load-data-swing-desktop-application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafa-farkhod%2Flogin-load-data-swing-desktop-application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafa-farkhod%2Flogin-load-data-swing-desktop-application/lists"}