440 likes | 607 Views
Tutorial (1). Software installation. Written by: Eng. Ahmed Mohamed Abdel Ghafar , Edited by Eng. Muhammed Hammad , Eng. Hamdy Soltan & Eng. Osama Talaat. Download Software. Click any picture to go to download link …. MySQL Installer. Apache Tomcat. Java JDK.
E N D
Tutorial (1) Software installation Written by: Eng. Ahmed Mohamed Abdel Ghafar, Edited by Eng. MuhammedHammad, Eng. HamdySoltan & Eng. Osama Talaat
Download Software Click any picture to go to download link … MySQL Installer Apache Tomcat Java JDK If you have x64 processor architecture in your computer, download both the x86 & x64 versions of the JDK. Download MySQL Connector/J(platform independent).
MySql Server Install MySQL Products
MySql Server Accept the licence
MySql Server Do not check for updates
MySql Server Choose the full setup
MySql Server You must be connected to the internet to download the missed component
MySql Server The items to be installed
MySql Server Configure MySQL Server
MySql Server Configure MySQL Server
MySql Server Set the password to: root
MySql Server Configure MySQL Server
MySql Server Samples & Examples
MySql Server Samples & Examples
MySql Server Completed …
MySql Server MySQL Workbech
Install java jdk If you have x64 processor architecture in your computer, install both the x86 & then x64 versions of the JDK.
Apache Tomcat Set the username and password to: root
Apache Tomcat • Check that apache is running correctly, open this link: http://localhost:8080/ • A similar page like this should appear • Done !!!
Run Apache Tomcat Service at startup Control Panel >> Administrative tools >> Services
Run Apache Tomcat Service at startup Startup type: Automatic
First JSP Page • Make a new text document in your desktop. • Copy the following code and paste it in the text document: <html> <head> <title> Non Official page </title> </head> <body> <font face="Times New Roman" size="+3" color="#CC0099"><br><center> Faculty of Engineering; Computer and Systems Dept. </center></font> </body> </html>
First JSP Page • Rename the text file as faculty.jsp • Navigate to C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps • Make a new folder and rename it faculty. • Copy the text file to this folder. • If you are running windows 7 you must be an administrator and you may have to make the text file at any other location and then pasting it in the “faculty” folder. • Go to your browser: http://localhost:8080/faculty/faculty.jsp • The following page should appear:
Building a test database Open MySQL Workbench, Database Menu >> Query Database
Building a test database The localhost with Port Number: 3306, username: root & password: root
Building a test database Click this button to create a new database schema
Building a test database Name it faculty and click Apply
Building a test database Apply
Building a test database Finish
Building a test database The new empty database is created and listed in the left
Building a test database Name it students, and create new columns with the names id, FirstName & LastNames then click Apply, Apply then Finish
Building a test database Edit the table rows data
Building a test database Enter any data correspond to the field names,then click Apply, Apply and Finish
Install MySql Connector/J • extract MySQL Connector/J you downloaded. • Copy the file named: “mysql-connector-java-xxxx-bin” • Paste it in C:\Program Files\Apache Software Foundation\Tomcat 7.0\lib.
Testing Apache Tomcat and MySQL Together • Make a new text document in your desktop. • Copy the following code and paste it in the text document: <%@ page import="java.sql.*" %> <% String connectionURL = "jdbc:mysql://localhost:3306/faculty?user=root;password=root"; Connection connection = null; Statement statement = null; ResultSetrs = null; %> <html><body> <%
Testing Apache Tomcat and MySQL Together try { Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection(connectionURL, "root", "root"); statement = connection.createStatement(); rs = statement.executeQuery("SELECT * FROM students"); while (rs.next()) { out.println(rs.getInt("id")+rs.getString("FirstName")+rs.getString("LastName")+rs.getString("E-mail")+"<br>"); } rs.close(); } catch(Exception e) { System.err.println("Exception: " + e.getMessage()); } finally { try { if(connection != null) connection.close(); } catch(SQLException e) {} } %> </body></html>
Testing Apache Tomcat and MySQL Together • Rename the text file as test.jsp • Navigate to C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT • Copy the text file to this folder. • RESTART YOUR COMPUTER • Go to your browser and type in address Bar: http://localhost:8080/test.jsp • The database entries you have entered before must be displayed in the browser.