| Author |
Connecting to a MySQL database
|
Jenn Person
Ranch Hand
Joined: Jan 16, 2005
Posts: 89
|
|
I'm switching from MS Access database to MySQL. However I'm having problems with the whole process. I've downloaded connector/J, but I don't know where to unpack the zip file. Does it go somewhere into my SDK directory? My Tomcat directory? I've been reading this: http://www.javaranch.com/drive/jdbc/index.jsp to help me, but it just says to "Unzip the outer file into your root directory." It's not clear to me unfortunately.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Your JDBC driver needs to be in you application's classpath. Don't put it in your SDK. Have a read of this.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Edvins Reisons
Ranch Hand
Joined: Dec 11, 2006
Posts: 364
|
|
Read also the relevant MySQL docs ; in particular, the typical user only needs to install the binary jar (one file, mysql-connector-java-[ver]-bin.jar). [ March 29, 2007: Message edited by: Edvins Reisons ]
|
 |
Jenn Person
Ranch Hand
Joined: Jan 16, 2005
Posts: 89
|
|
Originally posted by Paul Sturrock: Your JDBC driver needs to be in you application's classpath. Don't put it in your SDK. Have a read of this.
Hi Paul, So I'll add the driver's jar file to the classpath, I know how to do that. But is there a particular location where it typically placed? Or it just doesn't matter so long as it's included in the classpath?
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
It depends on your application. If this is a web application your servlet container will have directories it includes by default in the classpath (if your servlet container is Tomcat, I think you are supposed to put it in the common/lib directory). If it is a desktop application you'll have to manage the classpath yourself.
|
 |
Jenn Person
Ranch Hand
Joined: Jan 16, 2005
Posts: 89
|
|
Yes, my container is Tomcat. Ok so I'll place it in the common/lib directory. As for the classpath, do I have to add the mysql-connector jar file by name? ex. CLASSPATH=C:\Tomcat\common\lib\mysql-connector-java-myversion-bin.jar or just CLASSPATH=C:\Tomcat\common\lib
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
No. Like I said - the servlet container has directories it includes be default in the classpath of your web app. common/lib is one of those directories.
|
 |
Narasimha Raju Naidu
Ranch Hand
Joined: Mar 23, 2007
Posts: 37
|
|
thanks to all at last i got sucess. my jsp program retriving record from my data base. thanks a lot to all who gave sugessions all these days. thanks thanks a lot regards Narasimha Raju Naidu
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Connecting to a MySQL database
|
|
|