Programming In Java Week 11: Programming Assignments Jan-Jun 2022

  NPTEL PROGRAMMING ASSIGNMENTS

Week 11 : Programming Assignment 1

Due Date of Submission 2022-04-14, 23:59 IST

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





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();




 

 

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



Week 11 : Programming Assignment 2

Due Date of Submission 2022-04-14, 23:59 IST

Write the required code in order to update the following data in the table ‘PLAYERS.

Column

UID

First_Name

Last_Name

Age

From

1

Ram

Gopal

26

To

1

Rama

Gopala

24



import java.sql.*; import java.lang.*; public class UpdateData {     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");               String query="";                            // Open a connection               conn = DriverManager.getConnection(DB_URL);               stmt = conn.createStatement();



 

 

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



Week 11 : Programming Assignment 3

Due Date of Submission 2022-04-14, 23:59 IST

Write the appropriate code in order to delete the following data in the table ‘PLAYERS.

Column

UID

First_Name

Last_Name

Age

Delete

1

Rama

Gopala

24


import java.sql.*; import java.lang.*; public class DeleteData {     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");               String query="";                            // Open a connection               conn = DriverManager.getConnection(DB_URL);               stmt = conn.createStatement();



 

 

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


Week 11 : Programming Assignment 4

Due Date of Submission 2022-04-14, 23:59 IST

Complete the following program to calculate the average age of the players in the table ‘PLAYERS.

Structure of Table 'PLAYERS' is given below:

Column

UID

First_Name

Last_Name

Age

Type

Integer

Varchar(45)

Varchar(45)

Integer



import java.sql.*; import java.lang.*; public class CalAverage {     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");               String query="";               // Open a connection               conn = DriverManager.getConnection(DB_URL);               stmt = conn.createStatement();



 

 

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




Week 11 : Programming Assignment 5

Due Date of Submission 2022-04-14, 23:59 IST
Complete the code segment to drop the table named ‘PLAYERS.

import java.sql.*; import java.lang.*; public class DropTable {     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");               String query="";                            // Open a connection               conn = DriverManager.getConnection(DB_URL);               stmt = conn.createStatement();


 

 

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

Post a Comment (0)
Previous Post Next Post