aspose file tools*
The moose likes JDBC and the fly likes JDBC MSSQL 2000 connection pool manager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC MSSQL 2000 connection pool manager" Watch "JDBC MSSQL 2000 connection pool manager" New topic
Author

JDBC MSSQL 2000 connection pool manager

Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Hi,

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.

JDBCDriver=com.microsoft.jdbc.sqlserver.SQLServerDriver
JDBCConnectionURL=jdbc:microsoft:sqlserver://MSSERVER:1433
ConnectionPoolSize=5
ConnectionPoolMax=10
ConnectionUseCount=5
ConnectionTimeout = 2
User=mssql
Password=mssql

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 =
(ConnectionPoolDataSource)ctx.lookup("jdbc/EmployeeDB");
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC MSSQL 2000 connection pool manager