Download presentation
Presentation is loading. Please wait.
Published byCody Allison Modified over 9 years ago
1
Overview Class systems poll Microsoft SQL Server Cubist Server CGI Programming JDBC Programming Project Milestones Reminder
2
Systems Poll Java or C/C++ ? Perl HTML dynamic HTML: cgi, php, asp, jsp database systems? Mysql, postgresql, MSSQL, …
3
SQL Server: Query Analyzer
4
SQL Server: Login
5
SQL Query Analyzer Interface
6
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/
7
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.
8
CGI Programming CGI: common gateway interface a program executed by web server, returning web content
9
Static HTML I love databases! www.cs.washington.edu/static.html WWW BROWSER GET static.html WEB SERVER
10
“Dynamic” HTML w/ PERL #!/usr/bin/perl print “Content-type: text/html \n”; print “ \n”; print “ I love databases! \n”; print “ \n”; www.cs.washington.edu/dynamic.pl WWW BROWSER GET dynamic.pl WEB SERVER program output CGI Program
11
Dynamic HTML w/ DB WWW BROWSER GET db_access.pl WEB SERVER program output SQL query query results SQL Server
12
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 "; }
13
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”); } }
14
1 st 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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.