Home | Source code | How to become a hacker

Visa källkod

Nedanstående filer finns i denna katalogen. Klicka på en fil för att visa dess innehåll.

java-to-db/

ExampleJDBC.java
common.php
index.php
source.php

index.php
<?php
// ===========================================================================================
//
// index.php
//
// Description: Example on how to connect Java to database.
//
// Author: Mikael Roos
//


// -------------------------------------------------------------------------------------------
//
// The content of the page
//
$html = <<<EOD
<div>
<h1>Connecting Java to a database through JDBC</h1>
<p>
En example program written in Java showing how to connect to a Microsoft SQL Server 2005 Express
database using a JDBC driver. 
</p>

<h2>How to do it</h2>

<p>
<a href="http://www.student.bth.se/~mos/java-to-db/source.php?dir=&file=ExampleJDBC.java">Review the Java example program.</a>
</p>

<p>
<a href="ExampleJDBC.java">Download it.</a>
</p>

<p>
Instructions are available in the source-code.
</p>

EOD;


// -------------------------------------------------------------------------------------------
//
// Create and print out the html-page
//
require_once('common.php');
$title         = "Connecting Java to a database using JDBC";
$charset     = "iso-8859-1";
$language    = "en";

$html = <<< EOD
<?xml version="1.0" encoding="{$charset}" ?> 
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$language}" lang="{$language}">  
    <head>
        <meta http-equiv="Content-Type" content="text/html; {$charset};" />
        <title>{$title}</title>
    </head>
    <body>
        {$header}
        {$html}
        {$footer}
    </body>
</html>
EOD;

header("Content-Type: text/html; charset={$charset}");
echo $html;
exit;

?>
 .                
..:    Mikael Roos