从javaweb项目学习

Posted 山海皆可平

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从javaweb项目学习相关的知识,希望对你有一定的参考价值。

1.sql语句

在insert语句中需要插入查询出来的值。 Insert into a (a1,a2,a3) values (1,select num from b where id=1,3) 这样写就出现了“在此上下文中不允许使用子查询。只允许使用标量表达式。”这个错误

可以这样: insert into a (a1,a2,a3) select 1,num,3 from b where id=1 即可解决问题.

 

2.如何将string类型转化为sql.date(util.date与sql.date不能直接转化)

        if (year != null && month != null && day != null) {            
            String birthday = year + "-" + month + "-" + day;
            SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");  
            java.util.Date d = null;  
            try {  
                d = format.parse(birthday);  
            } catch (Exception e) {  
                e.printStackTrace();  
            }  
            java.sql.Date date = new java.sql.Date(d.getTime());
            user.setuBirthday(date);

 

3.除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效。

 

以上是关于从javaweb项目学习的主要内容,如果未能解决你的问题,请参考以下文章

走进JavaWeb技术世界12:从手动编译打包到项目构建工具Maven

从0开始创建JavaWeb(JSP)项目(普通版)

从0开始创建JavaWeb(JSP)项目(普通版)

动态SQL基础概念复习(Javaweb作业5)

学习——JavaWeb02:修改端口和web项目发布

Javaweb项目框架搭建-准备篇