T
timasmith
I have a regular class, implements serializable, private variables with
getter/setter.
Nothing prints - despite being populated - ahhh driving me nuts
The plot thickens when I use hardcoded strings to set the properties
i.e. instead of cp.getUserName() I used "username"
If I put println in the method it proves there is data...
public void saveConnection(ConnProperty cp)
ConnProperty conn = new ConnProperty();
conn.setUsername(cp.getUserName());
conn.setDriverClass(cp.getDriver());
conn.setPassword(cp.getPassword);
conn.setUrl(cp.getUrl());
ConnectionList.setConfigFileName("test.xml");
ConnectionList list =new ConnectionList();
list.add(conn);
SerializeUtility.serializeXML(new File(filename),
list.elements());
public static void serializeXML(File file, Enumeration e1) throws
IOException {
XMLEncoder encoder = null;
try
{
encoder = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream(file)));
while (e1.hasMoreElements()) {
encoder.writeObject(e1.nextElement());
}
} catch (Exception ex) {
Debug.LogException("SerializeUtility", ex);
}
finally
{
if (encoder != null) {
encoder.close();
}
}
}
package com.osframework.datalibrary.common;
import java.io.Serializable;
public class ConnProperty implements Serializable {
private static final long serialVersionUID = 0L;
/**
* False for MS Access, True for almost all other databases.
*/
private boolean connectToURL = true;
/**
* URL to connect to remote database (or MS Access local file)
* e.g. jdbcracle:thinlocalhost:1521rod1
*/
private String url = "jdbcdbcRIVER={Microsoft Access Driver
(*.mdb)};DBQ=osrmt.mdb";
/**
* Driver implementation - class name - must be in the classpath!
*/
private String driverClass = "sun.jdbc.odbc.JdbcOdbcDriver";
/**
* Database connections of the same environment name
* will access URLs in this order
*/
private int accessSequence = 0;
private String username = "admin";
private String password = "";
public int getAccessSequence() {
return accessSequence;
}
public void setAccessSequence(int accessSequence) {
this.accessSequence = accessSequence;
}
public boolean isConnectToURL() {
return connectToURL;
}
public void setConnectToURL(boolean connectToURL) {
this.connectToURL = connectToURL;
}
public String getDriverClass() {
return driverClass;
}
public void setDriverClass(String driverClass) {
this.driverClass = driverClass;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}
getter/setter.
Nothing prints - despite being populated - ahhh driving me nuts
The plot thickens when I use hardcoded strings to set the properties
i.e. instead of cp.getUserName() I used "username"
If I put println in the method it proves there is data...
public void saveConnection(ConnProperty cp)
ConnProperty conn = new ConnProperty();
conn.setUsername(cp.getUserName());
conn.setDriverClass(cp.getDriver());
conn.setPassword(cp.getPassword);
conn.setUrl(cp.getUrl());
ConnectionList.setConfigFileName("test.xml");
ConnectionList list =new ConnectionList();
list.add(conn);
SerializeUtility.serializeXML(new File(filename),
list.elements());
public static void serializeXML(File file, Enumeration e1) throws
IOException {
XMLEncoder encoder = null;
try
{
encoder = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream(file)));
while (e1.hasMoreElements()) {
encoder.writeObject(e1.nextElement());
}
} catch (Exception ex) {
Debug.LogException("SerializeUtility", ex);
}
finally
{
if (encoder != null) {
encoder.close();
}
}
}
package com.osframework.datalibrary.common;
import java.io.Serializable;
public class ConnProperty implements Serializable {
private static final long serialVersionUID = 0L;
/**
* False for MS Access, True for almost all other databases.
*/
private boolean connectToURL = true;
/**
* URL to connect to remote database (or MS Access local file)
* e.g. jdbcracle:thinlocalhost:1521rod1
*/
private String url = "jdbcdbcRIVER={Microsoft Access Driver
(*.mdb)};DBQ=osrmt.mdb";
/**
* Driver implementation - class name - must be in the classpath!
*/
private String driverClass = "sun.jdbc.odbc.JdbcOdbcDriver";
/**
* Database connections of the same environment name
* will access URLs in this order
*/
private int accessSequence = 0;
private String username = "admin";
private String password = "";
public int getAccessSequence() {
return accessSequence;
}
public void setAccessSequence(int accessSequence) {
this.accessSequence = accessSequence;
}
public boolean isConnectToURL() {
return connectToURL;
}
public void setConnectToURL(boolean connectToURL) {
this.connectToURL = connectToURL;
}
public String getDriverClass() {
return driverClass;
}
public void setDriverClass(String driverClass) {
this.driverClass = driverClass;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}