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

--no commit message

--no commit message
上级 25f0a14a
...@@ -18,7 +18,12 @@ Change Log ...@@ -18,7 +18,12 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>H2 Console: Oracle system tables are no longer listed, improving performance. <ul><li>PG Server: new system property h2.pgClientEncoding to explicitly set the encoding
for clients that don't send the encoding (the default encoding is UTF-8).
Thanks a lot to Sergi Vladykin for the patch!
</li><li>PG Server: improved compatibility by using the type ids of the PostgreSQL driver.
Thanks a lot to Sergi Vladykin for the patch!
</li><li>H2 Console: Oracle system tables are no longer listed, improving performance.
</li><li>Result sets are now read-only except if the statement or prepared statement was created </li><li>Result sets are now read-only except if the statement or prepared statement was created
with the concurrency ResultSet.CONCUR_UPDATABLE. This change is required because the old behavior with the concurrency ResultSet.CONCUR_UPDATABLE. This change is required because the old behavior
(all result set are updatable) violated the JDBC spec. For backward compatibility, use the (all result set are updatable) violated the JDBC spec. For backward compatibility, use the
......
...@@ -428,7 +428,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -428,7 +428,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Oracle compatibility: support DECODE(x, ...). </li><li>Oracle compatibility: support DECODE(x, ...).
</li><li>Console: Start Browser: if ip number changed, try localhost instead. </li><li>Console: Start Browser: if ip number changed, try localhost instead.
</li><li>MVCC: compare concurrent update behavior with PostgreSQL and Oracle. </li><li>MVCC: compare concurrent update behavior with PostgreSQL and Oracle.
</li><li>HSQLDB compatibility: CREATE FUNCTION (maybe using a Function interface). </li><li>HSQLDB compatibility: CREATE FUNCTION (maybe using a Function interface).
</li><li>HSQLDB compatibility: support CALL "java.lang.Math.sqrt"(2.0) </li><li>HSQLDB compatibility: support CALL "java.lang.Math.sqrt"(2.0)
</li></ul> </li></ul>
......
...@@ -156,6 +156,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex { ...@@ -156,6 +156,7 @@ public class PageScanIndex extends BaseIndex implements RowIndex {
* *
* @param id the page id * @param id the page id
* @param leaf the leaf page * @param leaf the leaf page
* @param offset the offset in bytes
* @return the page * @return the page
*/ */
PageDataLeafOverflow getPageOverflow(int id, PageDataLeaf leaf, int offset) throws SQLException { PageDataLeafOverflow getPageOverflow(int id, PageDataLeaf leaf, int offset) throws SQLException {
......
...@@ -33,7 +33,7 @@ public class TestCluster extends TestBase { ...@@ -33,7 +33,7 @@ public class TestCluster extends TestBase {
} }
public void test() throws SQLException { public void test() throws SQLException {
if (config.memory || config.networked) { if (config.memory || config.networked || config.cipher != null) {
return; return;
} }
deleteFiles(); deleteFiles();
...@@ -43,7 +43,8 @@ public class TestCluster extends TestBase { ...@@ -43,7 +43,8 @@ public class TestCluster extends TestBase {
org.h2.Driver.load(); org.h2.Driver.load();
String urlNode1 = getURL("node1/test", true); String urlNode1 = getURL("node1/test", true);
String urlNode2 = getURL("node2/test", true); String urlNode2 = getURL("node2/test", true);
conn = DriverManager.getConnection(urlNode1, "sa", ""); String user = getUser(), password = getPassword();
conn = DriverManager.getConnection(urlNode1, user, password);
Statement stat; Statement stat;
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST"); stat.execute("DROP TABLE IF EXISTS TEST");
...@@ -59,7 +60,7 @@ public class TestCluster extends TestBase { ...@@ -59,7 +60,7 @@ public class TestCluster extends TestBase {
conn.close(); conn.close();
CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget", CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", "sa", "-serverList", urlNode2, "-user", user, "-password", password, "-serverList",
"localhost:9191,localhost:9192" }); "localhost:9191,localhost:9192" });
Server n1 = org.h2.tools.Server.createTcpServer( Server n1 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start(); new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start();
...@@ -67,47 +68,47 @@ public class TestCluster extends TestBase { ...@@ -67,47 +68,47 @@ public class TestCluster extends TestBase {
new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start(); new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start();
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", user, password);
fail("should not be able to connect in standalone mode"); fail("should not be able to connect in standalone mode");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", user, password);
fail("should not be able to connect in standalone mode"); fail("should not be able to connect in standalone mode");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
// test regular cluster connection // test regular cluster connection
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
check(conn, len); check(conn, len);
conn.close(); conn.close();
// test if only one server is available at the beginning // test if only one server is available at the beginning
n2.stop(); n2.stop();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
stat = conn.createStatement(); stat = conn.createStatement();
check(conn, len); check(conn, len);
conn.close(); conn.close();
// disable the cluster // disable the cluster
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", user, password);
conn.close(); conn.close();
n1.stop(); n1.stop();
// re-create the cluster // re-create the cluster
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node2", "-quiet" }); DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node2", "-quiet" });
CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget", CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", "sa", "-serverList", urlNode2, "-user", user, "-password", password, "-serverList",
"localhost:9191,localhost:9192" }); "localhost:9191,localhost:9192" });
n1 = org.h2.tools.Server.createTcpServer( n1 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start(); new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start();
n2 = org.h2.tools.Server.createTcpServer( n2 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start(); new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("CREATE TABLE BOTH(ID INT)"); stat.execute("CREATE TABLE BOTH(ID INT)");
...@@ -119,14 +120,14 @@ public class TestCluster extends TestBase { ...@@ -119,14 +120,14 @@ public class TestCluster extends TestBase {
n1 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }) n1 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" })
.start(); .start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", user, password);
check(conn, len); check(conn, len);
conn.close(); conn.close();
n1.stop(); n1.stop();
n2 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }) n2 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" })
.start(); .start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test;CLUSTER=''", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test;CLUSTER=''", user, password);
check(conn, len); check(conn, len);
conn.createStatement().execute("SELECT * FROM A"); conn.createStatement().execute("SELECT * FROM A");
conn.close(); conn.close();
......
...@@ -234,6 +234,10 @@ public class TestLinkedTable extends TestBase { ...@@ -234,6 +234,10 @@ public class TestLinkedTable extends TestBase {
} }
private void testLinkEmitUpdates() throws SQLException { private void testLinkEmitUpdates() throws SQLException {
if (config.memory || config.networked) {
return;
}
deleteDb("linked1"); deleteDb("linked1");
deleteDb("linked2"); deleteDb("linked2");
org.h2.Driver.load(); org.h2.Driver.load();
...@@ -241,16 +245,16 @@ public class TestLinkedTable extends TestBase { ...@@ -241,16 +245,16 @@ public class TestLinkedTable extends TestBase {
String url1 = getURL("linked1", true); String url1 = getURL("linked1", true);
String url2 = getURL("linked2", true); String url2 = getURL("linked2", true);
Connection conn = DriverManager.getConnection(url1, "sa1", "abc"); Connection conn = DriverManager.getConnection(url1, "sa1", "abc abc");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
Connection conn2 = DriverManager.getConnection(url2, "sa2", "def"); Connection conn2 = DriverManager.getConnection(url2, "sa2", "def def");
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
String link = "CREATE LINKED TABLE TEST_LINK_U('', '" + url1 String link = "CREATE LINKED TABLE TEST_LINK_U('', '" + url1
+ "', 'sa1', 'abc', 'TEST') EMIT UPDATES"; + "', 'sa1', 'abc abc', 'TEST') EMIT UPDATES";
stat2.execute(link); stat2.execute(link);
link = "CREATE LINKED TABLE TEST_LINK_DI('', '" + url1 + "', 'sa1', 'abc', 'TEST')"; link = "CREATE LINKED TABLE TEST_LINK_DI('', '" + url1 + "', 'sa1', 'abc abc', 'TEST')";
stat2.execute(link); stat2.execute(link);
stat2.executeUpdate("INSERT INTO TEST_LINK_U VALUES(1, 'Hello')"); stat2.executeUpdate("INSERT INTO TEST_LINK_U VALUES(1, 'Hello')");
stat2.executeUpdate("INSERT INTO TEST_LINK_DI VALUES(2, 'World')"); stat2.executeUpdate("INSERT INTO TEST_LINK_DI VALUES(2, 'World')");
...@@ -296,19 +300,23 @@ public class TestLinkedTable extends TestBase { ...@@ -296,19 +300,23 @@ public class TestLinkedTable extends TestBase {
} }
private void testLinkSchema() throws SQLException { private void testLinkSchema() throws SQLException {
if (config.memory || config.networked) {
return;
}
deleteDb("linked1"); deleteDb("linked1");
deleteDb("linked2"); deleteDb("linked2");
org.h2.Driver.load(); org.h2.Driver.load();
String url1 = getURL("linked1", true); String url1 = getURL("linked1", true);
String url2 = getURL("linked2", true); String url2 = getURL("linked2", true);
Connection conn = DriverManager.getConnection(url1, "sa1", "abc"); Connection conn = DriverManager.getConnection(url1, "sa1", "abc abc");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST1(ID INT PRIMARY KEY)"); stat.execute("CREATE TABLE TEST1(ID INT PRIMARY KEY)");
Connection conn2 = DriverManager.getConnection(url2, "sa2", "def"); Connection conn2 = DriverManager.getConnection(url2, "sa2", "def def");
Statement stat2 = conn2.createStatement(); Statement stat2 = conn2.createStatement();
String link = "CALL LINK_SCHEMA('LINKED', '', '" + url1 + "', 'sa1', 'abc', 'PUBLIC')"; String link = "CALL LINK_SCHEMA('LINKED', '', '" + url1 + "', 'sa1', 'abc abc', 'PUBLIC')";
stat2.execute(link); stat2.execute(link);
stat2.executeQuery("SELECT * FROM LINKED.TEST1"); stat2.executeQuery("SELECT * FROM LINKED.TEST1");
...@@ -322,6 +330,10 @@ public class TestLinkedTable extends TestBase { ...@@ -322,6 +330,10 @@ public class TestLinkedTable extends TestBase {
} }
private void testLinkTable() throws SQLException { private void testLinkTable() throws SQLException {
if (config.memory || config.networked) {
return;
}
deleteDb("linked1"); deleteDb("linked1");
deleteDb("linked2"); deleteDb("linked2");
org.h2.Driver.load(); org.h2.Driver.load();
...@@ -329,7 +341,7 @@ public class TestLinkedTable extends TestBase { ...@@ -329,7 +341,7 @@ public class TestLinkedTable extends TestBase {
String url1 = getURL("linked1", true); String url1 = getURL("linked1", true);
String url2 = getURL("linked2", true); String url2 = getURL("linked2", true);
Connection conn = DriverManager.getConnection(url1, "sa1", "abc"); Connection conn = DriverManager.getConnection(url1, "sa1", "abc abc");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TEMP TABLE TEST_TEMP(ID INT PRIMARY KEY)"); stat.execute("CREATE TEMP TABLE TEST_TEMP(ID INT PRIMARY KEY)");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(200), XT TINYINT, XD DECIMAL(10,2), XTS TIMESTAMP, XBY BINARY(255), XBO BIT, XSM SMALLINT, XBI BIGINT, XBL BLOB, XDA DATE, XTI TIME, XCL CLOB, XDO DOUBLE)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(200), XT TINYINT, XD DECIMAL(10,2), XTS TIMESTAMP, XBY BINARY(255), XBO BIT, XSM SMALLINT, XBI BIGINT, XBL BLOB, XDA DATE, XTI TIME, XCL CLOB, XDO DOUBLE)");
...@@ -342,7 +354,7 @@ public class TestLinkedTable extends TestBase { ...@@ -342,7 +354,7 @@ public class TestLinkedTable extends TestBase {
stat.execute("SELECT * FROM TEST_TEMP"); stat.execute("SELECT * FROM TEST_TEMP");
conn.close(); conn.close();
conn = DriverManager.getConnection(url1, "sa1", "abc"); conn = DriverManager.getConnection(url1, "sa1", "abc abc");
stat = conn.createStatement(); stat = conn.createStatement();
testRow(stat, "TEST"); testRow(stat, "TEST");
try { try {
...@@ -353,12 +365,12 @@ public class TestLinkedTable extends TestBase { ...@@ -353,12 +365,12 @@ public class TestLinkedTable extends TestBase {
} }
conn.close(); conn.close();
conn = DriverManager.getConnection(url2, "sa2", "def"); conn = DriverManager.getConnection(url2, "sa2", "def def");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("CREATE LINKED TABLE IF NOT EXISTS LINK_TEST('org.h2.Driver', '" + url1 stat.execute("CREATE LINKED TABLE IF NOT EXISTS LINK_TEST('org.h2.Driver', '" + url1
+ "', 'sa1', 'abc', 'TEST')"); + "', 'sa1', 'abc abc', 'TEST')");
stat.execute("CREATE LINKED TABLE IF NOT EXISTS LINK_TEST('org.h2.Driver', '" + url1 stat.execute("CREATE LINKED TABLE IF NOT EXISTS LINK_TEST('org.h2.Driver', '" + url1
+ "', 'sa1', 'abc', 'TEST')"); + "', 'sa1', 'abc abc', 'TEST')");
testRow(stat, "LINK_TEST"); testRow(stat, "LINK_TEST");
ResultSet rs = stat.executeQuery("SELECT * FROM LINK_TEST"); ResultSet rs = stat.executeQuery("SELECT * FROM LINK_TEST");
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
...@@ -366,7 +378,7 @@ public class TestLinkedTable extends TestBase { ...@@ -366,7 +378,7 @@ public class TestLinkedTable extends TestBase {
assertEquals(200, meta.getPrecision(2)); assertEquals(200, meta.getPrecision(2));
conn.close(); conn.close();
conn = DriverManager.getConnection(url2, "sa2", "def"); conn = DriverManager.getConnection(url2, "sa2", "def def");
stat = conn.createStatement(); stat = conn.createStatement();
stat.execute("INSERT INTO LINK_TEST VALUES(3, 'Link Test', 30, 100.05, '2005-12-31 12:34:56.789', X'FFEECC33', FALSE, 1, -1234567890123456789, X'4455FF', DATE '9999-12-31', TIME '23:59:59', 'George', -2.5)"); stat.execute("INSERT INTO LINK_TEST VALUES(3, 'Link Test', 30, 100.05, '2005-12-31 12:34:56.789', X'FFEECC33', FALSE, 1, -1234567890123456789, X'4455FF', DATE '9999-12-31', TIME '23:59:59', 'George', -2.5)");
...@@ -412,7 +424,7 @@ public class TestLinkedTable extends TestBase { ...@@ -412,7 +424,7 @@ public class TestLinkedTable extends TestBase {
stat.execute("DROP TABLE LINK_TEST"); stat.execute("DROP TABLE LINK_TEST");
stat.execute("CREATE LINKED TABLE LINK_TEST('org.h2.Driver', '" + url1 stat.execute("CREATE LINKED TABLE LINK_TEST('org.h2.Driver', '" + url1
+ "', 'sa1', 'abc', '(SELECT COUNT(*) FROM TEST)')"); + "', 'sa1', 'abc abc', '(SELECT COUNT(*) FROM TEST)')");
rs = stat.executeQuery("SELECT * FROM LINK_TEST"); rs = stat.executeQuery("SELECT * FROM LINK_TEST");
rs.next(); rs.next();
assertEquals(rs.getInt(1), 3); assertEquals(rs.getInt(1), 3);
......
...@@ -60,6 +60,10 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -60,6 +60,10 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
} }
private void testBackup() throws SQLException { private void testBackup() throws SQLException {
if (config.memory || config.logMode == 0) {
return;
}
deleteDb("openClose"); deleteDb("openClose");
String url = getURL("openClose", true); String url = getURL("openClose", true);
org.h2.Driver.load(); org.h2.Driver.load();
...@@ -82,10 +86,15 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -82,10 +86,15 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
} }
private void testReconnectFast() throws SQLException { private void testReconnectFast() throws SQLException {
if (config.memory) {
return;
}
deleteDb("openClose"); deleteDb("openClose");
String user = getUser(), password = getPassword();
String url = getURL("openClose;DATABASE_EVENT_LISTENER='" + TestOpenClose.class.getName() String url = getURL("openClose;DATABASE_EVENT_LISTENER='" + TestOpenClose.class.getName()
+ "'", true); + "'", true);
Connection conn = DriverManager.getConnection(url, "sa", "sa"); Connection conn = DriverManager.getConnection(url, user, password);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
try { try {
stat.execute("CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR)"); stat.execute("CREATE TABLE TEST(ID IDENTITY, NAME VARCHAR)");
...@@ -97,7 +106,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -97,7 +106,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
} }
stat.close(); stat.close();
conn.close(); conn.close();
conn = DriverManager.getConnection(url, "sa", "sa"); conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement(); stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM DUAL"); ResultSet rs = stat.executeQuery("SELECT * FROM DUAL");
if (rs.next()) { if (rs.next()) {
...@@ -106,7 +115,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -106,7 +115,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
rs.close(); rs.close();
stat.close(); stat.close();
conn.close(); conn.close();
conn = DriverManager.getConnection(url, "sa", "sa"); conn = DriverManager.getConnection(url, user, password);
stat = conn.createStatement(); stat = conn.createStatement();
// stat.execute("SET DB_CLOSE_DELAY 0"); // stat.execute("SET DB_CLOSE_DELAY 0");
stat.executeUpdate("SHUTDOWN"); stat.executeUpdate("SHUTDOWN");
...@@ -115,10 +124,15 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -115,10 +124,15 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
} }
private void testCase() throws Exception { private void testCase() throws Exception {
if (config.memory) {
return;
}
org.h2.Driver.load(); org.h2.Driver.load();
deleteDb("openClose"); deleteDb("openClose");
final String url = getURL("openClose;FILE_LOCK=NO", true); final String url = getURL("openClose;FILE_LOCK=NO", true);
Connection conn = DriverManager.getConnection(url, "sa", ""); final String user = getUser(), password = getPassword();
Connection conn = DriverManager.getConnection(url, user, password);
conn.createStatement().execute("drop table employee if exists"); conn.createStatement().execute("drop table employee if exists");
conn.createStatement().execute("create table employee(id int primary key, name varchar, salary int)"); conn.createStatement().execute("create table employee(id int primary key, name varchar, salary int)");
conn.close(); conn.close();
...@@ -128,7 +142,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -128,7 +142,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
threads[i] = new Thread() { threads[i] = new Thread() {
public void run() { public void run() {
try { try {
Connection conn = DriverManager.getConnection(url, "sa", ""); Connection conn = DriverManager.getConnection(url, user, password);
PreparedStatement prep = conn.prepareStatement("insert into employee values(?, ?, 0)"); PreparedStatement prep = conn.prepareStatement("insert into employee values(?, ?, 0)");
int id = getNextId(); int id = getNextId();
prep.setInt(1, id); prep.setInt(1, id);
...@@ -148,7 +162,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener { ...@@ -148,7 +162,7 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
threads[i].join(); threads[i].join();
} }
conn = DriverManager.getConnection(url, "sa", ""); conn = DriverManager.getConnection(url, user, password);
ResultSet rs = conn.createStatement().executeQuery("select count(*) from employee"); ResultSet rs = conn.createStatement().executeQuery("select count(*) from employee");
rs.next(); rs.next();
assertEquals(rs.getInt(1), len); assertEquals(rs.getInt(1), len);
......
...@@ -58,6 +58,8 @@ public class TestDataSource extends TestBase { ...@@ -58,6 +58,8 @@ public class TestDataSource extends TestBase {
deleteDb("dataSource"); deleteDb("dataSource");
JdbcDataSource ds = new JdbcDataSource(); JdbcDataSource ds = new JdbcDataSource();
ds.setURL(getURL("dataSource", true)); ds.setURL(getURL("dataSource", true));
ds.setUser(getUser());
ds.setPassword(getPassword());
XAConnection xaConn = ds.getXAConnection(); XAConnection xaConn = ds.getXAConnection();
xaConn.addConnectionEventListener(new ConnectionEventListener() { xaConn.addConnectionEventListener(new ConnectionEventListener() {
public void connectionClosed(ConnectionEvent event) { public void connectionClosed(ConnectionEvent event) {
...@@ -82,7 +84,8 @@ public class TestDataSource extends TestBase { ...@@ -82,7 +84,8 @@ public class TestDataSource extends TestBase {
deleteDb("dataSource"); deleteDb("dataSource");
JdbcDataSource ds = new JdbcDataSource(); JdbcDataSource ds = new JdbcDataSource();
ds.setURL(getURL("dataSource", true)); ds.setURL(getURL("dataSource", true));
ds.setUser("sa"); ds.setUser(getUser());
ds.setPassword(getPassword());
Connection conn = ds.getConnection(); Connection conn = ds.getConnection();
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("SELECT * FROM DUAL"); stat.execute("SELECT * FROM DUAL");
......
...@@ -38,12 +38,12 @@ public class TestXASimple extends TestBase { ...@@ -38,12 +38,12 @@ public class TestXASimple extends TestBase {
// context.rebind(USER_TRANSACTION_JNDI_NAME, j.getUserTransaction()); // context.rebind(USER_TRANSACTION_JNDI_NAME, j.getUserTransaction());
JdbcDataSource ds1 = new JdbcDataSource(); JdbcDataSource ds1 = new JdbcDataSource();
ds1.setPassword(""); ds1.setPassword(getPassword());
ds1.setUser("sa"); ds1.setUser("sa");
ds1.setURL(getURL("xaSimple1", true)); ds1.setURL(getURL("xaSimple1", true));
JdbcDataSource ds2 = new JdbcDataSource(); JdbcDataSource ds2 = new JdbcDataSource();
ds2.setPassword(""); ds2.setPassword(getPassword());
ds2.setUser("sa"); ds2.setUser("sa");
ds2.setURL(getURL("xaSimple2", true)); ds2.setURL(getURL("xaSimple2", true));
......
...@@ -591,4 +591,5 @@ relocating smtps smtp osde joist catching guesses delimiters shortlist sheet ...@@ -591,4 +591,5 @@ relocating smtps smtp osde joist catching guesses delimiters shortlist sheet
rowspan cheat partitioning datepart dreamsource toussi locates fred rowspan cheat partitioning datepart dreamsource toussi locates fred
longnvarchar collate localdb nan bootclasspath bcp retrotranslator iterable longnvarchar collate localdb nan bootclasspath bcp retrotranslator iterable
ops jopr googlegroups fletcher prefer djava expires fffe polish articles ops jopr googlegroups fletcher prefer djava expires fffe polish articles
attachment transiently cleanup attachment transiently cleanup dbsnmp olapsys wmsys tsmsys outln ctxsys mddata
\ No newline at end of file ordsys ordplugins mgmt dmsys exfsys mdsys sysman informtn textarray tmzone
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论