File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes mySql connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "mySql connection" Watch "mySql connection" New topic
Author

mySql connection

Joseph Bashir
Ranch Hand

Joined: Jun 16, 2004
Posts: 41
Can someone please tell me how to connect to mysql database?

Thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

From a web app?
If so, what container are you using?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Nimish Patel
Ranch Hand

Joined: Jun 29, 2005
Posts: 84
hi,

if you use tomcate 5.5.x version ,u have to configure in context.xml
otherwise in server.xml.

download mysql driver from net.
driver name like this "mysql-connector-java-3.0.16-ga-bin.jar"

copy this file in %CATALINA_HOME%\common\lib folder.

and following code in context.xml
-----------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<Context crossContext="true" debug="5" docBase="/xyz" path="/xyz" reloadable="true">
<Resource auth="Container" driverClassName="org.gjt.mm.mysql.Driver" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" logAbandoned="true" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/abc" password="admin" removeAbandoned="true" removeAbandonedTimeout="60" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/databasename?autoReconnect=true" username="root" />
</Context>
---------------------------------------------------------

change name,pathname and username,databasename relative to u.ok
if u changes according to ur application, i hope it will works.


Thanks,
Nimish
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Moving this to the JDBC forum. This forum is for Servlets questions.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mySql connection