Download presentation
Presentation is loading. Please wait.
Published byEugenia Hamilton Modified over 8 years ago
1
Settings MySQL Database and JDBC configuration Instructor: Sergey Goldman
2
Instructions for Installing MySQL Installing MySQL Connector/J Test example Java DB Test example Installing Tomcat
3
Instructions for Installing MySQL Database MySQL 5.5 Community Server Edition - open-source database management system that executes on many platforms, including Windows, Solaris, Linux, and Macintosh Download: http://dev.mysql.com/downloads/mysql/5.5.html#downloadshttp://dev.mysql.com/downloads/mysql/5.5.html#downloads Complete information about MySQL is available from http://www.mysql.com http://www.mysql.com Installation requirements for your platform: http://dev.mysql.com/doc/refman/5.5/en/installing.html –Download from http://dev.mysql.com/downloads/mysql/ –Select OS. Ex, Windows64. –Run the MSI installer
4
Instructions for Installing MySQL Database (cont.)
5
Accept agreement amd Choose Typical for the Setup Type, then Click install
6
Next, next…finish
7
Select Standard Configuration
8
Select Install as Windows Service (optional). Otherwise start manually as mysql-nt.exe Select Include Bin Directory in Windows PATH
9
Select Modify Security Settings. Type password mysql (BTW, in the Deitel book it is root ) Select Create An Anonymous Account mysql mysql
10
Execute
11
MySQL running as service
12
Possible Problem: Windows Firewall Exception http://windows.microsoft.com/en-us/windows/open-port-windows- firewall#1TC=windows-7
13
Open mssql using command line
14
Another way All Programs->MySQL MySQL Command Line Client
15
Switch to the default mysql database (do not confuse with mysql password!)
16
Important: Create deitel user: Create a deitel user with password is deitel create user 'deitel'@'localhost' identified by 'deitel';
17
Give deitel user all privileges Give deitel user all privileges grant select, insert, update, delete, create, drop, references, execute on *.* to 'deitel'@'localhost';
18
Logging as deitel user (command prompt) Logging as deitel user (command prompt) mysql -h localhost -u deitel –p password: deitel
19
Logging as deitel user (another command) Logging as deitel user (another command) mysql –user=deitel –p password: deitel
20
Logging as deitel user (another command) Logging as deitel user (another command) mysql –user=deitel –password=deitel
21
Create books Database Copy from chapter 28 examples ch28\SQLscripts\mysql books.sql to C:\Program Files\MySQL\MySQL Server 5.5\data
22
Create books Database (cont) Execute (no ;) source C:\Program Files\MySQL\MySQL Server 5.5\data\books.sql
23
Check books database entries
24
Update path for javac (if not yet done can be a different version)
25
Test Failure (re-compile first)
26
Installing MySQL Connector/J To use MySQL with JDBC, you also need to install MySQL Connector/J— a JDBC driver that allows programs to use JDBC to interact with MySQL MySQL Connector/J can be downloaded from http://dev.mysql.com/downloads/connector/j/5.1.html Get Platform independent mysql-connector-java-5.1.34.zip (latest at that time) OR mysql-connector-java-5.1.14.tar.gz from Deitel’s CD The documentation for Connector/J is located at http://dev.mysql.com/doc/connector/j/en/connector-j.html http://dev.mysql.com/doc/connector/j/en/connector-j.html Unzip and get mysql-connector-java-5.1.34-bin.jar
27
Configure Connector/J Unzip the tar.gz (use for example, Winzip) or simply use from CD, or provided by instructor All you need is mysql-connector-java-5.1.34-bin.jar Put it somewhere, for example (change: c:\MySql\sglj)
28
Configure Connector/J cont. Set System CLASSPATH to use this jar.;C:\Program Files\Java\jdk1.7.0_75;c:\MySql\mysqlj\mysql-connector-java- 5.1.18-bin.jar
29
Re-test (new shell)
30
Apache Tomcat Server Multiple ways: –Stand alone (download version 7.x from from http://tomcat.apache.org/download-70.cgi) http://tomcat.apache.org/download-70.cgi Use Windows service (32/64 installer) or without (32/64 zip) If using zip, install under C:\tomcat
35
Setting Up Environmental Variables for (No windows service) Define environment variables –CATALINA_HOME C:\tomcat –CATALINA_BASE C:\tomcat –JAVA_HOME C:\Program Files\Java\jdk1.7.0_02 –Add to CLASSPATH C:\tomcat\lib\servlet-api.jar C:\tomcat\lib\jsp-api.jar –On some platforms you may need to restart your computer for the new environment variables to take effect
36
Create desktop shortcuts (if not running as service) Create desktop shortcuts (if not running as service) May need to restart after deploying a new content
37
SETTINGS CATALINA_BASE=C:\tomcat CATALINA_HOME=C:\tomcat CLASSPATH=.;C:\Program Files\Java\jdk1.7.0_02;c:\mysqlj\mysql-connector-java-5.1.18-bin.jar;C:\Program Files\Java\jdk1.7.0_02\db\lib\derby.jar;C:\tomcat\lib\ser vlet-api.jar;C:\tomcat\lib\jsp-api.jar JAVA_HOME=C:\Program Files\Java\jdk1.7.0_02 Path=.;C:\Program Files\Java\jdk1.7.0_02\bin;C:\Program Files\RSA SecurID Token Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\ 9.0\DLLShared\;C:\Program Files\ImageConverter Plus;C:\Program Files\ImageConver ter Plus\Microsoft.VC90.CRT;C:\Program Files\ImageConverter Plus\Microsoft.VC90. MFC;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\MySQL\MySQL Server 5.5 \bin
38
Java DB* As of JDK 7, the open-source, pure Java database Java DB (the Sun branded version of Apache Derby) comes with the JDK Before you can execute the application in the next section, you must set up the AddressBook - database in Java DB We use the embedded version of Java DB –There is also a network version that executes similarly to the MySQL DBMS –http://developers.sun.com/javadb/reference/docs/http://developers.sun.com/javadb/reference/docs/ –read “Getting Started with Java DB” for installation and configuration instructions.
39
Java DB (Windows settings)* Open the batch file setEmbeddedCP.bat (located in C:\Program Files\Java\jdk1.7.0_02\db\bin ), locate the line @rem set DERBY_INSTALL= Change it to @set DERBY_INSTALL=C:\Program Files\Java\jdk1.7.0_02\db\bin Open a Command Prompt and change directories to C:\Program Files\Java\jdk1.7.0_02\db\bin Type setEmbeddedCP.bat and press Enter to set the environment variables required by Java DB An embedded JavaDb must reside in the same location as the application that manipulates the database Change to the directory that contains the code, for example: C:\Projects\Forte\_WebPage_cst356_javaWeb\resources\examples\ch 28\fig28_30_32-WithoutDBPredefined This directory contains a SQL script address.sql that builds the AddressBook database
41
Execute the command "C:\Program Files\Java\jdk1.7.0_02\db\bin\ij" to start the command-line tool for interacting with Java DB Java DB settings*
42
Create database table Adresses* –first delete AddressBook directory –Connect to AddressBook database (will create AddressBook db if not exists) connect 'jdbc:derby:AddressBook;create=true;user=deitel;password=deitel'; –Create database table run 'address.sql';
43
Test. Compile (javac *.java) and run
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.