Here you can find the source of executeCreateDB(String className, String URL, String userName, String password, String dbName)
public static boolean executeCreateDB(String className, String URL, String userName, String password, String dbName) throws SQLException, ClassNotFoundException
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class Main { public static boolean executeCreateDB(String className, String URL, String userName, String password, String dbName) throws SQLException, ClassNotFoundException { Connection con = null;// w w w. j a v a2s . com Statement stat = null; try { con = getConnection(className, URL, userName, password); stat = con.createStatement(); int count = stat.executeUpdate("CREATE DATABASE IF NOT EXISTS " + dbName); return count > 0 ? true : false; } finally { if (stat != null) { stat.close(); } if (con != null) { con.close(); } } } public static Connection getConnection(String className, String URL, String userName, String password) throws ClassNotFoundException, SQLException { Class.forName(className); return DriverManager.getConnection(URL, userName, password); } }