This is a simple Java application that demonstrates how to connect to a MySQL database using JDBC. The application connects to a local MySQL database, performs database operations (such as querying or updating), and handles SQL exceptions.
- JDBC Connection: The application establishes a connection to a MySQL database using the JDBC driver.
- SQL Queries: Interacts with a MySQL database, potentially allowing data manipulation and retrieval.
- Exception Handling: Catches and handles SQL and ClassNotFound exceptions.
- Java Development Kit (JDK): Version 8 or above.
- MySQL: Ensure MySQL is installed and running locally.
- JDBC Driver: The MySQL JDBC driver (
com.mysql.jdbc.Driver) must be included in the project. - Database Setup: A MySQL database with the schema
v_projectand user credentials as defined in the code.
-
Clone the repository:
git clone https://github.com/sarveshdesai/java-mysql-app.git
-
Install MySQL and create the required database:
CREATE DATABASE v_project;
-
Modify Database Credentials: Update the following line in the
App.javafile with your MySQL username and password:Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/v_project", "root", "1234");
-
Compile the Java program:
javac App.java
-
Run the application:
java App
The main steps in the program include:
-
Loading the JDBC driver:
Class.forName("com.mysql.jdbc.Driver");
-
Connecting to the database:
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/v_project", "root", "1234");
-
Handling Exceptions: Proper handling for
ClassNotFoundExceptionandSQLExceptionis implemented:catch (ClassNotFoundException e) { e.printStackTrace(); }
Contributions to improve the application or add new features are welcome. To contribute:
- Fork the repository.
- Create a new branch for your feature:
git checkout -b feature/YourFeature
- Make your changes and commit:
git commit -m 'Add feature' - Push to your fork:
git push origin feature/YourFeature
- Submit a pull request for review.
For any inquiries or issues, please reach out to the project maintainers at sarveshdesaigp@gmail.com.