Create a database using JDBC

JDBC is not intended to manage databases. It’s used to connect to them. Creating a database is not standard, every DMBS has another way of doing it. If you’re willing to give up portability accross databases, there are ways. For example, in mysql, you can connect to an existing database and invoke executeUpdate to create a new database.

import java.util.*;
import java.sql.*;
public class Main {
   public static void main(String []args) throws Exception {
      try {
         Connection conn = DriverManager.getConnection("jdbc:mysql://", 
         Statement stmt = conn.createStatement();
         stmt.executeUpdate("create database testdb");
      catch(Exception e) {