0% found this document useful (0 votes)
867 views2 pages

Nptel Week10 Assignment Solutions

The document discusses 5 programming assignments for Week 10. It includes code snippets for connecting to a database, checking if a connection is closed, importing SQL and Java classes, creating a table, and renaming a table. The assignments cover basic Java database programming tasks like establishing a connection, executing SQL statements, and managing database objects.

Uploaded by

Aman Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
867 views2 pages

Nptel Week10 Assignment Solutions

The document discusses 5 programming assignments for Week 10. It includes code snippets for connecting to a database, checking if a connection is closed, importing SQL and Java classes, creating a table, and renaming a table. The assignments cover basic Java database programming tasks like establishing a connection, executing SQL statements, and managing database objects.

Uploaded by

Aman Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Week 10 : Programming Assignment 1

import java.sql.*;

import java.lang.*;

Week 10 : Programming Assignment 2

conn= DriverManager.getConnection(DB_URL);

if(conn.isClosed())

System.out.print("false");

else

System.out.print("true");

Week 10 : Programming Assignment 3

import java.sql.*; // All sql classes are imported

import java.lang.*; // Semicolon is added

import java.util.Scanner;

public class Question103 {

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

conn.close();

System.out.print(conn.isClosed());

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

Week 10 : Programming Assignment 4

String CREATE_TABLE_SQL="CREATE TABLE players (UID INT, First_Name


VARCHAR(45), Last_Name VARCHAR(45), Age INT);";

stmt.executeUpdate(CREATE_TABLE_SQL);

Week 10 : Programming Assignment 5

String alter="ALTER TABLE players RENAME TO sports;";

stmt.executeUpdate(alter);

You might also like