- String url = "jdbc:mysql://localhost/mysql";
- String driver = "com.mysql.jdbc.Driver";
- try{
- Class.forName(driver);
- }catch(Exception e){
- System.out.println("无法加载驱动");
- }
- try {
- Connection con = DriverManager.getConnection(url,"root","");
- if(!con.isClosed())
- System.out.println("success");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
MySQL连接是否成功
最新推荐文章于 2021-02-28 08:00:46 发布