Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Jetty and JDBC

These demos illustrate basic concepts related to embedded Jetty and servlets in Java.

Jetty Setup

See the "Servlets" README for how to setup Jetty.

JDBC Setup

To add JDBC as a user library in Eclipse, you need to download a driver to connect Java to our MariaDB database server on campus:

Name your library jdbc to have it automatically included by the lecture examples. See the Adding User Party Libraries in Eclipse guide for details.

Configuring JDBC

Modify with your MariaDB username and password. If you are connecting from on-campus, then set in the properties file.

If you are connecting off-campus, then set hostname=localhost:3307 in the properties file, and create an SSH tunnel to forward anything sent to your port 3307 to our MariaDB server on campus using this command:

ssh -L

where username is your CS username. You will be prompted for your CS password.

If you are a Mac user, you can create a tunnel.command file with the SSH command you should use and give the file execute privileges. Then, you should be able to double-click the file to run the command.

If you are a Windows user, you need to setup the tunnel (or port forwarding) using a program like Putty. (Search for "Putty Port Forwarding" to find several guides.)

Relevant Resources

The following official Java Tutorials may be useful:

Security Notes

Nothing we do regarding security will be effective unless we use encrypted communication between the client browser and the web server. For this, you should be using HTTPS instead of HTTP.

Unless you are a security expert, I always recommend you use a package designed by security professionals for handling sensitive information (like username and passwords). However, there are some best practices guides out there. See the OWASP Password Storage Cheat Sheet for an example.

You can’t perform that action at this time.