forked from LupusNobilis/java-org.hwo
118 lines
2.3 KiB
Java
118 lines
2.3 KiB
Java
package org.hwo;
|
|
|
|
import java.util.prefs.BackingStoreException;
|
|
import java.util.prefs.Preferences;
|
|
|
|
|
|
public class DBProfile
|
|
{
|
|
private Integer profileno;
|
|
private String bezeichnung;
|
|
private String hostname;
|
|
private String database;
|
|
private Integer port;
|
|
private String username;
|
|
private String password;
|
|
|
|
public DBProfile(Preferences pref,int profileno)
|
|
{
|
|
this.setProfileno(profileno);
|
|
load(pref);
|
|
}
|
|
|
|
public int getProfileno() {
|
|
return profileno;
|
|
}
|
|
|
|
public void load(Preferences pref)
|
|
{
|
|
Preferences prefs = pref.node("database").node(profileno.toString());
|
|
|
|
hostname = prefs.get("hostname", "localhost");
|
|
database = prefs.get("database", "hworganizer");
|
|
username = prefs.get("username", "");
|
|
password = prefs.get("password", "");
|
|
port = prefs.getInt("port", 5432);
|
|
bezeichnung = prefs.get("bezeichnung", "Profil " + profileno.toString());
|
|
}
|
|
|
|
public void save(Preferences pref)
|
|
{
|
|
Preferences prefs = pref.node("database").node(profileno.toString());
|
|
|
|
prefs.put("hostname", hostname);
|
|
prefs.put("database", database);
|
|
prefs.put("username", username);
|
|
prefs.put("password", password);
|
|
prefs.putInt("port", port);
|
|
prefs.put("bezeichnung", bezeichnung);
|
|
|
|
try
|
|
{
|
|
prefs.flush();
|
|
} catch (BackingStoreException bse)
|
|
{
|
|
System.err.println("Einstellungen konnten nicht gespeichert werden!");
|
|
System.err.println(bse.toString());
|
|
bse.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void setProfileno(int profileno) {
|
|
this.profileno = profileno;
|
|
}
|
|
|
|
public String getHostname() {
|
|
return hostname;
|
|
}
|
|
|
|
public void setHostname(String hostname) {
|
|
this.hostname = hostname;
|
|
}
|
|
|
|
public String getDatabase() {
|
|
return database;
|
|
}
|
|
|
|
public void setDatabase(String database) {
|
|
this.database = database;
|
|
}
|
|
|
|
public String getUsername() {
|
|
return username;
|
|
}
|
|
|
|
public void setUsername(String username) {
|
|
this.username = username;
|
|
}
|
|
|
|
public String getPassword() {
|
|
return password;
|
|
}
|
|
|
|
public void setPassword(String password) {
|
|
this.password = password;
|
|
}
|
|
|
|
public Integer getPort() {
|
|
return port;
|
|
}
|
|
|
|
public void setPort(Integer port) {
|
|
this.port = port;
|
|
}
|
|
|
|
public String getBezeichnung() {
|
|
return bezeichnung;
|
|
}
|
|
|
|
public void setBezeichnung(String bezeichnung) {
|
|
this.bezeichnung = bezeichnung;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return getBezeichnung();
|
|
}
|
|
|
|
} |