W11 Programming Assignments 1
Due date on 2026-10-08, 23:59 IST
Complete Program
//Import required packages
// Hint: USE static import
import java.sql.*;
import java.lang.*;
import static java.sql.DriverManager.*;
public class W11_P1 {
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");
// Connection using static import method from DriverManager
conn = getConnection(DB_URL);
System.out.println(conn.isValid(1));
conn.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.
Evaluation Results
Note: These tests may not be considered while scoring.
Due date on 2026-10-08, 23:59 IST
Complete Program
import java.sql.*;
import java.util.Scanner;
public class W11_P2 {
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);
System.out.print(conn.isValid(1));
conn.close();
} catch (Exception e) {
System.out.println(e);
}
}
}This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.
Evaluation Results
Note: These tests may not be considered while scoring.
Due date on 2026-10-08, 23:59 IST
Complete Program
// Fix bugs in the code, DO NOT ADD or DELETE ANY LINE
import java.sql.*; // All sql classes are imported
import java.lang.*; // Semicolon is added
import java.util.Scanner;
public class W11_P3 {
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");
// Connection object is created
conn = DriverManager.getConnection(DB_URL); // Add this line
conn.close(); // correction here
System.out.print(conn.isClosed());
// Hidden code completes try-catch block
} catch (Exception e) {
System.out.println(e);
}
}
}
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.
Evaluation Results
Note: These tests may not be considered while scoring.
Due date on 2026-10-08, 23:59 IST
Complete Program
import java.sql.*;
import java.lang.*;
public class W11_P4 {
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();
String CREATE_TABLE_SQL="CREATE TABLE STUDENTS (UID INT, Name VARCHAR(45), Roll VARCHAR(12), Age INT);";
// Execute the statement containing SQL command
stmt.executeUpdate(CREATE_TABLE_SQL);
}
catch(Exception e){ System.out.println(e);}
}
}
Code Snippet to Paste in the Editor
String CREATE_TABLE_SQL="CREATE TABLE STUDENTS (UID INT, Name VARCHAR(45), Roll VARCHAR(12), Age INT);";
// Execute the statement containing SQL command
stmt.executeUpdate(CREATE_TABLE_SQL);This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.
Evaluation Results
Note: These tests may not be considered while scoring.
Due date on 2026-10-08, 23:59 IST
Complete Program
import java.sql.*;
import java.lang.*;
public class W11_P5 {
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();
// Write the SQL command to rename a table
String alter="ALTER TABLE STUDENTS RENAME TO GRADUATES;";
// Execute the SQL command
stmt.executeUpdate(alter);
} catch(Exception e){ System.out.println(e);}
}
}
Code Snippet to Paste in the Editor
// Write the SQL command to rename a table
String alter="ALTER TABLE STUDENTS RENAME TO GRADUATES;";
// Execute the SQL command
stmt.executeUpdate(alter);This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.
Evaluation Results
Note: These tests may not be considered while scoring.
No comments