Most Recent
W11 Programming Assignments 1
Due date on 2026-10-08, 23:59 IST
Your last recorded submission was on 2026-09-26, 16:08 IST.
Q.
Write appropriate code to
- import the required package(s) in order to make the program compile and execute successfully.
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.
Public Test Cases
0
true
true
-
Due date on 2026-10-08, 23:59 IST
Your last recorded submission was on 2026-09-26, 16:11 IST.
Q.
Note the following points carefully:
- Name the connection object as conn only.
- Use timeout value as 1.
- Ignore the hidden code.
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.
Public Test Cases
0
true
true
-
Due date on 2026-10-08, 23:59 IST
Your last recorded submission was on 2026-09-26, 16:12 IST.
Q.
Modify and debug the JDBC code to make it execute successfully.
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.
Public Test Cases
0
true
true
-
Due date on 2026-10-08, 23:59 IST
Your last recorded submission was on 2026-09-26, 16:14 IST.
Q.
| Column | UID | Name | Roll | Age |
| Type | Integer | Varchar (45) | Varchar (12) | Integer |
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.
Public Test Cases
1
No. of columns : 4\n Column 1 Name: UID\n Column 1 Type : INT\n Column 2 Name: Name\n Column 2 Type : VARCHAR\n Column 3 Name: Roll\n Column 3 Type : VARCHAR\n Column 4 Name: Age\n Column 5 Type : INT
No. of columns : 4\n Column 1 Name: UID\n Column 1 Type : INT\n Column 2 Name: Name\n Column 2 Type : VARCHAR\n Column 3 Name: Roll\n Column 3 Type : VARCHAR\n Column 4 Name: Age\n Column 5 Type : INT
-
Due date on 2026-10-08, 23:59 IST
Your last recorded submission was on 2026-09-26, 16:16 IST.
Q.
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.
Public Test Cases
1
TABLE NAME = GRADUATES
TABLE NAME = GRADUATES
-










