This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I downloaded the JDBC driver from mysql.com mm.mysql-2.0.4-bin.jar and now what, i have installed tomcat and i want to link it to Mysql. I m doing a project on JSP and i need to get values from the database. I have downloaded the driver but now i dont know how to open it, and what to do next with it? Confused...can anyone help? Thanks, Suzana Shah
The (easiest) answer to your question is that a jar file is actually a zip file that has a jar extension. Rename the file to *.zip then open it in WinZip. The correct answer, however, is that you don't open the jar. A jar is a "Java Archive", to use it you either put it on your classpath or in the [java home]/lib directory, then you should automatically be able to load the drivers. If you are doing it within Tomcat or other app servers it sometimes gets a little more complicated. (not too difficult, just behaves differently) Hope this helps you out, drop a line if you need more Dave.
Whoops, didn't see where you refered to Tomcat. You have two options here: make the drivers accessible to all web-apps in Tomcat (easier but not generally recommended) or only make it available to a specific web-app. To make it available to all web-apps, place the jar in the [ TOMCAT_HOME ]/lib directory, otherwise put it in the web-apps/[context]/web-inf/lib directory. There are some differences between Tomcat 3.* and 4.* so you might need to experiment a bit. Dave. (again)
Joined: Jan 07, 2002
Hi Dave Thank you, but what do u mean i can do it two ways, you said that i could either have driver available to all web-apps or to specific one, well what does this mean, and which way is better to use and why. Sorry, its just all so confusing...i did it the way u suggested which is i copied it into the web-apps/[context]/web-inf/lib directory. What i did is copied the driver and pasted it into that directory..is that how i m suppose to do it? Helppppppp.... Suzee
When you create a web ap on an Application Server, the server is able to host multiple "applications" at the same time. So that you can maintain some measure of separation between these applications. Otherwise you could have problems like applications accidentally tripping over each other or applications that require different versions of some API. If you are only running a single app and it is just a test (or you always use the same database etc etc), dropping the drivers into either directory should be fine, as long as you understand the reasoning for both. Is this a bit better? Dave.
Joined: Jan 07, 2002
Thanks Dave, This makes it more clearer, so in my case, i m just trying to create a webpage using JSP, linking it a a simple MySql database where there wont be more then 5 tables, i would be able to use either.....is that correct..just confirming Another query i had was, say i copied the mm.mysql-2.0.4-bin.jar file into the directory as u mentioned. But other then that do i also have to set a classpath in the autoexe.bat file? If i do then say if i placed the .jar file in this directory: C:\jakarta-tomcat-3.3\webapps\admin\WEB-INF\lib then how would i actually set the classpath...do i sound like i dont have a clue of what i m saying....well i guess i am confused.....Thank you again Dave...for the help so far.... Need hellppppp again Suzi
You don't need to set the classpath for the tomcat server, it manages finding and loading classes itself. It all comes down to the concept of ClassLoaders. (see java.lang.ClassLoader and the Tomcat documentation). A ClassLoader loads classes (nothing difficult so far). You can create a heirarchy of ClassLoaders to achieve a number of effects, and this is how the manage the "lots of applications in the same VM with differnt classes" I need to go look it up again, but I think the default directories it load from is defined by the startup scripts and the server properties. Dave.