使用 jdbc 时出现 MySQlSyntaxErrorException

问题描述 投票:0回答:0

MySQLSyntaxErrorException:您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,了解在第 1 行“姓名、注册号、部门、手机号码、电子邮件”值(Effie,1051,CE,123456789,121...)附近使用的正确语法

显示上述异常。 我不知道我做错了什么,但这是代码:

String Create()
    {
        String sql;
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter name:");
        String name = sc.nextLine();
        
        System.out.println("Enter enrl:");
        long enrl = sc.nextInt();
        
        sc.nextLine();
         
        System.out.println("Enter department:");
        String dept = sc.nextLine();
        
        System.out.println("Enter mobile no:");
        String mono = sc.nextLine();
        
        System.out.println("Enter mail:");
        String mail = sc.nextLine();
        
        sql="Insert into stud_details(First Name,Enrol no,Department,Mobile No,Email) values("+name+","+enrl+","+dept+","+mono+","+mail+");";
        return sql; 
    }

上面的代码是在“demo”类中编写的,我在包含 PSVM 的主类中调用了它。我在这里找不到错误,请帮忙。谢谢

java exception jdbc sqlexception mssql-jdbc
© www.soinside.com 2019 - 2024. All rights reserved.