数据未使用NetBeans从html表单插入数据库

问题描述

我已经编写了netbeans代码以将数据输入到MysqL数据库中,代码正在正确运行,html表单代码也正确并且运行成功,但是数据未插入数据库

这是html表单名称index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form action="login" method="post">
        <pre>
     <input type ="text"  name ="username" placeholder ="username" />


     <input type ="password"  name ="password"  placeholder = "password"/>


     <input type ="submit"  value="submit" />
        </pre>    
        </form>
</body>
</html>

这是保存为mydb .java的连接文件

public class Mydb {
        Connection con;
        public Connection getCon()
        {
           
        try {
            Class.forName("com.MysqL.jdbc.Driver");
            DriverManager.getConnection("jdbc:MysqL://localhost:1234/mydb","root","5122002");
        } catch (ClassNotFoundException | sqlException ex) {
            Logger.getLogger(Mydb.class.getName()).log(Level.SEVERE,null,ex);
        }
       
        return con;
    }
}

这是保存为login.java的语句sql文件

 String username = request.getParameter("username");
             String password = request.getParameter("password");
             Mydb db = new Mydb();
            Connection con =  db.getCon();
            Statement stmt;
           stmt = con.createStatement();
                   stmt.executeUpdate("insert into user (name,pass) values('"+username+"','"+password+"')");
            out.println("Record Inserted Succesfully");
         
        } catch (sqlException ex) {
            Logger.getLogger(login.class.getName()).log(Level.SEVERE,ex);
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)