OverviewSystems PollSQL Server: Query AnalyzerSQL Server: LoginSQL Query Analyzer InterfaceCubistCubist (Continue)CGI ProgrammingStatic HTML“Dynamic” HTML w/ PERLDynamic HTML w/ DBDB connection from perlDB Connection from Java1st Project MilestonesOverview•Class systems poll•Microsoft SQL Server•Cubist Server•CGI Programming•JDBC Programming•Project Milestones ReminderSystems Poll•Java or C/C++ ?•Perl•HTML•dynamic HTML: cgi, php, asp, jsp•database systems? Mysql, postgresql, MSSQL, …SQL Server: Query AnalyzerSQL Server: LoginSQL Query Analyzer InterfaceCubist•CGI programs are not allowed by cs web server•Special server: CUBIST•Your account will have directory www•Accessed as –http://cubist.cs.washington.edu/~username/Cubist (Continue)•You will need to access PostgreSQL on Cubist•Account has been setup for you.•Password should have been emailed to you individually.•Getting start with PostgreSQL details are on our course website.CGI Programming•CGI: common gateway interface•a program executed by web server, returning web contentStatic HTML<html><h1> I love databases! </h1></html>www.cs.washington.edu/static.htmlWWWBROWSERGET static.htmlWEBSERVER“Dynamic” HTML w/ PERL#!/usr/bin/perlprint “Content-type: text/html \n”;print “<html>\n”;print “<h1> I love databases! </h1> \n”;print “</html>\n”;www.cs.washington.edu/dynamic.plWWWBROWSERGET dynamic.plWEBSERVERprogram outputCGI ProgramDynamic HTML w/ DBWWWBROWSERGET db_access.plWEBSERVERprogram outputSQL queryquery resultsSQLServerDB connection from perl#!/usr/bin/perl5 -w use CGI;use DBI; $html = new CGI; print $html->header, "\n", $html->start_html(); &searchDatabase;print $html->end_html; sub searchDatabase { $sql = "SELECT * FROM MovieDatabase"; $db = DBI->connect ("dbi:Pg:dbname=database", "cse444", “cse444"); $db or die "Sorry we couldn't connect!\n"; $data = $db->prepare($sql); $data->execute(); $tuple = ""; while ($tuple = $data-> fetchrow_hashref()) { $title = $tuple->{Title}; print “Title is $title<p>";}}DB Connection from Java• Get postgresql.jar from http://jdbc.postgresql.org/import java.io.*;import java.util.*;import java.sql.*;public class Database {public static void main () {try {Class.forName("org.postgresql.Driver");java.sql.Connection con = DriverManager.getConnection (“jdbc:postgresql:database”, “cse444”, “cse444”);java.sql.Statement stmt = con.createStatement();java.sql.ResultSet rs = stmt.executeQuery (“SELECT * FROM MovieDatabase”);while(rs.next()) {System.out.println(“Title is ” + rs.getString(“Title”);}}catch (SQLException e) { System.out.println (“Error in database connection”); }}}1st Project Milestones•Today: Groups formed, email both Alon (alon@cs) and Luna (lunadong@cs) with: –The members of the groups –The group name –The URL of the group web page •Other project milestones details are
View Full Document