提交 a4bf608a authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 176: the JdbcDataSource now also supports a 'description' property.

上级 1d018117
......@@ -18,7 +18,10 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>The Shell tool threw a IndexOutOfBoundsException after 20 statements.
<ul><li>CREATE ALIAS ... AS: Compilation was incorrect if the source code contained
characters that are not supported by the default file encoding.
</li><li>Issue 176: the JdbcDataSource now also supports a 'description' property.
</li><li>The Shell tool threw a IndexOutOfBoundsException after 20 statements.
</li><li>When using the small version of H2 ('jarClient'), the first call to
Connection.createBlob (or similar) could throw a ClassNotFoundException
because the file org.h2.store.fs.FileSystemZip is not included. This missing class
......
......@@ -72,6 +72,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
private String userName = "";
private char[] passwordChars = new char[0];
private String url = "";
private String description;
static {
org.h2.Driver.load();
......@@ -258,6 +259,26 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
this.userName = user;
}
/**
* Get the current description.
*
* @return the description
*/
public String getDescription() {
debugCodeCall("getDescription");
return description;
}
/**
* Set the description.
*
* @param description the new description
*/
public void setDescription(String description) {
debugCodeCall("getDescription", description);
this.description = description;
}
/**
* Get a new reference for this object, using the current settings.
*
......@@ -272,6 +293,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
ref.add(new StringRefAddr("user", userName));
ref.add(new StringRefAddr("password", convertToString(passwordChars)));
ref.add(new StringRefAddr("loginTimeout", String.valueOf(loginTimeout)));
ref.add(new StringRefAddr("description", description));
return ref;
}
//## Java 1.4 end ##
......
......@@ -68,6 +68,7 @@ implements ObjectFactory
dataSource.setURL((String) ref.get("url").getContent());
dataSource.setUser((String) ref.get("user").getContent());
dataSource.setPassword((String) ref.get("password").getContent());
dataSource.setDescription((String) ref.get("description").getContent());
String s = (String) ref.get("loginTimeout").getContent();
dataSource.setLoginTimeout(Integer.parseInt(s));
return dataSource;
......
......@@ -79,6 +79,7 @@ public class TestDataSource extends TestBase {
ref.add(new StringRefAddr("user", "u"));
ref.add(new StringRefAddr("password", "p"));
ref.add(new StringRefAddr("loginTimeout", "1"));
ref.add(new StringRefAddr("description", "test"));
JdbcDataSource ds = (JdbcDataSource) factory.getObjectInstance(ref, null, null, null);
assertEquals(1, ds.getLoginTimeout());
assertEquals("jdbc:h2:mem:", ds.getURL());
......@@ -90,6 +91,7 @@ public class TestDataSource extends TestBase {
assertEquals(ref.get("user").getContent().toString(), ref2.get("user").getContent().toString());
assertEquals(ref.get("password").getContent().toString(), ref2.get("password").getContent().toString());
assertEquals(ref.get("loginTimeout").getContent().toString(), ref2.get("loginTimeout").getContent().toString());
assertEquals(ref.get("description").getContent().toString(), ref2.get("description").getContent().toString());
ds.setPasswordChars("abc".toCharArray());
assertEquals("abc", ds.getPassword());
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论