jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Using Commons dbcp with MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Using Commons dbcp with MySQL" Watch "Using Commons dbcp with MySQL" New topic

Using Commons dbcp with MySQL

Sachin Dere
Ranch Hand

Joined: Jan 14, 2003
Posts: 80
Hi guys,
how can i use Commons DBCP with MySQL DB?All the examples are using Oracle Driver.How do i set the username & pwd for it?
pls help me,
Yashar Kalantari

Joined: Sep 19, 2004
Posts: 12
Hi Sachin

I am declaring my solution acording to sample in URL


you can change your Driver by changing the Driver package like this

System.out.println("Loading underlying JDBC driver.");
try {
} catch (ClassNotFoundException e) {

it's abvioues that befor doing this you need to download this driver from mysql website and deploy it.

for passing username and password to DBCP try this:

Properties props = new Properties();
props.put("user", "username");
props.put("password", "password");

ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(this.getDbURL(), props);

regards yashar.

[ November 25, 2004: Message edited by: Yashar Kalantari ]

[ November 25, 2004: Message edited by: Yashar Kalantari ]
[ November 25, 2004: Message edited by: Yashar Kalantari ]
I agree. Here's the link: http://aspose.com/file-tools
subject: Using Commons dbcp with MySQL
It's not a secret anymore!