更新时间:2023-11-10 GMT+08:00
分享

创建数据库

以Java JDBC方式执行SQL语句在集群中创建dbName变量对应的数据库。
String createDatabaseSql = "create database if not exists " + dbName;
public static void execDDL(Connection connection, String sql) throws Exception {
   try (PreparedStatement statement = connection.prepareStatement(sql)) {
      statement.execute();
   } catch (Exception e) {
      logger.error("Execute sql {} failed.", sql, e);
      throw new Exception(e);
   }
}
分享:

    相关文档

    相关产品