140 likes | 232 Views
Overview. Class systems poll Microsoft SQL Server Cubist Server CGI Programming JDBC Programming Project Milestones Reminder. Systems Poll. Java or C/C++ ? Perl HTML dynamic HTML: cgi, php, asp, jsp database systems? Mysql, postgresql, MSSQL, …. SQL Server: Query Analyzer.
E N D
Overview • Class systems poll • Microsoft SQL Server • Cubist Server • CGI Programming • JDBC Programming • Project Milestones Reminder
Systems Poll • Java or C/C++ ? • Perl • HTML • dynamic HTML: cgi, php, asp, jsp • database systems? Mysql, postgresql, MSSQL, …
Cubist • 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 content
Static HTML www.cs.washington.edu/static.html <html> <h1> I love databases! </h1> </html> GET static.html WWW BROWSER WEB SERVER
“Dynamic” HTML w/ PERL www.cs.washington.edu/dynamic.pl #!/usr/bin/perl print “Content-type: text/html \n”; print “<html>\n”; print “<h1> I love databases! </h1> \n”; print “</html>\n”; CGI Program GET dynamic.pl WWW BROWSER WEB SERVER program output
Dynamic HTML w/ DB GET db_access.pl WWW BROWSER WEB SERVER program output query results SQLquery SQL Server
DB 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>"; • } • }
Get postgresql.jar from http://jdbc.postgresql.org/ DB Connection from Java • import java.io.*; • import java.util.*; • import java.sql.*; • public classDatabase { • public staticvoidmain () { • 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 online.