| Author |
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, thanks, Sachin
|
 |
Yashar Kalantari
Greenhorn
Joined: Sep 19, 2004
Posts: 12
|
|
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 ]
|
 |
 |
|
|
subject: Using Commons dbcp with MySQL
|
|
|