Need sql query to create the table and add data to it from the program. Input (O
ID: 3591127 • Letter: N
Question
Need sql query to create the table and add data to it from the program.
Input (Output xit Create Invoices Write Database Tables Exit Program Add New Customer Add New Course Read Customers Read Courses Commit to Database Customer Panel Course Panel Enter Customer Name Select Course Enter Name Enter Account Number Enter Street Enter City Enter State Enter Zip Select Customer Type Enter Course type Start Date End Date O student O Faculty Government Add New Course Submit Add New Customer submit 8.58 PM ..d 10/9/2017Explanation / Answer
//statements to make database connection
String url="jdbc:mysql://localhost:3306/dbname";
String uname="username";
String pass="password";
Class.forName("com.mysql.jdbc.Driver");
Connection c=(Connection) DriverManager.getConnection(url,uname,pass);
Statement s=c.createStatement();
//queries to create table
createTableSQL1 = "CREATE TABLE Customers
(
AccountNO int PRIMARY KEY,
Name varchar(50),
Type varchar(50),
State varchar(50),
City vrachar(50),
Zip int
)";
createTableSQL2 = "CREATE TABLE Course
(
CustomerName varchar(50),
Title varchar(50),
Type varchar(50),
Instructor varchar(50),
StartDate date,
EndDate date,
Price float
)";
s.execute(createTableSQL);
//queries to insert data
s.executeUpdate("INSERT INTO `Customers`(AccountNO,Name,Type,State,City,Zip) VALUE ('"+variable1+"','"+variable2+"','"+variable3+"',"+variable4+","+variable5+",'"+variable6+"')");
(Please mention comment if any other query needed)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.