Java错误“ com.mysql.cj.exceptions.WrongArgumentException:格式错误的数据库URL,无法解析主URL部分。”

问题描述 投票:0回答:1
public void actionPerformed(ActionEvent arg0) {
     String departurecity = depcity.getText();
        String depdate = dt.getText();
        String arrivalcity = ac.getText();
        String arrivaldate = dtar.getText();
        String cabinclass = ccc.getText();
        String seats = sts.getText();
        String price = prc.getText();

        try {
            Connection connection = (Connection) DriverManager.getConnection("jdbc:mysql:‪//localhost:8080/airblue", "root", "");
            java.sql.Statement st = connection.createStatement();
            String query = "INSERT INTO flight values('" + departurecity + "','" + depdate + "','" + arrivalcity + "','" +
                    arrivaldate + "','" +cabinclass + "','" + seats +"','"+price+ "')";

            Statement sta = (Statement) ((java.sql.Connection) connection).createStatement();
            int x = ((java.sql.Statement) sta).executeUpdate(query);

                JOptionPane.showMessageDialog(btnNewButton,
                    "done");

            connection.close();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
});

这是我的连接代码的一小部分,我尝试了许多解决方案,但没有一个对我有任何解决此问题的解决方案?

java mysql jdbc
1个回答
1
投票
mysql:‪//

在此处检查您的数据库URL,您将自己看到:https://www.soscisurvey.de/tools/view-chars.php

也许手动键入该部分。    
© www.soinside.com 2019 - 2024. All rights reserved.