mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Applied patch from Aaron Mulder (ammulder@alumni.princeton.edu) that fixes
jdbc datasource support for jdk1.4/jdbc3 Modified Files: jdbc/build.xml jdbc/org/postgresql/Driver.java.in jdbc/org/postgresql/jdbc2/optional/BaseDataSource.java jdbc/org/postgresql/jdbc2/optional/PGObjectFactory.java jdbc/org/postgresql/jdbc2/optional/PooledConnectionImpl.java jdbc/org/postgresql/jdbc2/optional/PoolingDataSource.java jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java jdbc/org/postgresql/test/jdbc2/optional/OptionalTestSuite.java jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java Added Files: jdbc/org/postgresql/jdbc3/Jdbc3ConnectionPool.java jdbc/org/postgresql/jdbc3/Jdbc3ObjectFactory.java jdbc/org/postgresql/jdbc3/Jdbc3PooledConnection.java jdbc/org/postgresql/jdbc3/Jdbc3PoolingDataSource.java jdbc/org/postgresql/jdbc3/Jdbc3SimpleDataSource.java jdbc/org/postgresql/test/jdbc2/optional/PoolingDataSourceTest.java jdbc/org/postgresql/test/jdbc3/Jdbc3ConnectionPoolTest.java jdbc/org/postgresql/test/jdbc3/Jdbc3PoolingDataSourceTest.java jdbc/org/postgresql/test/jdbc3/Jdbc3SimpleDataSourceTest.java jdbc/org/postgresql/test/util/MiniJndiContext.java jdbc/org/postgresql/test/util/MiniJndiContextFactory.java
This commit is contained in:
@ -0,0 +1,60 @@
|
||||
package org.postgresql.test.jdbc3;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import org.postgresql.test.jdbc2.optional.SimpleDataSourceTest;
|
||||
import org.postgresql.test.TestUtil;
|
||||
import org.postgresql.jdbc3.*;
|
||||
|
||||
/**
|
||||
* Tests JDBC3 non-pooling DataSource.
|
||||
*
|
||||
* @author Aaron Mulder (ammulder@chariotsolutions.com)
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
public class Jdbc3SimpleDataSourceTest extends SimpleDataSourceTest {
|
||||
/**
|
||||
* Constructor required by JUnit
|
||||
*/
|
||||
public Jdbc3SimpleDataSourceTest(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and configures a new SimpleDataSource.
|
||||
*/
|
||||
protected void initializeDataSource()
|
||||
{
|
||||
if (bds == null)
|
||||
{
|
||||
bds = new Jdbc3SimpleDataSource();
|
||||
String db = TestUtil.getURL();
|
||||
if (db.indexOf('/') > -1)
|
||||
{
|
||||
db = db.substring(db.lastIndexOf('/') + 1);
|
||||
}
|
||||
else if (db.indexOf(':') > -1)
|
||||
{
|
||||
db = db.substring(db.lastIndexOf(':') + 1);
|
||||
}
|
||||
bds.setDatabaseName(db);
|
||||
bds.setUser(TestUtil.getUser());
|
||||
bds.setPassword(TestUtil.getPassword());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Makes sure this is a JDBC 3 implementation producing JDBC3
|
||||
* connections.
|
||||
*/
|
||||
public void testConfirmJdbc3Impl()
|
||||
{
|
||||
try {
|
||||
Connection con = getDataSourceConnection();
|
||||
assertTrue("Wrong SimpleDataSource impl used by test: "+bds.getClass().getName(), bds instanceof Jdbc3SimpleDataSource);
|
||||
assertTrue("Wrong Connnection class generated by JDBC3 DataSource: "+con.getClass().getName(), con instanceof Jdbc3Connection);
|
||||
} catch (SQLException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user