0
try{
     Class.forName("com.mysql.jdbc.Driver").newInstance();

     try{
            try (Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/crm","root","")) {
                PreparedStatement pstmt=con.prepareStatement("INSERT INTO user_tbl (email, password, role) VALUES (?,?,?) ");

                pstmt.setString(1,"amandhakal79@gmail.com");
                pstmt.setString(2,"amandhakal79@gmail.com");
                pstmt.setString(3,"Engineer");

                int z=pstmt.executeUpdate();

                }
            } catch(SQLException exception1) {
                System.out.println("Caught an exception "+exception1);
            }
      } catch(ClassNotFoundException | IllegalAccessException | InstantiationException e) {
          System.out.println("No driver found "+e);
    }

数据库中一切正常。即有数据库以及具有相同列的表。但是,这段代码不起作用。可能是什么问题?

4

0 回答 0