• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC MSSQL 2000 connection pool manager

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic