dcsimg

Table 1:

CD Table
BAND_NAME ALBUM_NAME PUBLISHER COST
Big Bad Voodoo Daddy Big Bad Voodoo Daddy BMI 12.99
Levay Smith One Hour Mama Fat Note 13.99
Louis Prima Capitol Collector's Series Capitol 9.99
Indigo Swing Indigo Swing Wet and placket 13.99
Louis Jordan Rock and Roll Mercury 12.99
Louis Jordan Best Of Capitol 10.99

Code example 1:


#!c:\Perl\Perl5.00402\bin\perl.exe
use CGI;
$dataIn = new CGI;
$dataIn->header();
print "Hello Cyberspace";

[Test CGI Script]

Code example 2:

Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
Connection jdbcConnection = 
	         DriverManager.getConnection
                 (jdbc:odbc:Access);
Statement sqlStatement = jdbcConnection.createStatement();

        // We have seen all of the above before.  
        // No surprises so far.  in the next line, we
        // will simply create a string of SQL.  

String sql = "SELECT * FROM CUSTOMERS";

        // Next we will attempt to send the SQL command to
        // the database.  If it works, the database will 
        // return to us a set of results that JDBC will 
        // store in a ResultSet object.

try
  {
  ResultSet results = sqlStatement.executeQuery(sql);

        // We simply go through the ResultSet object
        // one element at a time and print out the 
        // fields.  In this example, we assume that
        // the result set will contain three fields

  while (results.next())
    {
    System.our.println("Field One: " + 
                       results.getString(1) +
                       "Field Two: " + 
                       results.getString(2) +
                       "Field Three: " + 
                       results.getString(3));
    }
  }

        // If there was a problem sending the SQL, 
        // we will get this error.

catch (Exception e)
  {
  System.out.println("Problem with Sending Query: " + e);
  }

Code example 3:

Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
Connection jdbcConnection = 
	         DriverManager.getConnection
                 (jdbc:odbc:Access);
Statement sqlStatement = jdbcConnection.createStatement();

        // We have seen all of the above before.  
        // No surprises so far.  in the next line, we
        // will simply create a string of SQL.  

String sql = "INSERT INTO CUSTOMERS + 
             " (CustomerID, Firstname, LastName, Email)" +
	     " VALUES (004, 'Selena', 'Sol' " +
                      "'selena@extropia.com')";

        // Now submit the SQL....

sqlStatement.executeUpdate(sql);