A Java desktop application for fetching, storing, and displaying weather data for Kerala's districts. This app uses the Open-Meteo API and a MySQL database to display both current and past weather conditions for each district.
- Real-Time Data: Fetches real-time weather data for Kerala's districts.
- Historical Tracking: Stores weather data in a SQL database for history tracking.
- District Search: Quickly find weather data by district name.
- Current Metrics: View temperature, humidity, wind speed, and rainfall.
- Weather History: Explore past weather trends in a clean tabular format.
Before you get started, ensure you have the following installed:
- Java Development Kit (JDK): Version 11 or higher.
- MySQL Database: Installed and configured locally.
- Visual Studio Code: Recommended IDE, but feel free to use any Java-compatible IDE.
- Dependencies:
org.json.JSONObject
for parsing JSON from the weather API.javax.swing
for creating a user-friendly graphical interface.- MySQL Connector/J: Essential for database connectivity (included in the
lib
folder).
git clone https://github.com/your-username/KeralaWeatherApp.git
cd KeralaWeatherApp
-
Launch MySQL via command line or a GUI tool like MySQL Workbench.
-
Create the
weather_db
database:CREATE DATABASE weather_db; USE weather_db;
-
Create the
weather_data
table:CREATE TABLE weather_data ( id INT PRIMARY KEY AUTO_INCREMENT, district VARCHAR(50), temperature DOUBLE, wind_speed DOUBLE, humidity DOUBLE, rain DOUBLE, timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
-
Open
src/KeralaWeatherApp.java
. -
Update your database credentials in the
connectToDatabase
method:connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/weather_db", "your_username", "your_password");
- No sign up required for Open-Meteo or use another weather API that supports latitude-longitude data.
- Update the
apiUrl
infetchWeatherData
with your API endpoint and key, if necessary.
Execute the following commands to get your app running:
javac -cp ".:lib/*" src/KeralaWeatherApp.java
java -cp ".:lib/*:src" KeralaWeatherApp
- Fetch All Districts' Weather: Click βFetch Weather for All Districtsβ to see real-time data.
- Search by District: Enter the district name and hit βSearch Districtβ to retrieve weather info.
- View Weather History: Click βShow Weather Historyβ for past weather data.
- Refresh Data: Click βRefreshβ to update the weather for your selected district.
KeralaWeatherApp/
βββ src/
β βββ KeralaWeatherApp.java # Main application code
βββ lib/ # Libraries (e.g., MySQL connector)
βββ elements/ # Weather icons (sunny, cloudy, rainy)
βββ README.md # Project README
- JDK: For running Java applications.
- MySQL JDBC Driver: Place the MySQL JDBC driver (e.g.,
mysql-connector-java
) in thelib
folder for database access. - org.json: For parsing JSON responses from the API.
- Enable automatic data refresh at defined intervals.
- Improve the user interface with weather icons and trends.
- Add advanced search and filter options for historical data.
This project is licensed under the MIT License. See the LICENSE file for details.