This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC MSSQL 2000 connection pool manager  RSS feed

Andrew Parker
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a java console application which needs to connect to MSSQL 2000 DB. I installed the jdbc driver and set the classpath.

Previously, I used to connect MySQL with ConnectionPool.

I use the same connectionpool class to connect to the MSSQL 2000 by changing the parameters.
ConnectionTimeout = 2

I read the Microsoft SQL Server 2000 Driver for JDBC help documents:

The pool implementation creates "real" database connections using the getPooledConnection() method of ConnectionPoolDataSource. Then, the pool implementation registers itself as a listener to the PooledConnection. When a client application requests a connection, the pool implementation (Pool Manager) assigns one of its available connections. If there is no connection available, the Pool Manager establishes a new connection and assigns it to that application. When the client application closes the connection, the Pool Manager is notified by the driver through the ConnectionEventListener interface that the connection is free and available for reuse. The pool implementation is also notified by the ConnectionEventListener interface when the client somehow corrupts the database connection, so that the pool implementation can remove that connection from the pool.

Once a SQL Server 2000 Driver for JDBC data source has been registered with JNDI, it can be used by your JDBC application as shown in the following example, typically through a third-party connection pool tool:

Context ctx = new InitialContext();
ConnectionPoolDataSource ds =
pooledConnection pcon = ds.getPooledConnection("matt", "wwf");

In this example, the JNDI environment is first initialized. Next, the initial naming context is used to find the logical name of the JDBC data source (EmployeeDB). The Context.lookup() method returns a reference to a Java object, which is narrowed to a javax.sql.ConnectionPoolDataSource object. Finally, the ConnectionPoolDataSource.getPooledConnection() method is called to establish a connection with the underlying database.

NOTE: JDBC drivers do not manage connection pooling. You must use an external connection pool manager.

I need to create a pool and the create method is:

I added breakpoint and saw that the following code did not execute and finally return a nullpointerexception.

Q.1 I am not sure "Once a SQL Server 2000 Driver for JDBC data source has been registered with JNDI", how can I register with JNDI?

Q.2 I saw that the help document mentioned ConnectionPoolDataSource.getPooledConnection(), my connectionpool java class does not has getPooledConnection() method.

I have only the public synchronized java.sql.Connection getConnection() which seems not use javax.sql.ConnectionPoolDataSource, it only uses java.sql.Connection.

May I ask where can I download the connection pool manager java source?

Thanks for help
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!