Today, my trainer, Muthu Sir, organized a hackathon-like event, and it was an amazing learning experience for me. During the session, I learned how to create a CSV file using Java. I practiced writing structured data into the file, like IDs, names, ages, and departments, which was really interesting.
After that, I learned how to read and write CSV files in Java. Using BufferedReader, I could read each line, split the values, and even skip the header or empty lines. It gave me a clear understanding of how data can be handled programmatically.
The most challenging part for me was Java Database Connectivity (JDBC). I initially faced several difficulties while trying to store CSV data into a PostgreSQL database. I struggled with connecting to the database, writing proper SQL queries, and handling errors like duplicate primary keys.
With step-by-step guidance from ChatGPT, I finally fixed all the errors. I learned to use batch inserts for efficiency, and ON CONFLICT statements in PostgreSQL to handle duplicates. Now, my Java program can read CSV data, print it in a table format, and insert it safely into the database.
Overall, this hackathon helped me practically apply Java skills, understand file handling, and learn how to integrate Java with databases. It was a proud moment when I successfully completed the task, and I feel more confident about working with Java and JDBC in real-world scenarios.
Top comments (0)