赞
踩
示例代码如下:
public static void main(String[] args) { //新版MySQL驱动,兼容老版本 String driver = "com.mysql.cj.jdbc.Driver"; String url = "jdbc:mysql://localhost:3308/"; String username = "root"; String password = "fpl1116"; try { Class.forName(driver); Connection conn = DriverManager.getConnection(url, username, password); Statement st = conn.createStatement(); //在服务器建立10个数据库 for (int i = 0; i < 10; i++) { st.executeUpdate(String.format("create database if not exists userdb%d", i)); } } catch (Exception e) { e.printStackTrace(); } }
运行结果如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。