- How to obtain Oracle
software?
- You can download Oracle server from
Oracle Technical Network website. You
need to be a member (free registration). Once you become a member, you can
download any Oracle software for your personal use.
- For UQ students, we are part of
Oracle
Academic Initiative scheme. Once you become a member of OAI, UQ's site
licence can be made available to you. This does not give you the latest
version of software, but does save you a lot of time for downloading
gigabytes of software.
- How to install Oracle?
- Install Oracle on Windows is very simple
these days. First you need to get a right copy of Oracle software (according
to which OS you are using).
- All you need to do to install Oracle, apart from normal
things such as click "yes" or "I accept" and set your program directories,
is to give a Global database name (for example, I use zxf.uq), and then your
SID will be derived (in my case, SID = zxf).
- It is time-consuming to install (from 20 minutes to 1
hour), but you don't need to do anything. Make sure you have sufficient disk
space (1.8GB plus) and memory (less than 256MB is not good). Remember we are
installing DBMS server, so you should have hardware to match.
- At the end of installation, write down the default user
account names and password: system/manager and sys/change_on_installation.
- Now you can start SQL*PLUS, and use system/manager as
username/password. You should be able to cerate tables etc. If you are happy
with using this account for your work, don't worry about the next step.
- If you want to create your own user account and database,
there are a bit more work to do. You need to use Oracle's Enterprise Manager
(you will find an Enterprise Manager Console option in the Oracle menu where
you see SQL*PLUS and other things). From there you can enter as
system/manager, and then change password, create users, give privileges
(such as create tables, create index, create triggers). Come to talk to me
if you want to know more about this.
- That's it!
- Where to obtain Tomcat
software?
- How to get Tomcat working?
- I have installed
Tomcat 4.1.18 recently (12/5/2003). I found it became a lot easier than
before (as described below). It's an automatic process now (just run that
.exe file downloaded from this course website). The installation software
tells you the port# so you need to write down. After that, all I did was to
set JAVA_HOME variable (from control panel -> System -> Advanced ->
Environment Variables -> System Variables", and I add new variable JAVA_HOME
and set the value to "C:/JBuilder8/jdk1.4" (that's where my JDK is).
No need to set up CATALINA_HOME anymore.
- Installation of
Tomcat (earlier versions) on your home PC: This should be very simple. Don't spend too
much time if you could not configure it properly. Ask George or me about how
to do this, though the
online instructions are very detailed already. It can be as simple as
doing two things: 1) copy the tomcat software to a directory (and add a new
system environment variable CATALINA_HOME to this directory so the systems
knows where to find the server software); 2) install JDK1.3 (maybe you have
already had it in your system, check first), then add a new system
environment variable JAVA_HOME to the JDK directory so the system knows
where to find Java software. You can add environment variables from Control
Panel-System-Advanced-Environment Variables. You can skip the steps of
changing DOS settings or changing port number from 8080 to 80 if you invoke
your servlet from http://localhost:8080/servlet/myServlet. You can have a
look at webapps/examples about how to use the Tomcat (this is basically a
mirror of what in ROOT directory).
- However, once Oracle is installed, Oracle
will be started automatically when you start your computer. So it's likely
that port 8080, to be used by Tomcat, is already used by Oracle. You will
see an error message if you start up Tomcat using it's default 8080 port.
In this case, do the following
- Go to your Tomcat directory (that is, %CATALINA_HOME%),
open conf\server.xml, search for 8080, and
replace 8080 to another number larger than 1024 (I used 8088). Save the file,
and start Tomcat again. It should work now. If you are unlucky (8088 is also
used), try another number.
- Don't forget to change HTML pages to use this new port
number to invoke JSPs or servlets.
- How to compile your Java code using JDBC?
- That's very easy. Just find where your Oracle's JDBC
library is, and include two .jar files in your classpath. For example, if
your JDBC library is at C:\oracle\ora90\jdbc\lib,
then you will see these two files there: classes12.jar
(Oracle JDBC drivers for JDK 1.2 and above) and
nls_charset112.jar (for character sets). Just include these two files
in your classpath, in the same way as you include servlet libraries before
(actually you will include JDBC as well as servlet libraries when you use
JDBC and servlet or JSP).
- How to find the connection
string of your own Oracle?
- The driver class is still
class.forName("oracle.jdbc.driver.OracleDriver");
Note this class is loaded at runtime from classes12.jar.
- The connection string will be
jdbc:oracle:thin:@yourhost:OraclePort:yourDB.
This information can be found in Oracle's Enterprise Manager (at the first
screen when you click your database name). You can guess this information, though. You should know the
hostname for your machine, and the port number is most likely 1521, and of
course you know your database name. For example, I use
jdbc:oracle:thin:@G638-8823:1521:zxf,
where
G638-8823
is my machine's name, and
zxf
is my SID name.
- How to get
Servlets/JSP working with Oracle using JDBC?
- Again, very simple. Remember that
your Tomcat server needs to convert your JSP pages into servlets and compiles
the servlets, and your Tomcat server needs to load JDBC driver at run-time,
so you need to tell your Tomcat server where to find these two files. All
you need to do here is to copy these two files (i.e., classes12.jar and nls_charset112.jar)
to the lib
directory of Tomcat (i.e., %CATALINA_HOME%/lib).
Modern Web servers add all things in their lib directory to its classpath.
- This will be done for you in the
lab. But if you want to use your own Tomcat server in the lab, or do things
at home, you will find these information useful.
- Finally, a
few suggestions:
- I would prefer to do things in
Java first, not using JSP or servlet, until I'm sure everything inside
Oracle and my interfaces to Oracles (query strings, results etc) are all
correct. You will find this is more productive, as you are not slowed down
by an extra layer of software (i.e., Tomcat, which has problems from time to
time), and also, you have more useful error messages.
- I would capture all error
exceptions and output them so I know what's wrong if something doesn't work.
I would also output every SQL string I passed to Oracle, just for a double
check.
- Remember System.out.print
doesn't work for your servlets or JSP, so you might want to use PrintWriter out
for generating HTML lines to output error messages (and remove them once
everything works).