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

    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
  • Good Essays

    1. SELECT e.ename, e.deptno, d.dname, d.deptno FROM dept d LEFT OUTER JOIN emp e ON d.deptno = e.deptno ORDER BY d.deptno; SQL> SELECT e.ename, e.deptno, d.dname, d.deptno 2 FROM dept d 3 LEFT OUTER JOIN emp e 4 ON d.deptno = e.deptno 5 ORDER BY d.deptno; ENAME DEPTNO DNAME DEPTNO ---------- ---------- -------------- ----------…

    • 1542 Words
    • 7 Pages
    Good Essays
  • Good Essays

    Bus 155

    • 658 Words
    • 3 Pages

    You own your own small party supply and rental business. You maintain an Excel list of potential customers and clients who have rented or purchased from you in the past two years. The list includes both physical mailing addresses and e-mail addresses for each person listed. You have a “category“ code to show whether the contact is a client. If they have done business with you, they show a code of “CUST” for customer. If they are potential customers who have not yet purchased or rented from you, they are coded as “PROS” for prospect.…

    • 658 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    drawing511

    • 329 Words
    • 10 Pages

    Name Date 1..* CreateEntry (); getEntryID(); setDate(); updateEntry(); removeEntry(); setEntryName(); 1..* Fitness entry Start Time Duratoin Estimate number of calories burnt Map data Distance Pace/speed getStartTime(); getDuration() getNumberOfCaloriesBurnt(); getMapData(); Measurement entry Meal entry Value of measurement Unt of measurement Type of Meal Calories consumed getValueOfMeasurement(); getUnitOfMeasurement(); getTypeOfMeal(); getcaloriesConsumed(); User Friendship UserID UserFriendID Date 1 0..…

    • 329 Words
    • 10 Pages
    Satisfactory 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
  • Satisfactory Essays

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

    • 985 Words
    • 5 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

    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

    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
  • 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
  • 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

Related Topics