• Tidak ada hasil yang ditemukan

PDF Java Week 11 : Q1

N/A
N/A
Protected

Academic year: 2024

Membagikan "PDF Java Week 11 : Q1"

Copied!
3
0
0

Teks penuh

(1)

02/07/2020 Programming in Java - Course

https://onlinecourses.nptel.ac.in/noc20_cs08/progassignment?name=181 1/3

Due on 2020-04-20, 23:59 IST

Java Week 11 : Q1

Complete the code segment to insert the following data using prepared statement in the existing table ‘PLAYERS.

Column UID First_Name Last_Name Age

Row 1 1 Ram Gopal 26

Row 2 2 John Mayer 22

Sample Test Cases

Input Output

Test Case 1 1 Ram Gopal 26

2 John Mayer 22

The due date for submitting this assignment has passed.

As per our records you have not submitted this assignment.

Sample solutions (Provided by instructor) X

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » Programming in Java (course)

(https://swayam.gov.in)

(https://swayam.gov.in/nc_details/NPTEL)

[email protected]

Announcements (announcements)

About the Course (https://swayam.gov.in/nd1_noc20_cs08/preview) Ask a Question (forum) Progress (student/home) Mentor (student/mentor)

Course outline

How does an NPTEL online course work?

Week 0 : Week 1 : Week 2 : Week 3 : Week 4 : Week 5 : Week 6 : Week 7 : Week 8 : Week 9 : Week 10 : Week 11 :

import java.sql.*;

import java.lang.*;

public class InsertData {

public static void main(String args[]) { try {

Connection conn = null;

Statement stmt = null;

String DB_URL = "jdbc:sqlite:/tempfs/db";

System.setProperty("org.sqlite.tmpdir", "/tempfs");

// Open a connection

conn = DriverManager.getConnection(DB_URL);

stmt = conn.createStatement();

// The statement containing SQL command to create table "players"

String CREATE_TABLE_SQL="CREATE TABLE players (UID INT, First_Name VARC // Execute the statement containing SQL command

stmt.executeUpdate(CREATE_TABLE_SQL);

String query = " insert into PLAYERS (UID, first_name, last_na 12

34 56 78 109 1112 1314 1516 1718 19

(2)

02/07/2020 Programming in Java - Course

https://onlinecourses.nptel.ac.in/noc20_cs08/progassignment?name=181 2/3

Week 12 : DOWNLOAD VIDEOS

Lecture 51 : JDBC—II (unit?

unit=12&lesson=65) Lecture 52 : JDBC—III (unit?

unit=12&lesson=66) Lecture 53 : Demonstration

—XX (unit?

unit=12&lesson=67) Lecture 54 : Demonstration

—XXI (unit?

unit=12&lesson=68) Lecture 55 : Demonstration

—XXII (unit?

unit=12&lesson=69) Quiz :

Assignment 11 (assessment?

name=186) Java Week 11 : Q1

(/noc20_cs08/progassignment?

name=181) Java Week 11:

Q2

(/noc20_cs08/progassignment?

name=182) Java Week 11 : Q3

(/noc20_cs08/progassignment?

name=183) Java Week 11 : Q4

(/noc20_cs08/progassignment?

name=184) Java Week 11 : Q5

(/noc20_cs08/progassignment?

name=185) Feedback For Week 11 (unit?

unit=12&lesson=196)

PreparedStatement preparedStmt = conn.prepareStatement(quer preparedStmt.setInt (1, 1);

preparedStmt.setString (2, "Ram");

preparedStmt.setString (3, "Gopal");

preparedStmt.setInt(4, 26);

preparedStmt.execute();

preparedStmt.setInt (1, 2);

preparedStmt.setString (2, "John");

preparedStmt.setString (3, "Mayer");

preparedStmt.setInt(4, 22);

preparedStmt.execute();

//Evaluation Portion

ResultSet rs = stmt.executeQuery("SELECT * FROM players;");

while(rs.next())

System.out.println(rs.getInt(1)+" "+rs.getString(2)+"

conn.close();

}catch(Exception e){ System.out.println(e);}

} } 2021 2223 2425 2627 2829 3031 3233 3435 3637 3839 4041 4243 44

(3)

02/07/2020 Programming in Java - Course

https://onlinecourses.nptel.ac.in/noc20_cs08/progassignment?name=181 3/3

Assignment Solution Books

Live Interactive Session

Referensi

Dokumen terkait