Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 出生日期在数据库中存储空值_Java_Mysql_Jsp_Servlets - Fatal编程技术网

Java 出生日期在数据库中存储空值

Java 出生日期在数据库中存储空值,java,mysql,jsp,servlets,Java,Mysql,Jsp,Servlets,我正在尝试在数据库中插入出生数据。但它不在数据库中只存储null值 index.jsp <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.

我正在尝试在数据库中插入出生数据。但它不在
数据库中只存储
null

index.jsp

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>Country State List</title>
        <script src="countries.js"></script>
    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>

  <body>
    <form action="RegisterServlet" method="post">
   First Name:<input type="text" name="fname"></br>
   Last  Name:<input type="text" name="lname"></br>

         SSN :<input type="text" name="ssn"></br>
      Country:<select id="country" name ="country"></select>
            <br />
        State: <select name ="state" id ="state"></select>

            <br/><br />

            <script language="javascript">
                populateCountries("country", "state");

            </script>
        Date of birth: <input type="date"  name= "dob"/>    
 <input type="submit" value ="register">
    </form>


    </form>
  </body>
</html>
我的数据库表员工

+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| fname   | varchar(20) | YES  |     | NULL    |       |
| lname   | varchar(20) | YES  |     | NULL    |       |
| ssn     | int(20)     | YES  |     | NULL    |       |
| country | varchar(20) | YES  |     | NULL    |       |
| state   | varchar(20) | YES  |     | NULL    |       |
| dob     | varchar(50) | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+

table:
+--------+-------+--------+-----------+------------------+------------+
| fname  | lname | ssn    | country   | state            | dob        |
+--------+-------+--------+-----------+------------------+------------+
| srinu  | sk    | 741258 | India     | Telangana        | NULL       |
| naseer | sk    |   5555 | India     | Telangana        | NULL       |
| vamshi | sh    |   4444 | Indonesia | Bengkulu         | NULL       |
| vishal | kl    |   1111 | India     | Telangana        | NULL       |
| manasa | kx    |   7777 | Angola    | Bengo            | NULL       |
| pavani | pa    |      0 | Antartica | Antartica        | NULL       |
| ravi   | ra    |   1234 | Angola    | Andorra la Vella | NULL       |
| NULL   | NULL  |   NULL | NULL      | NULL             | 18-11-1995 |
| NULL   | NULL  |   NULL | NULL      | NULL             | NULL       |
| NULL   | NULL  |   NULL | NULL      | NULL             | NULL       |
+--------+-------+--------+-----------+------------------+------------+

您是否在servlet中成功接收到dob?haa但将空值存储为字符串,您接收到的dob未转换为日期,如果字符串正常,则将输入类型设置为文本。它仍然存储空值,更改为txt
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| fname   | varchar(20) | YES  |     | NULL    |       |
| lname   | varchar(20) | YES  |     | NULL    |       |
| ssn     | int(20)     | YES  |     | NULL    |       |
| country | varchar(20) | YES  |     | NULL    |       |
| state   | varchar(20) | YES  |     | NULL    |       |
| dob     | varchar(50) | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+

table:
+--------+-------+--------+-----------+------------------+------------+
| fname  | lname | ssn    | country   | state            | dob        |
+--------+-------+--------+-----------+------------------+------------+
| srinu  | sk    | 741258 | India     | Telangana        | NULL       |
| naseer | sk    |   5555 | India     | Telangana        | NULL       |
| vamshi | sh    |   4444 | Indonesia | Bengkulu         | NULL       |
| vishal | kl    |   1111 | India     | Telangana        | NULL       |
| manasa | kx    |   7777 | Angola    | Bengo            | NULL       |
| pavani | pa    |      0 | Antartica | Antartica        | NULL       |
| ravi   | ra    |   1234 | Angola    | Andorra la Vella | NULL       |
| NULL   | NULL  |   NULL | NULL      | NULL             | 18-11-1995 |
| NULL   | NULL  |   NULL | NULL      | NULL             | NULL       |
| NULL   | NULL  |   NULL | NULL      | NULL             | NULL       |
+--------+-------+--------+-----------+------------------+------------+