| Author |
DBCP -- connection string for SQL Server
|
eric zhao
Greenhorn
Joined: Feb 26, 2003
Posts: 20
|
|
Folks: Anyone has experience using DBCP with SQL Server? What is the connection String for SQL Server? I am using following for oracle, but couldn't find any documentation for SQL Server: (replace # with :, : was displayed as icons for some reason) jdbc#oracle#thin#userid/password@server#port#Databasename Thanks. [ August 24, 2005: Message edited by: eric zhao ] [ August 24, 2005: Message edited by: eric zhao ]
|
 |
Tom Blough
Ranch Hand
Joined: Jul 31, 2003
Posts: 263
|
|
If you are using Microsoft's type 4 JDBC Driver then it's: Otherwise, it depends on your driver. Cheers, [ August 24, 2005: Message edited by: Tom Blough ]
|
Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
|
 |
eric zhao
Greenhorn
Joined: Feb 26, 2003
Posts: 20
|
|
Thanks, Tom. But with DBCP, when dealing with oracle or mysql, I have userid and password passed in explicitly in the connection string. I don't know how to do the same with SQL Server. Any suggestions? Do I have to change my wrapper code for DBCP for SQL Server? Below is the code I wrote to wrap DBCP (pooled driver) used for my projects, it works if the userid and password are in connectionURL. How can I pass the userid and password outside the connectionURL? ObjectPool connectionPool = new GenericObjectPool(null, maxActive, GenericObjectPool.WHEN_EXHAUSTED_BLOCK, 5000); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connectURI, null); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, null, false, true); Class.forName("org.apache.commons.dbcp.PoolingDriver"); PoolingDriver driver = (PoolingDriver) DriverManager.getDriver( "jdbc:apache:commons bcp:"); driver.registerPool(poolname, connectionPool); Many thanks. Eric [ August 29, 2005: Message edited by: eric zhao ]
|
 |
Tom Blough
Ranch Hand
Joined: Jul 31, 2003
Posts: 263
|
|
Eric, just use the connectonFactory constructor that take the user name and password as parameters: Cheers,
|
 |
eric zhao
Greenhorn
Joined: Feb 26, 2003
Posts: 20
|
|
Tom, thank you very much for your help. Do you happen to know if there is some website having good documentation for DBCP? DBCP's own website has very limited examples and how-tos. Have a great day.
|
 |
eric zhao
Greenhorn
Joined: Feb 26, 2003
Posts: 20
|
|
Tom, Still more problems. Even if I pass in the userid and password with the constructor you mentioned, I still get the following error messge: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. Any ideas? I have googled this error and haven't found any pointers. thanks. Eric
|
 |
 |
|
|
subject: DBCP -- connection string for SQL Server
|
|
|