java - 列不能为 Null
问题描述
我有一个错误说:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:列“课程名称”不能为空`
当我将它设置为 Nullable 列时,它将我输入的任何文本存储为 null,我尝试了许多排序规则但没有工作
这是代码:
String coursename = request.getParameter("name");
String duration = request.getParameter("duration");
Connection con;
PreparedStatement pst;
Class.forName("com.mysql.jdbc.Driver");
con =DriverManager.getConnection("jdbc:mysql://localhost/studentms","root","");
pst = con.prepareStatement("insert into course(coursename,duration)values(?,?)");
pst.setString(1, coursename);
pst.setString(2, duration);
pst.executeUpdate();
out.println("Added sucessfully");
解决方案
推荐阅读
- angular - 角度路由:延迟加载后,页面重定向到默认路由
- javascript - 尝试使用本地存储来跟踪用户访问过的页面,不工作
- python - 如何修复 Google Cloud Endpoints 上的 OpenAPI 文档生成问题?
- php - OCI-Lob 类的对象无法转换为字符串
- python - 如何将此秒表代码添加到我的游戏中?
- jquery - 使用 mCustomScrollbar 一次滚动一个元素
- html - 新部分高于上一部分
- jquery - 在 page1 中显示模态内容 page2[关闭]
- android - 如何在没有密钥的情况下解析 Json 数组中的 Json 数组
- php - PHP 警告:标头已发送