• 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

Using Commons dbcp with MySQL

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
thanks,
Sachin
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sachin

I am declaring my solution acording to sample in URL

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/dbcp/doc/ManualPoolingDriverExample.java?rev=1.6&view=markup

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

System.out.println("Loading underlying JDBC driver.");
try {
Class.forName("org.gjt.mm.mysql.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic