Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to a MySQL database

 
Jenn Person
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your JDBC driver needs to be in you application's classpath. Don't put it in your SDK. Have a read of this.
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic