intellij mysql如何连接控制器类?

fgw7neuy  于 2021-06-17  发布在  Mysql
关注(0)|答案(0)|浏览(223)

我是intellij的新手,刚从eclipse转行。我有几个问题:我去了项目设置,库和添加mysql连接。在modules和dependencies下,我还有mysql连接器。我在eclipse中尝试了以下代码:

String dbUsername = "root";
    String dbPassword = "12frimyux09";
    String URL = "127.0.0.1";
    String port = "3306";
    String dbName = "university";
    //Connection con;
    String SQL;
    String dbURL = "jdbc:mysql://" + URL + ":" + port + "/" + dbName + "?verifyServerCertificate=false&useJDBCComplaintTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
    Properties property  = new Properties();

        property.setProperty ("user", dbUsername);
        property.setProperty("password", dbPassword);
        property.setProperty("useSSL", "false");
        property.setProperty("autoReconnect", "true");

        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection con = DriverManager.getConnection (dbURL, property);

工作得很好,但与intellij不兼容(我将代码放在控制器类中),甚至尝试使用try and catch,仍然没有成功,我得到以下错误。1在eclipse中,当我使用integer.parseint时,我得到了很多建议,但是与intellij一起,我得到了错误和没有建议,尝试了cntrl space和cntrl p,还转到了文件、设置,代码完成并设置参数信息下的所有刻度,我做错了什么,为什么intellji没有完成我???

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题