用了eclipse也有几个月了,可是我没有系统的去学习过它的使用,都是遇到什么问题才想起去解决什么问题。
这两天,我在机器上运行learndiary_login老是到一个地方就停住不动了。我搞不懂是什么原因。把所有的地方都检查了。今天中午,我偶然发现在程序行的左边有一个小蓝点,把鼠标放上去一看,原来是个断点。我突然恍然大悟,我不知无意中在程序行的左边双击了一下,于是就加了一个测试断点。当然,程序运行到这里就停住了。
看来,我还是要系统的把eclipse的基本操作学习一下了。否则尽犯这种低级错误,浪费时间,浪费精力。
作者:littlebat
需要系统的设计一下违例系统
违例即异常,正确的处理它有利于程序的健壮性和用户的友好性,学习日记现有的设计中没有系统的考虑这个问题。当把现在做的登录系统初步完成后,需要认真的考虑一下违例处理系统。系统的设计以实用为原则。不必追求复杂系统的设计原则。
以后的新系统还要把这个认真的设计一下。
在ant中使用junit测试
今天,ppig提交的junit,strutstestcase测试类的同时,修改了ant的build.xml,里面包含自动测试的脚本,可是最后一个运行测试的任务总是通不过,报告:
Buildfile: D:\learndiary\find_a_way\login\build.xml
compile:
compiletests:
runtests:
[junit] BUILD FAILED: file:D:/learndiary/find_a_way/login/build.xml:111: Could not create task or type of type: junit.
Ant could not find the task or a class this task relies upon.
This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'junit'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and optional.jar is absent
Fix: look for optional.jar in ANT_HOME/lib, download if needed
- The task was not built into optional.jar as dependent
libraries were not found at build time.
Fix: look in the JAR to verify, then rebuild with the needed
libraries, or download a release version from apache.org
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.
Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath
Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.
Total time: 1 second
解决办法:在环境变量的classpath中加上junit.jar的路径;或者在eclipse2.1环境中run ant->classpath->Runtime classpath中加上junit.jar的路径。
第一次开家长会
成都来的教育专家张老师,讲幼儿的教育问题。
总结一下:
1、与孩子愉快的相处18年(因为这18年孩子跟孩子距离最近);
2、多赏识孩子(赏识教育法);
3、孩子的无理要求坚决不与满足;
4、特别的请教孩子能不能体罚孩子:
总体是不应该,应该在平时的教育中给孩子约定,比如:吃饭前孩子在玩玩具,提前15分钟就通知她两次把玩具收好,第三次正要吃饭时才去检查。如果没有遵守约定应该严厉的批评;要在孩子面前树立家长的威信;
5、滥用批评和滥用表扬对孩子的成长都是不利的。
6、世界教科文组织定义的教育:
第一层次:做一个有尊严的人;
第二层次:实现自己的愿望;
第三层次:有益于社区和组织;
思想:主观利已,客观利人。
7、不要总拿自己的孩子跟别人的孩子比较,每个孩子都有自己的优点和缺点。
代码必须写一点,测试一点,测试代码应该预先编写
前两天,想把全部功能代码写出来再来测试。可是,仅仅写了一部分,就发现要找到问题十分困难。
必须写一点,测试一点,一部分一部分的保证正确性。
Setup logging with Log4j using Struts 1.2.4 on Tomcat 4.1.3
在用中文搜索不到你想要东西时(http://www.learndiary.com/disDiaryContentAction.do?searchDiaryID=1343&goalID=1343&naviStr=a10a60a0167),就用英文吧,有时给你十分满意的答案。昨天,花了许多时间来搜struts下log4j的使用,找到的答案还是没有能解决问题。今天,就用“struts log4j”两个关键字,一下就找到了我要找的东西:)
转自:http://www.mobilefish.com/developer/struts/struts_quickguide_log4j.html
Setup logging with Log4j using Struts 1.2.4 on Tomcat 4.1.3.
Information:
none
Operating system used:
Windows XP Home Edition Version 5.1 SP 2
Software prerequisites:
Log4j 1.2.9
Struts 1.2.4
Tomcat 4.1.3
Procedure:
Download and unzip Log4j.
In the unzipped log4j directory copy file C:\Tools\logging-log4j-1.2.9\dist\lib\log4j-1.2.9.jar to your Struts project: <my_project>\WEB-INF\lib\log4j-1.2.9.jar
Create a log4j.properties file.
As an example you can put the following lines in the log4j.properties file:
log4j.rootLogger=ERROR, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%5p] %d{mm:ss} (%F:%M:%L)%n%m%n%n
Remark: The ConversionPattern creates the following message:
[ERROR] 02:44 (com.mobilefish.DemoAction execute:95)
This is my message.
Put the log4j.properties file in the following location:
<my_project>\WEB-INF\classes\log4j.properties
Note: In some situations the log4j.properties can not be located by the application server. To find out if this is the case set the -Dlog4j.debug=true.
In the quick guide "Loading the log4j.properties file" serveral solutions are mentioned how to solve this problem.
Add the following lines in your Java code:
package com.mobilefish;
// Please note the following: Struts 1.2.4 uses commons-logging
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class DemoAction extends Action {
private static Log log = LogFactory.getLog("com.mobilefish.DemoAction");
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
log.debug("This is my debug message.");
log.info("This is my info message.");
log.warn("This is my warn message.");
log.error("This is my error message.");
log.fatal("This is my fatal message.");
}
}
Start the application server and run your web application.
Because log4j.rootLogger=ERROR (see log4j.properties file), the following messages are displayed in the console:
[ERROR] 23:35 (DemoAction.java:execute:69)
This is my error message.
[FATAL] 23:35 (DemoAction.java:execute:69)
This is my fatal message.
Note 1. Loggers can be assigned to the following ORDERD levels:
ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF
Note 2. To enable all log messages:
log4j.rootLogger=ALL
Be warned: the struts code and your web applications log messages are logged.
Note 3. To disable all log messages:
log4j.rootLogger=OFF
知识的快速获取的必要性
一个非常简单的小问题,由于我们没有经验,往往搞得焦头烂额。而在已经经历过的人的口里,也许就是几个字的工夫。所以,不要对提问的朋友的不起眼的小问题哧之以鼻。
我们提倡钻研精神,更提倡互助和共享的精神。
你有两个苹果,我有两个梨,我们互相交换一下,两个人都吃到了苹果和梨。
凡事多检查自己
我们总喜欢站在自己的角度思考问题,争执问题。这就是矛盾的源泉。
这几天,家庭环境很不顺心,今天又跟家人争吵,一气之下,不到上班时间就跑到单位上来了。
静下心来想想,凡事要多检查自己,自己检查完了,再去检查对方。我想,只有这样,才是解决问题的办法。
学习日记精神,开发小组精神
学习日记精神:
1、学习到永远;
2、不怕犯错,不怕面对错,不怕改错;
开发小组精神:
1、做好每一个小事和细节;
2、团结就是力量;
3、乐于其中;
4、勇于提交代码;
5、快速提交,快速迭代;
6、小增量,密集版本发布;
mysql从4.11开始支持子查询(转帖)
我用的mysql4.0.14,试验可以在插入语句中使用子查询,如:
insert into learndiary_login.user
(SELECT userID,userName,psd,email
FROM websitedb.user
where userid<30)
但是其它的子查询不行:
select * from
(select userID*2 AS u1,userName as u2,
psd as u3,email as u4) as t
where u1>50
下面的文章说mysql从4.11开始支持子查询,正文如下:
关于MySQL嵌套查询的技巧 [ 2005-10-11 14:57:12 | 5iuu ]
许多人都觉得MySQL不支持嵌套查询,其实MySQl从4.11版后已经完全支持嵌套查询了,那么下面我举些简单的嵌套查询的例子吧(源程序来自MySQL User Manual):
1. SELECT语句的子查询:
语法: SELECT ... FROM (subquery) AS name ...
先创建一个表:
CREATE TABLE t1 (s1 INT, s2 CHAR(5), s3 FLOAT);
INSERT INTO t1 VALUES (1,'1',1.0);
INSERT INTO t1 VALUES (2,'2',2.0);
我们就可以进行以下的嵌套查询了:
SELECT sb1,sb2,sb3
FROM (SELECT s1 AS sb1, s2 AS sb2, s3*2 AS sb3 FROM t1) AS sb
WHERE sb1 > 1;
结果是: 2, '2', 4.0.
我们知道下面语句是不会得到正确结果的,因为对经过Group by排序的集合进行求均值是不能得到正确答案的:
SELECT AVG(SUM(column1)) FROM t1 GROUP BY column1
所以我们可以通过下面的嵌套查询实现同样的效果:
SELECT AVG(sum_column1)
FROM (SELECT SUM(column1) AS sum_column1
FROM t1 GROUP BY column1) AS t1;
2.行的子查询(Row Subquery):
看下面的例子:
SELECT * FROM t1 WHERE ROW(1,2) = (SELECT column1, column2 FROM t2);
这个查询是返回column1等于column2的结果行。Row函数中的1和2相当于构造参数。想必Blogjava上的同志对这些应该比较清楚,也不去详细介绍了。
3.使用Exist和Not Exist参数
这里的Exist和Not Exist用途及用法和在其他没有什么大的区别,我就简单举几个范例好了:
范例一: SELECT DISTINCT store_type FROM Stores
WHERE EXISTS (SELECT * FROM Cities_Stores
WHERE Cities_Stores.store_type = Stores.store_type);
范例二: SELECT DISTINCT store_type FROM Stores
WHERE NOT EXISTS (SELECT * FROM Cities_Stores
WHERE Cities_Stores.store_type = Stores.store_type);
范例三: 这个例子中嵌套使用了Not Exist语法,稍微注意一下:
SELECT DISTINCT store_type FROM Stores S1
WHERE NOT EXISTS (
SELECT * FROM Cities WHERE NOT EXISTS (
SELECT * FROM Cities_Stores
WHERE Cities_Stores.city = Cities.city
AND Cities_Stores.store_type = Stores.store_type));
4.条件关联关系查询:
解释起来麻烦,直接看例子吧:
SELECT column1 FROM t1 AS x
WHERE x.column1 = (SELECT column1 FROM t2 AS x
WHERE x.column1 = (SELECT column1 FROM t3
WHERE x.column2 = t3.column1));
跟其他数据库做法是一样的。
5.其他使用方法和注意:
除了上面这些还有很多很多,不过就不去细讲了,因为这些跟别的数据库差不多,只是为了给大家一个参考,提提就够了。
SELECT (SELECT s1 FROM t2) FROM t1;
SELECT (SELECT s2 FROM t1);
支持子查询的语法有:SELECT,INSERT,UPDATE,DELETE,SET和DO。
子查询可以使用任何普通查询中使用的关键词:如DINSTINCT,GROUP BY,LIMIT,ORDER BY,UNION,ALL,UNION ALL等。可以使用<,>, <=, >=, =, <>运算符进行比较,也可以使用ANY ,IN和SOME进行集合的匹配。
Tags:MySQL相关日志: JSP连接mysql数据库攻略 [2005-10-21 PM | 日积月累]
引用通告地址 (0):[本站声明:此文章来源于网络,如果未属名,可能此文被转摘多次,原作者不详,如果您认为侵权,请联系我。我将在第一时间按要求做出处理,并消除影响。][字体大小:大 中 小] [ 收藏此页到 365KEY | 博采 | 人人网摘 ]
http://www.GuoBlog.com/trackback.asp?tbID=694
http://www.GuoBlog.com/trackback.asp?tbID=694&CP=GBK