从数据库中提取日期,如何在jsp页面中写日期?

时间:2017-06-22 11:53:33

标签: java html jsp

为什么我无法将从数据库中提取的出生日期写入jsp页面?

<html>
    <body>
         <%@ page import="java.sql.*"%> 
         <%@ page import="java.util.Date"%>
         <%
              Statement stmt=null;
              Connection con=null;
              try {  
                   Class.forName("com.mysql.jdbc.Driver");  
                   con=DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb","root","");   
                   stmt=con.createStatement(); 
              }
              catch(Exception e) {
                   out.write("<br>database connection problem");
              }
              ResultSet rs = null;
              Date dob= null;
              try {
                   rs=stmt.executeQuery("select * from registrar1 where id='"+id+"';");  
                   while(rs.next()) {
                        dob = rs.getDate(3);
                   }
              }
              catch(Exception e) {

              }
         %>
         Date of Birth : <% out.println(dob);  %><br>
     </body>
 </html>

以下错误由eclipse id:

给出

此行找到多个注释:      - dob无法解析为      变量

0 个答案:

没有答案