Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7644413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:40:57+00:00 2026-05-31T09:40:57+00:00

I have an assignment to create a java Swing application to do some stuff

  • 0

I have an assignment to create a java Swing application to do some stuff with a mysql database, I have planed to set the database connection properties in a .properties file. In that application user should be able to change the database properties through the application. The problem I’ve got is how to read and write a properties file through a swing application.

try {
            Properties prop = new Properties();
//reading properties
            FileInputStream in = new FileInputStream("conf/properties.xml");
            prop.loadFromXML(in);           
            System.out.println(prop.getProperty("driver"));
            in.close();

//Writing properties
FileOutputStream out = new FileOutputStream("conf/properties.xml");
prop.setProperty("username", "root");
prop.storeToXML(out, "rhym");
out.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

xml file..

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <comment>database configuration</comment>
    <entry key="driver">com.mysql.jdbc.Driver</entry>
    <entry key="ip">127.0.0.1</entry>
    <entry key="port">3306</entry>
    <entry key="database">ofm_mnu_jvs</entry>
    <entry key="username">user1</entry>
    <entry key="password">123789</entry>
</properties>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:40:59+00:00Added an answer on May 31, 2026 at 9:40 am

    Sounds like a program design exercise to me 🙂

    First, you need to write code that can handle persisting Java’s Properties object to disk, and retrieving Properties from disk. You can do this in many ways, but the best way is to use Java Properties syntax to save the contents of the Properties object to a user-editable text file. Your parser will just have to be smart enough to figure out how to read text from the file back into a Properties object, but it’s really not that hard to do.

    Once your program is able to correctly read/write Java Properties syntax from files, you can write your User Interface to deal only with Properties object instances. The UI could tell your persistence objects/methods to save the Properties instance each time the user changes a field or value.

    Bottom line is, it’s most important to figure out how to break up this program into smaller pieces. You could just as easily write a bunch of monolithic code that directly saves your properties files from ActionListeners in Swing, but none of that code would be reuseable. Break your code up into smaller objects (Parser object, UI object), then focus only on those smaller pieces, one at a time, until you can get them all working together to accomplish your goal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a short java assignment that I have been set. The
I currently have an assignment to create a filesystem in Java. I am trying
I have created a method in my java assignment to write into a file
I have an assignment to create a GUI using MATLAB GUIDE and am having
I have a small assignment in C. I am trying to create an array
I have a homework assignment where I need to take input from a file
I am completely new to Java and have an assignment coming up; with the
I have an assignment in which I need to create a function that tells
I'm new to Java and for a HW assignment, we had to create a
Wrote up a basic file handler for a Java Homework assignment, and when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.