creating a database in mysql from java

前端 未结 7 1914
情深已故
情深已故 2020-12-30 12:06

Could you help with this problem.

I\'m trying to create and then use a database called TIGER.

I have no problem if I create the database in MySQL and it runs

相关标签:
7条回答
  • 2020-12-30 13:00

    The easy approach to problem is :

    package Database;
    import java.sql.*;
    
    public class Database {
    
     public static void main(String[] args) {
        final  String URl = "JDBC:mysql:/localhost:3306/info";
        final  String id = "root";
        final  String  password = "";
    
        try
        {
            Connection con1 = DriverManager.getConnection(URl,id,password);
            Statement s1 = con1.createStatement();
            String s = "CREATE DATABASE CLASSIFIED";
            s1.executeUpdate(s);
    
        }
        catch(SQLException err)
        {
            System.out.println(err.getMessage());
        }
    
     }
    
    }
    
    0 讨论(0)
提交回复
热议问题