-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment5.java
32 lines (29 loc) · 1.2 KB
/
Assignment5.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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();
// The statement containing SQL command to create table "players"
String CREATE_TABLE_SQL="CREATE TABLE players (UID INT, First_Name VARCHAR(45), Last_Name VARCHAR(45), Age INT);";
// Execute the statement containing SQL command
stmt.executeUpdate(CREATE_TABLE_SQL);
// Write the SQL command to drop a table
query = "DROP TABLE players;";
// Execute the SQL command to drop a table
stmt.executeUpdate(query);
ResultSet rs = stmt.executeQuery("SELECT * FROM players;");
ResultSetMetaData rsmd = rs.getMetaData();
System.out.println("No. of columns : " + rsmd.getColumnCount());
conn.close();
}
catch(Exception e){ System.out.println(e);}
}
}