Swing Tutorial on Netbeans 6.0

bravesnailsΛογισμικό & κατασκευή λογ/κού

7 Ιουν 2012 (πριν από 5 χρόνια και 5 μήνες)

354 εμφανίσεις

MySQL
-
JSP tutorial

February 26, 2008

Presented by: Anwar Hossain

Email: anwar@mcrlab.uottawa.ca

Installing MySQL and Tomcat server



Download mysql for windows from:



http://dev.mysql.com/downloads/mysql/5.0.html#win32



Install MySQL in your machine



Check by typing mysql from the command prompt to see mysql> command line



Download and install Tomcat as per the instructions in:



http://tomcat.apache.org/download
-
55.cgi


Type
http://localhost:8080/

in the browser


If the index page appears, installing seems ok


Download JDBC connector for mYSQL to work with Tomcat server from:



http://www.mysql.com/products/connector/j/



-

Extract the zip file anywhere in the C drive.


-

Copy mysql
-
connector
-
java
-
3.1.14
-
bin.jar file from the C drive
location


and put it under C:
\
Tomcat 5.0
\
common
\
lib, assuming your


Tomcat is installed in C:
\
Tomcat..


Creating MySQL script

--

--

create mysql database

--

CREATE DATABASE hcidb;

USE hcidb;




Open NOTEPAD or any other text editor in windows



Type the following:

Creating MySQL script

--

--

Table structure for table students;

--

DROP TABLE IF EXISTS students;


CREATE TABLE students(


studentID varchar(20) NOT NULL,


fname varchar(25),


lname varchar(25),


department varchar(30),


Note varchar(100),


PRIMARY KEY (studentID)

) TYPE=InnoDB;


Creating MySQL script

--

Insert some records


INSERT INTO students values ("123456", "John", "Doe", "Computer", "research
student");

INSERT INTO students values ("345678", "Jane", "Hunter", "Accounting", "project
student");

INSERT INTO students values ("543216", "Alice", "Alicia", "Computer", "research
student");

INSERT INTO students values ("576635", "Huang", "Hoo", "Management",
"research student");

Creating MySQL script

--

--

drop and create table

--

DROP TABLE IF EXISTS courses;


CREATE TABLE courses (


courseID varchar(10) NOT NULL,


coursename varchar(30) NOT NULL,


offeredin varchar(20),


PRIMARY KEY (courseID)

) TYPE=InnoDB;



INSERT INTO courses values ("csi1301", "Introduction to programming", "Fall");

INSERT INTO courses values ("acc3203", "Accounting basics", "Winter");

INSERT INTO courses values ("mgt1212", "Managing organization", "Fall");

Creating MySQL script

--

--

drop and create table

--

DROP TABLE IF EXISTS students_courses;


CREATE TABLE students_courses(


studentID varchar(20) NOT NULL,


courseID varchar(10) NOT NULL,


PRIMARY KEY (studentID, courseID)

) TYPE=InnoDB;


INSERT INTO students_courses values ("123456", "csi1301");

INSERT INTO students_courses values ("123456", "acc3203");

INSERT INTO students_courses values ("543216", "csi1301");

INSERT INTO students_courses values ("576635", "mgt1212");

Creating MySQL script


--

--

user creation and privilege

--


GRANT ALL PRIVILEGES ON hcidb.* TO hciuser@'localhost'


IDENTIFIED BY 'hciuser' WITH GRANT OPTION;

GRANT ALL PRIVILEGES ON hcidb.* TO hciuser@'%'


IDENTIFIED BY 'hciuser' WITH GRANT OPTION;



Save this script file as myscript.sql

Creating MySQL script



Open command prompt window



Type mysql

u root

p



Give password for root



From the mysql> prompt, type
\

. myscript.sql



Type exit



Again type mysql

u hciuser

p



Type hciuser as password



Type use hcidb;



Type show tables;


Creating webapps in Tomcat



Explore Tomcat root



Go to webapps directory



Copy Root directory and paste it with a new name e.g. hci



Write your first jsp page as index.jsp



Follow the hands
-
on shown in the class