java - 如何使用 servlet 在 mysql 数据库中插入全名?例如 - viraj sharma
问题描述
我的代码是
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter out = resp.getWriter();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/patient", "root", "");
PreparedStatement ps = con.prepareStatement("insert into userdetails(userType) VALUES(?)");
ps.setString(1, req.getParameter("userType"));
int b = ps.executeUpdate();
if (b > 0)
out.print("succes");
else
out.print("fail");
}
当我运行这个程序时,它只插入全名的名字,即viraj
我想存储viraj Sharma
.
解决方案
推荐阅读
- laravel - 解决解析错误:语法错误,意外的“?” 在 helpers.php 第 500 行
- asp.net - 检查用户会话是否处于活动状态
- ember.js - 为什么这个 Ember 组件被创建了两次?
- java - 如何将用文字写成的数字转换为Java中的数字?
- javascript - 换行符 \n 为
- asp.net-mvc - 如何将样式应用于使用 kendo 组合框创建的 li 标签?
- google-oauth - Google OAuth 2.0:刷新 access_token 和新的 refresh_token
- c++ - 为什么我在 AVR 中的中断不能正常工作?
- mysql - 计算两个日期之间的差异
- node.js - Loopback 4:如何结合查询父级和相关模型获取父级数据