Your SlideShare is downloading. ×
MySQL JDBC Tutorial
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

MySQL JDBC Tutorial

1,122

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,122
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
27
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MySQL and JDBC Tutorial ECT 7130 Hong Cheng
  • 2. Supplement on MySQL
    • http://cs.armstrong.edu/liang/intro7e/supplement/Supplement4bMySQL.pdf
  • 3. MySQL Download and Install
    • http://dev.mysql.com/downloads/mysql/5.4.html
    • When you install the software, you can set the root password.
  • 4. Starting and Stopping MySQL Server
    • Starting and stopping the server
      • See Item 1 in supplement
    • Login
      • mysql –u root –p
      • Type your password
    • Create an ordinary user
      • See Item 3 in supplement to create a user with name “scott” and password “tiger”
  • 5. Databases in MySQL
    • show databases;
    • use test;
    • create database javabook;
    • use javabook;
  • 6. Tables
    • create table Course (
    • courseId char(5),
    • subjectId char(4) not null,
    • courseNumber integer,
    • title varchar(50) not null,
    • numOfCredits integer,
    • primary key (courseId)
    • );
    create table Student ( ssn char(9), firstName varchar(25), mi char(1), lastName varchar(25), birthDate date, street varchar(25), phone char(11), zipCode char(5), deptId char(4), primary key (ssn) ); create table Enrollment ( ssn char(9), courseId char(5), dateRegistered date, grade char(1), primary key (ssn, courseId), foreign key (ssn) references Student (ssn), foreign key (courseId) references Course (courseId) );
  • 7. Load from a File
    • Put the above commands in a file, e.g., test.sql and put in D:ook est.sql.
    • Then in MySQL command line window, type: source D:ook est.sql
  • 8. Insert Tuples
    • insert into Course (courseId, subjectId, courseNumber, title, numOfCredits) values ('11113', 'CSCI', '3720', 'Database Systems', 3);
    • insert into Student (ssn, firstName, mi, lastName, birthDate, street, phone, zipCode, deptId) values ('123456789', 'John', 'M', 'Smith', '1990-01-02', 'main', '222-333-444', '61801', 'SEEM');
    • insert into Enrollment (ssn, courseId, dateRegistered, grade) values ('123456789', '11113', '2009-9-1', 'A');
    • select * from Enrollment;
  • 9. Set MySQL JDBC Driver
    • An easy way
      • Copy slideookmysqljdbc.jar to C:Program FilesJavajre1.6.0_03libext
      • Try to run the program
    • An alternative way
      • In command line window
      • set classpath=%classpath%;c:slideookmysqljdbc.jar;
      • cd slideook
      • java FindGrade

×