Skip to content

Commit 9840a94

Browse files
authored
Create JDBCExample4.java
1 parent ce1ec51 commit 9840a94

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

JDBCExample4.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Demonstrating DROP TABLE Command
2+
import java.sql.Connection;
3+
import java.sql.DriverManager;
4+
import java.sql.SQLException;
5+
import java.sql.Statement;
6+
7+
public class JDBCExample4 {
8+
static final String DB_URL = "jdbc:mysql://localhost/TUTORIALSPOINT";
9+
static final String USER = "guest";
10+
static final String PASS = "guest123";
11+
12+
public static void main(String[] args) {
13+
// Open a connection
14+
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
15+
Statement stmt = conn.createStatement();
16+
) {
17+
String sql = "DROP TABLE REGISTRATION";
18+
stmt.executeUpdate(sql);
19+
System.out.println("Table deleted in given database...");
20+
} catch (SQLException e) {
21+
e.printStackTrace();
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)