Subject | Re: [Firebird-Java] how do i get pooled connection |
---|---|
Author | Roman Rokytskyy |
Post date | 2005-07-23T05:46:37Z |
> if I instaniate FBConnectionPoolDataSource, it gives PooledConnection;Correct.
> if i get through the driver manager, i have no access to firebirdNot correct - you specify all Firebird specifics in extended properties:
> specifics (rolename etc).
Properties props = new Properties();
props.setProperty("user", "SYSDBA");
props.setProperty("password", "masterkey");
props.setProperty("sqlRole", "USER");
props.setProperty("encoding", "UNICODE_FSS");
Connection connection = DriverManager.getConnection(url, props);
> what should I do to be sure that connection/statement pooling isWhen you use FBConnectionPoolDataSource or FBWrappingDataSource, there is a
> switched on?
setters setPooling(boolean) and setMaxStatements(int). There is no
connection and statement pooling when you obtain connection via
DriverManager - that is JDBC specification and implementation specifics -
pooling is built on top of the driver.
> i want it to be as easy as in faq:FBWrappingDataSource dataSource = new FBWrappingDataSource();
> 002 Connection connection = dataSource.getConnection();
> but what that 'dataSource' object is made from?
dataSource.setDatabase("localhost/3050:/path/to/db.fdb');
dataSource.setUser("SYSDBA");
dataSource.setPassword("masterkey");
dataSource.setSqlRole("USER");
dataSource.setEncoding("UNICODE_FSS");
dataSource.setPooling(true); // this is default value
dataSource.setMaxStatements(10); // default value
Connection connection = dataSource.getConnection();
But usually you do not instantiate DataSource object yourself, this is done
by your container (in this case Tomcat) and later bound to JNDI. Your
application looks like this
InitialContext ctx = new InitialContext();
DataSource dataSource = (DataSource)ctx.lookup(myJndiName);
Connection connection = dataSource.getConnection();
Sample configuration for Tomcat can be found at
http://jaybirdwiki.firebirdsql.org/config/TomcatConnectionPooling , for
Jakarta DBCP at
http://jaybirdwiki.firebirdsql.org/config/JakartaDBCPConfiguration.
> ps. Roman, 'that' problem is still uninvestigated. cured withSo, I suspect that it would be enough to set the temp directory in Firebird
> explicitly setting /tmp directory as directory for temp files. i will
> write more details later in that thread
config - temp directory is used for sorting operations (ORDER BY). This
explains everything.
Roman