Saturday, June 09, 2007
Verifier java code jtextfield
public boolean verify(JComponent comp) {
boolean returnValue;
JTextField textField = (JTextField)comp;
try {
Integer.parseInt(textField.getText());
returnValue = true;
} catch (NumberFormatException e) {
Toolkit.getDefaultToolkit().beep();
returnValue = false;
}
return returnValue;
}
};
textField1.setInputVerifier(verifier);
SQL 语句中 EXISTS 与 IN
exists( select 1 ) --返回真
exists( select 1 where 1=2 ) --返回假
IN 是 在结果集中再查~
唉,由于不清楚就用,干了错事,好在损失不太大,估计不会再忘了~~hoho
Tuesday, June 05, 2007
多表连接删除的sql
--select a.artnr from wsart a ,art b where a.artnr=b.artnr and b.artgrp="";
--delete from wsart where exists (select a.artnr from wsart a ,art b where a.artnr=b.artnr and b.artgrp="") ;
--delete from pris where exists (select a.artnr from pris a ,art b where a.artnr=b.artnr and b.artgrp="") ;
--select a.artnr from inkpris a ,art b where a.artnr=b.artnr and b.artgrp="";
--select * from art where artgrp="";
--delete from inkpris where exists (select a.artnr from inkpris a ,art b where a.artnr=b.artnr and b.artgrp="") ;
delete from art where artgrp="";
Monday, June 04, 2007
java中split的研究
split 方法
将一个字符串分割为子字符串,然后将结果作为字符串数组返回。
stringObj.split([separator,[limit]])
参数
stringObj
必选项。要被分解的 String 对象或文字。该对象不会被 split 方法修改。
separator
可选项。字符串或 正则表达式 对象,它标识了分隔字符串时使用的是一个还是多个字符。如果忽
略该选项,返回包含整个字符串的单一元素数组。
limit
可选项。该值用来限制返回数组中的元素个数。
说明
split 方法的结果是一个字符串数组,在 stingObj 中每个出现 separator 的位置都要进行分解
。separator 不作为任何数组元素的部分返回。
示例1:
public class SplitDemo {
public static String[] ss=new String[20];
public SplitDemo() {
String s = "The rain in Spain falls mainly in the plain.";
// 在每个空格字符处进行分解。
ss = s.split(" ");
}
public static void main(String[] args) {
SplitDemo demo=new SplitDemo();
for(int i=0;i&alt;ss.length;i++)
System.out.println(ss[i]);
}
}
程序结果:
The
rain
in
Spain
falls
mainly
in
the
plain.
示例2:
public class SplitDemo {
public static String[] ss=new String[20];
public SplitDemo() {
String s = "The rain in Spain falls mainly in the plain.";
// 在每个空格字符处进行分解。
ss = s.split(" ",2);
}
public static void main(String[] args) {
SplitDemo demo=new SplitDemo();
for(int i=0;i 小于 ss.length;i++)
System.out.println(ss[i]);
}
}
程序结果:
The
rain in Spain falls mainly in the plain.
示例3:
public class SplitDemo {
public static String[] ss=new String[20];
public SplitDemo() {
String s = "The rain in Spain falls mainly in the plain.";
// 在每个空格字符处进行分解。
ss = s.split(" ",20);
}
public static void main(String[] args) {
SplitDemo demo=new SplitDemo();
for(int i=0;i 小于 ss.length;i++)
System.out.println(ss[i]);
}
程序结果:
The
rain
in
Spain
falls
mainly
in
the
plain.