开发者

How to Create a MySql Database using JDBC

开发者 https://www.devze.com 2022-12-21 22:44 出处:网络
Can we create a new MySQL database( not a table, I want a new database) from java code ? I have searched the internet and I get code only for connecting with existing mysql databases. Can i create a n

Can we create a new MySQL database( not a table, I want a new database) from java code ? I have searched the internet and I get code only for connecting with existing mysql databases. Can i create a new database at run time using java code.

plea开发者_StackOverflow中文版se help


In your connection string omit a database name and then execute Create database command.

Connection String: jdbc:mysql://localhost

Create Database Syntax : stm.executeUpdate("CREATE DATABASE dbname")


Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1";
Connection conn = DriverManager.getConnection(url);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号