Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
764 B
3
Indexable
Never
//Pravljenje konfiguracionog fajla
String nazivBaze=txtNazivBaze.getText();
String username=txtUsername.getText();
String password=String.valueOf(txtPassword.getPassword();

if(nazivBaze.isEmpty())
{
    //
    retutn;
}

File appConfig=new File("dbconfig.properties");

try (Writer inputStream=new FileWriter(appConfig)) {

    FileInputStream propsInput=new FileInputStream("dbconfig.properties");
    
    Properties prop=new Properties();
    
    prop.load(propsInput);

    props.setProperty("url", "jdbc:mysql://localhost:3306/" + nazivBaze);
    props.setProperty("username", username);
    props.setProperty("password", password);

    prop.store(inputStream, null);
    
    //
    this.dispose();

} catch (IOException ex) {
    ex.printStacktTrace();
}
Leave a Comment