Preview

JDBC using MySQL

Better Essays
Open Document
Open Document
10167 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
JDBC using MySQL
//////////////////////////////////////////////////////////////////////////////////////////////////
CREATE DATABASE Company;

USE Company;

CREATE TABLE Customer( id VARCHAR(6) NOT NULL, name VARCHAR(30), address VARCHAR(30), salary DECIMAL(10,2), CONSTRAINT PRIMARY KEY (id)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE Orders( id VARCHAR(6) NOT NULL, date DATE, customerId VARCHAR(6) NOT NULL, CONSTRAINT PRIMARY KEY (id), CONSTRAINT FOREIGN KEY(customerId) REFERENCES Customer(id)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE Item( code VARCHAR(6) NOT NULL, description VARCHAR(50), unitPrice DECIMAL(8,2), qtyOnHand INT(5), CONSTRAINT PRIMARY KEY (code)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE OrderDetail( orderId VARCHAR(6) NOT NULL, itemCode VARCHAR(6) NOT NULL, qty INT(11), unitPrice DECIMAL(8,2), CONSTRAINT PRIMARY KEY (orderId,itemCode), CONSTRAINT FOREIGN KEY (orderId) REFERENCES Orders(id), CONSTRAINT FOREIGN KEY (itemCode) REFERENCES Item(code)
)ENGINE=InnoDB DEFAULT CHARSET=latin1;

/////////////////////////////////////////////////////////////////////////
INSERT INTO Customer VALUES( 'C001 ', 'Danapala ', 'Panadura ',54000);
INSERT INTO Customer VALUES( 'C002 ', 'Gunapala ', 'Matara ',44000);
INSERT INTO Customer VALUES( 'C003 ', 'Somapala ', 'Galle ',82000);
INSERT INTO Customer VALUES( 'C004 ', 'Siripala ', 'Galle ',24000);
INSERT INTO Customer VALUES( 'C005 ', 'Jinadasa ', 'Panadura ',94000);
INSERT INTO Customer VALUES( 'C006 ', 'Sepalika ', 'Kalutara ',58000);
INSERT INTO Customer VALUES( 'C007 ', 'Jinasena ', 'Ambalangoda ',51000);
INSERT INTO Customer VALUES( 'C008 ', 'Somadasa ', 'Baddegama ',34000);
INSERT INTO Customer VALUES( 'C009 ', 'Danasiri ', 'Moratuwa ',29000);
INSERT INTO Customer VALUES( 'C010 ', 'Somasiri ', 'Kandy ',64000);

///////////////////////////////////////////////////////////////////////
INSERT INTO Item VALUES( 'P001 ', 'Keerisamba



References: ///////////////////////////////////////////////////////////////////////// INSERT INTO Customer VALUES( 'C001 ', 'Danapala ', 'Panadura ',54000); INSERT INTO Customer VALUES( 'C002 ', 'Gunapala ', 'Matara ',44000); INSERT INTO Customer VALUES( 'C003 ', 'Somapala ', 'Galle ',82000); INSERT INTO Customer VALUES( 'C004 ', 'Siripala ', 'Galle ',24000); INSERT INTO Customer VALUES( 'C005 ', 'Jinadasa ', 'Panadura ',94000); INSERT INTO Customer VALUES( 'C006 ', 'Sepalika ', 'Kalutara ',58000); INSERT INTO Customer VALUES( 'C007 ', 'Jinasena ', 'Ambalangoda ',51000); INSERT INTO Customer VALUES( 'C008 ', 'Somadasa ', 'Baddegama ',34000); INSERT INTO Customer VALUES( 'C009 ', 'Danasiri ', 'Moratuwa ',29000); INSERT INTO Customer VALUES( 'C010 ', 'Somasiri ', 'Kandy ',64000); /////////////////////////////////////////////////////////////////////// INSERT INTO Item VALUES( 'P001 ', 'Keerisamba Retail ',105.00,3000); INSERT INTO Item VALUES( 'P002 ', 'Keerisamba 5Kg ',525.00,200); INSERT INTO Item VALUES( 'P005 ', 'Red Raw Rice ',60.00,6000); INSERT INTO Item VALUES( 'P006 ', 'Red Raw Rice 10Kg Pack ',560.00,300); =============== INSERT INTO Customer VALUES( 'C001 ', 'Danapala ', 'Panadura ',54000); String sql="Insert into Customer values( 'C001 ', 'Danapala ', 'Matara ',50000)"; String sql="Insert into Customer values( 'C001 ', 'Danapala ', 'Matara ',50000)"; stm.executeUpdate(sql);

You May Also Find These Documents Helpful

  • Satisfactory Essays

    B. Helga can check the field or type in the data in the pivot table.…

    • 985 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Hiredate DATE No No Job VARCHAR2(15) No No Mgrno number(4) no no yes ( to emp.empno) Salary number(8,2) no no Comm number(8,2) no no Deptno number(2) no no yes ( to…

    • 1169 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    Pos 410 Week Dq

    • 703 Words
    • 5 Pages

    * 3.4 Write a SQL query that joins two tables in the example database and uses BETWEEN…

    • 703 Words
    • 5 Pages
    Powerful Essays
  • Satisfactory Essays

    SQL Queries

    • 423 Words
    • 2 Pages

    Given the table information above, if you were asked to create an Access query that showed the Student Name and Grade for all students taking a class in Room H201, what tables would you need and how would you link them together?…

    • 423 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    * In an inventory order system, you don't want an order to be deleted if there are inventory order items, or those items will be orphaned.…

    • 579 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    After creating the database schema, use Insert, Update, and Delete commands to populate the tables with the following information. Notice that the values for the primary key columns (ClassId in the Classes table, AdvisorId in the Advisors table and StudentId in the Students table) are not listed. It is assumed that they will be “Identity” or “Auto-increment” columns and the DBMS will determine the proper identity value when the row is inserted.…

    • 2177 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    Sql Database Language

    • 1101 Words
    • 5 Pages

    Get the offering, the course number, and the course description of SUMMER 2010 offerings without an assigned instructor.…

    • 1101 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    Database Environment

    • 1121 Words
    • 5 Pages

    A database defines a structure for storing information and it collects information that is organized in such a way that a computer program can quickly select desired pieces of data. A database can also be thought of as an electronic filing system. Data and information are extracted from a database by creating a query and then submitting it to the query database management system (DBMS) and it is posed in a language that only the DBMS can understand. The query can be in the form of a question or just a keyword and once these queries run against the database, it will find a matching record (Reynolds, 2004) .…

    • 1121 Words
    • 5 Pages
    Powerful Essays
  • Powerful Essays

    Mssql vs Mysql

    • 1764 Words
    • 8 Pages

    An important aspect of database development is how to access your data using standard protocols. Both MySql and MSSql Server do a good job of supporting all major protocols for accessing their respective databases. MYsql and MSsql are the two Sql Servers that are commonly used today by the programmers and other IT people. These two are the most popular choices when considering a utility for data management. Both are efficient at keeping the data organized and readily available through a user interface but they differ in many drastic areas. Both are freely accessible for running small or big databases. Even they do have the same functionality; the existence of differences of the two known Sql Servers will still be a question to the users and to the future users. The major differences of this two will include the licensing costs, performance, and security.…

    • 1764 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    DBMS is a collection of programs that manages the database structure and controls access to the data stored in the database. It helps manage the cabinet’s contents (pg. 7)…

    • 1011 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    Oracle Support

    • 1407 Words
    • 7 Pages

    1. By how much time can Configuration Support Manager reduce time to log a Service Request?…

    • 1407 Words
    • 7 Pages
    Powerful Essays
  • Good Essays

    DATABASE SQL

    • 592 Words
    • 2 Pages

    A database is an organized collection of data. The data is typically organized to model aspects of reality in a way that supports processes requiring information.…

    • 592 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    DBMS

    • 3523 Words
    • 15 Pages

    Structural metadata is about the design and specification of data structures and is more properly called "data about the containers of data".…

    • 3523 Words
    • 15 Pages
    Powerful Essays
  • Satisfactory Essays

    access tutorial

    • 52738 Words
    • 211 Pages

    Microsoft-Access Tutorial Soren Lauesen E-mail: slauesen@itu.dk Version 2.4b: July 2011 Contents 1. The hotel system................................................... 4 2. Creating a database ............................................. 6 2.1 Create a database in Access ............................. 6 2.2 Create more tables ......................................... 10 2.3 Create relationships ....................................... 12 2.4 Look-up fields, enumeration type .................. 14 2.5 Dealing with trees and networks.................... 16 3. Access-based user interfaces ............................. 18 3.1 Forms and simple controls............................. 18 3.1.1 Text box, label and command button...... 18 3.1.2 Adjusting the controls............................. 20 3.1.3 Cleaning up the form .............................. 20 3.1.4 Shortcut keys for the user .......................…

    • 52738 Words
    • 211 Pages
    Satisfactory Essays
  • Good Essays

    Java Programming Questions

    • 1971 Words
    • 8 Pages

    Using a case statement, write a shell program to read a command (eg., who, cal, ls, ps) from the user and execute it.…

    • 1971 Words
    • 8 Pages
    Good Essays

Related Topics