Example: The steps to delete QSAMPLE library ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
1# Use the Work with System Value (WRKSYSVAL) command to remove QSAMPLE from the system value(QUSERLIBL or QSYSLIBL) it is contained in. (The changed system value does not affect the library list of any jobs running.)
1. Enter WRKSYSVAL QUSRLIBL at the i5/OS command line. 2. Press Enter and select option number 2. 3. Remove the QSAMPLE library from the list.
2# Use the Remove Library List Entry (RMVLIBLE) command to remove QSAMPLE from the job's library list.
1. Enter RMVLIBLE QSAMPLE at the i5/OS command line.
3# Use the Work with Object Lock (WRKOBJLCK) command to remove locks on QSAMPLE library if any.
1. Enter WRKOBJLCK OBJ(QSYS/QSAMPLE) OBJTYPE(*LIB) at the i5/OS command line. 2. Remove object locks on QSAMPLE library.
4# Use the Delete Library (DLTLIB) command to delete the library and the objects in the library.
1. Enter DLTLIB QSAMPLE at the i5/OS command line. ××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
The information are mainly refered from IBM infocenter for iSeries.
1、修改/etc/default/locale, 改为:
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"
2、sudo reboot
3、locale
如果想 Ubuntu 在每次啟動到 command prompt ,可以輸入以下指令:
$echo “false” | sudo tee /etc/X11/default-display-manager
當下次開機時,就會以指令模式啟動,如果想變回啟動 x window,可以輸入:
$echo “/usr/sbin/gdm” | sudo tee /etc/X11/default-display-manager
P.S. 如果不是用 gdm 作為,以上指令需要根據你的環境作出更改,例如 kdm 或 xdm。
上述程式已在Ubuntu 9.04亲测。
编辑工程的.project文件:
添加
<nature>org.eclipse.wst.common.project.facet.core.nature</nature><nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature><nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
到
<natures>…</natures>
eg.
例如将
<natures> <nature>org.eclipse.jdt.core.javanature</nature></natures>
更改为:
<natures> <nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> <nature>org.eclipse.jdt.core.javanature</nature></natures>
应用python的pickle模块从序列化文件中构造对象,根据对象的构造解开谜题
详细描述 :
http://www.pythonchallenge.com/pc/def/peak.html
(peak hell连读发音类似pickle,谜题就是pickle模块的应用了)
解决方案代码:
输出的对象构造:
在网上找了很久才找到developerWorks上的一个解决方案:
在命令提示符里切换到目录“C:\Program Files\IBM\SDP70\jdk\jre\bin”,运行“java.exe -Xshareclasses:destroyAll”
这样就能正常启动RAD了!
原因描述如下:
(摘录自http://www-1.ibm.com/support/docview.wss?uid=swg21281393,并通过Google Translate转译,译文已作修改)
×××××××××××××××××××××××××××××××××××××
问题(摘要) 此说明解释如何解决错误“JVM的终止。退出代码= 1”。 起因 RAD自带的IBM JVM使用了一个高速缓存参数来提高性能。而因为JVM的崩溃,比如蓝屏,或断电,都可能造成Java高速缓存被损坏。 而JVM会拒绝连接到一个损坏的高速缓存。
解决问题 要解决这个问题,使用“-Xshareclasses:destroyAll”的Java选项将销毁所有的共享级缓存。这是一种实用工具选项,所以不会启动JVM 。如果您想要这么做,只要从命令提示符使用参数“-Xshareclasses:destroyAll”来运行RAD使用的java。
××××××××××××××××××××××××××××××××××××××
把你的shell换成bash就可以了。
怎么换成bash呢?
执行“bash”命令就可以了,如下:
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images ; DIL= DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0)
用vmware装redhat as 4,初始分辨率是800×600的, 看着窗口太小了,不舒服。。。(系统是1280×1024),以前没装过vmware-tools,这次想试试看能不能改分辨率,果然,就是用来改分辨率的。。。 装了rpm包後运行vmware-config-tools.pl(在/usr/bin下面),选择1280×1024,哇,世界清净了!
要准备的东东:一杯清水方法:含一大口水,小口分多次吞下,直至不打嗝。 (一般两大口水量就可以搞定)PS: 代码实现:
考试,实习,写点代码;这些天就这些事情了
刚才我在网上的回帖,大概总结一下,贴上来.
1、不用删除邮件(偶现在3千多封邮件,用了80M左右空间,Gmail空间有两个多G;邮件很多是Google快讯;查询邮件的时候速度也快,方便,我都不用分类)
2、在线聊天(在网页里跟同使用Gmail的联系人在线聊天)
3、界面简洁,操作人性化(Ajax风格,使得操作很流畅)
4、邮件用会话形式维护(同一个主题的回复邮件被组织到一起,对照起来很方便)
5、Gmail帐号是Google其他服务的通行证(这样当Google有了新服务,很快就可以体验,Google有很多好的免费产品,具体参见http://www.blogjava.net/Andyluo/archive/2006/04/13/40962.html)
6、Gmail的垃圾邮件过滤,是我用过的系统中最完美的!(垃圾邮件肯定是投递到垃圾箱的,不过由于前期“宣传”失误,导致我每天都能收到30多封垃圾邮件;Hotmail邮箱每天也能收到10来封,但都“帮”我放到收件箱了,所以惨不忍睹。。。)
在Java中使界面置顶,且用户在界面显示的时间内不能访问其他程序 代码摘录20050505(文件分块、断点下载、剪贴板) 代码阅读摘录及心得20050503(界面style统一设置) 如何在Java程序中访问IE设置的代理服务器 享受商业软件的宝贵试用期,减少盗版 做一个聪明的项目参与者--制订WBS清单(转载) Java Swing设计的一些小技巧
在《J2EE》课程实验里写了些jsp和servlet代码,将遇到的一些问题和解决方法贴上,自己mark一下 && 供大家参考1、jsp:usebean标签中, 若引用的bean不存在,会自动调用默认构造器生成一个javabean实例,所以不要在servlet里再用session.getAttribute来判断bean是否为空(因为肯定不为空),应该判断里面的字段是否为null或为初始化状态。
2、jsp:usebean 的class属性应该是类的全名(包括包名)。在前面<%@ import>中import的包,在tag里不起作用,只对jsp里面的java代码有用,所以tag里要使用类的全名
3、post时如果表单里有中文,会出现中文乱码,在servlet里调用request.getParameter之前执行request.setCharacterEncoding("gb2312");就可以正确识别和显示中文了;如果是url中用中文参数,如someaction.jsp?q=中文问题,则要加一个filter来setEncoding,因为post和get传送参数的处理方式不一样。url中包含中文参数的设置参考:http://www.itet.cn/0512456328001529/JSP/0691214511318687.html
先讲讲做这个小程序的动机吧,昨天看了下以前学院的新闻,没什么更新,但发现列表很长,保留了2003年1月至今的所有新闻。这个新闻列表是大学期间我们了解学院信息的主要来源,都养成了每天先看新闻再看BBS的习惯。在大连实习期间更是如此,也算是产生感情了^__^,所以。。。决定把这700+新闻全部保存下来...需求:指定一个网址,将这个网页和里面所有的子链接页面都下载下来,保存到指定的文件夹中。如下图所示:需求有了,怎么完成呢?用迅雷下载全部链接?嗯,这是个好主意,(我确实也这么做了一次,连接数开得太多了,差点被封orz ),但咱们是搞软件的@_@,这个小功能是不是写个程序就能搞定,用Java?想到那一堆Stream的封装(new BufferedReader(new BufferedOutputStream(new FileOutputStream(new File("blabla.html")))))...我就头晕。小程序用脚本语言?应该不错!用Perl还是Python?。。。经过一番网上查询论证,似乎:Perl语法复杂,但简练,API库也超级多;Python语法清晰易懂,有点像Java,适合开发大型应用。Java是我的最爱,也算熟悉了,就学点bt的吧,用Perl完成代码期间主要参考了Perl文档中URL,HTML::LinkExtor,HTTP::Request的用法,Perl中国的一篇文章《LWP与WEB的基本使用》,还占用了J2EE的上课时间来编写程序。。。
主网页保存为index.html,子网页按1、2、3排序生成1.html、2.html等因为有Google Desktop,即使文件名是1.html...,搜索起来也是很方便的。也可以扩充下,将<a></a>中的新闻主题抽出来作为文件名。但这个程序对我来说已经足够了,所以就不继续做了。总的来说用Perl还是很简单的,库也很多,写起来挺方便!但是要记得常翻翻Perl手册,呵呵Technorati Tag : Perl LWP Download web script
原文照抄如下,^__^问题:装了Google Toolbar的用户在网页搜索框里点右键,不会出现Custom Search菜单,导致不能将“迅雷搜索功能”添加到Toolbar。
市场需求:很多用户都装了google toolbar,里面有一个定制搜索的功能(Custom Search),可以将一些自己喜欢的搜索功能添加到toolbar,方便搜索,比如百度mp3搜索,天网搜索,在线字典搜索 等等。
建议:有可能是迅雷的搜索按钮的样式,导致Google Toolbar不能正确识别该搜索框。希望能做稍微修改,使其支持Google Toolbar的识别,让Google Toolbar的用户使用迅雷更加方便,谢谢你们Excellent的产品!
我的Email:andyluo197(AT)gmail.com
欢迎交流!Technorati Tag : 迅雷googlecustom search
最开始 我在程序里使用SQL访问数据库时,都是直接用“+”将字段值嵌到SQL中。
后来我开始使用PreparedStatement,在SQL里使用“?”标记参数,然后用setXXX方法给参数赋值。当时只知道这样用是因为有setDate,setTimeStamp这些用“+”连接不能直接嵌入的值。感觉PreparedStatement在性能方面应该也能快点,可能DBMS会重用,但不明底层原理。这次《数据库实现》课程终于让我弄懂了:每个SQL语句都要通过 语法分析 -> 生成逻辑查询计划 -> 逻辑优化 -> 物理优化 等步骤生成具体的执行计划,用PreparedStatement就可以生成一个执行计划,以后只是参数改变(相当于执行计划的执行环境改变),前面的四个步骤也会省略,从而提高了效率。如果一个SQL语句要被反复多次执行,或多用户同时操作,则应选用PreparedStatement!
执行力是工作中最重要的! 人有7次改变命运的机遇,第一次和最后一次没有精力抓住(too naive 或 too old),中间两次机遇错失,其余三次机遇就看你能否抓住了。
昨天看了IBM Developerworks上一篇介绍WTP的教程,对照着使用WTP1.0完成一个J2EE示例书签应用程序,服务器使用JBoss,数据库用的是Derby,Eclipse版本3.1.1。在新建JBoss Server时,因为本机上已有Tomcat占用了8080端口(未启动),所以将监听端口由默认的8080改成了8081,结果运行服务器后:JBoss进程明明正常启动(根据Console得出),但WTP的Servers视图却提示“Timeout waiting for JBOSS 3.2.3 to start. Server did not start after 50000s”,服务器的状态也显示Stopped。但改成默认的8080就一切正常。怎么能出这种问题呢?难道WTP就是通过查询8080有没有JBoss在监听,从而判断JBoss是否启动成功?强烈怀疑这是一个Bug,不知道在最新版Eclipse和WTP改过来没有PS: 用老版的Eclipse3.1.1来开发也是迫不得已,本来已安装了Callisto最新完整版(Eclipse3.2M5),但在J2EE透视图中就是看不到EJB项目分类,新建EJB项目也抛出若干个异常,看Log发现是JFace插件里抛出了NullPointerException,总之是做不下去了,不知道这样的Callisto怎么会算MileStone,: (那个50000s应该是50000ms吧,50000s可是13时53分啊!^_^
预览报表时提示无法显示网页,查看D:\eclipse\workspace\.metadata\.log文件后发现错误:!MESSAGE Exception occurred starting the embedded application server.!STACK 0org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JLogger does not implement Log...搜索plugins目录下的log文件,发现既有Log4j又有CommonsLogging,将plugins目录下的org.apache.jakarta_log4j_logging_version.jar移出Eclipse目录(移出Classpath),重启动Eclipse,就可以预览了。其他Web服务器不能启动(如Eclipse的Help打不开,JBoss提示上述Log异常)的错误也可以参照以上方法解决。
有越来越多的迹象表明Web2.0之类的东西渐渐深入网络的各个角落,无论是Google Maps,Gmail,Flickr还是国内的163邮箱、365kit、豆瓣网,都把Ajax之类代表Web2.0的技术发挥得淋漓尽致,撇开他们用的技术不管,单从他们提高的用户交互“流畅感”,就可以说是对Web技术的一次改革。 以前的Web应用从功能方面考虑的因素比较多,对提升用户体验度所做的工作很少,现在的Web2.0应用则从用户的角度入手,把提升用户体验度当成第一目标。以前不喜欢搞Web开发,更不喜欢用JavaScript,感觉那些东东只能做些美化界面的活,做些动画什么的,因为当初认为它只能在客户端发挥作用,而现在JavaScript和异步传输结合,就把服务器的地盘也夺过来了。 如今,Web2.0应用的复杂度已经可以与大型应用媲美了,很多提高用户体验度的东东都要在后台做大量有技术难度的工作,如365kit的通讯录同步功能,就要在与Outlook、MSN、手机交互中下很大工夫。 现在还没有时间,要忙着做项目和毕业设计,等过一阵子,一定要研究一下Ajax和JavaScript,并做出个像样的应用来。也希望以后能做出个好的应用,有市场的,慢慢把它做大,推广,现在不流行网络创业吗,呵呵,而且门槛也比较低,要的硬件和资金不多,主要是应用要有市场、有创意! Web2.0火了,我们又多了一条路!(写得不好,欢迎大家拍砖)续:RIA应该也是一种实现Web2.0的技术? Web2.0应该是一种思想,是通过提高用户体验度来赢得市场,实现它的技术有很多,只要能达到提高用户体验度的目的,我们就可以说它“是”Web2.0,不是吗? RIA技术我知道的好像有三种:1、Flex 2、Eclipse RCP 3、Ajax 4、Java Web Start
轉自:http://blueline.hit.edu.cn/ccs/blogs/loveme/archive/2006/03/03/1030.aspx
为了减轻服务器压力,将原来的文章管理系统由JSP文件的从数据库中取数据显示改为由jsp生成静态html文件后直接访问html文件。下面是一个简单的示例
1.buildhtml.jsp
<%@ page contentType="text/html; charset=gb2312" import="java.util.*,java.io.*"%><%try{ String title="This is Title"; String content="This is Content Area"; String editer="LaoMao"; String filePath = ""; filePath = request.getRealPath("/")+"test/template.htm"; //out.print(filePath+"<br>"); String templateContent=""; FileInputStream fileinputstream = new FileInputStream(filePath);//读取模块文件 int lenght = fileinputstream.available(); byte bytes[] = new byte[lenght]; fileinputstream.read(bytes); fileinputstream.close(); templateContent = new String(bytes); //out.print(templateContent); templateContent=templateContent.replaceAll("###title###",title); templateContent=templateContent.replaceAll("###content###",content); templateContent=templateContent.replaceAll("###author###",editer);//替换掉模块中相应的地方 //out.print(templateContent); // 根据时间得文件名 Calendar calendar = Calendar.getInstance(); String fileame = String.valueOf(calendar.getTimeInMillis()) +".html"; fileame = request.getRealPath("/")+fileame;//生成的html文件保存路径 FileOutputStream fileoutputstream = new FileOutputStream(fileame);//建立文件输出流 byte tag_bytes[] = templateContent.getBytes(); fileoutputstream.write(tag_bytes); fileoutputstream.close();}catch(Exception e){ out.print(e.toString());}
%>
2. template.htm
<html><head><title>###title###</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><LINK href="../css.css" rel=stylesheet type=text/css></head>
<body><table width="500" border="0" align="center" cellpadding="0" cellspacing="2"> <tr> <td align="center">###title###</td> </tr> <tr> <td align="center">author:###author### </td> </tr> <tr> <td>###content### </td> </tr>
</table></body></html>
在下面这篇文章中 http://www.firstpartners.net/blog/technology/2006/03/01/web-20-and-enterprise-java-move-over-struts/ ,作者介绍了几种常用的AJAX框架。
最后作者以Struts为例,介绍了几种选择Ajax的场景:
1 现有的Struts应用程序要使用Ajax,请使用AjaxAnywhere
2 建立新的应用程序准备使用Ajax,参考Appfuse,它集成了DWR的Ajax
3 中期目标: 使用一种支持Ajax的JSF的实现,MyFaces或者Struts Shale原文地址:http://blog.csdn.net/danny_xcz/archive/2006/03/03/614302.aspx
刚解决的问题:用Word的网页形式做报表时遇到中文乱码,而且已经使用ISO8859_1对中文参数进行了转换,试试将网页里的charset=us-ascii改为charset=gb2312怎么我这里默认的charset是us-ascii呢,我这是中文版阿?!
URL分别用三个List保存, 一个是boring,这个list中的url最后来下载 其他两个是interesting和average 当搜索到url时检查是否包含设定为boring的词,并放入boring中
用户可设定“深度搜索”:每搜到一个url就放在list的最前面 也可广度
有些网页链接要特殊处理:
url = textReplace("?", URLEncoder.encode("?"), url); url = textReplace("&", URLEncoder.encode("&"), url); private String textReplace(String find, String replace, String input) { int startPos = 0; while(true) { int textPos = input.indexOf(find, startPos); if(textPos < 0) { break; } input = input.substring(0, textPos) + replace + input.substring(textPos + find.length()); startPos = textPos + replace.length(); } return input; }
读取资源代码:
BufferedInputStream remoteBIS = new BufferedInputStream(conn.getInputStream()); ByteArrayOutputStream baos = new ByteArrayOutputStream(10240); byte[] buf = new byte[1024]; int bytesRead = 0; while(bytesRead >= 0) { baos.write(buf, 0, bytesRead); bytesRead = remoteBIS.read(buf); }
byte[] content = baos.toByteArray();
File f = new File(fileName); f.getParentFile().mkdirs(); FileOutputStream out = new FileOutputStream(fileName); out.write(content); out.flush(); out.close();
/** * Set of URLs downloaded or scheduled, so we don't download a * URL more than once. * Thread safety: To access the set, first synchronize on it. */ private Set urlsDownloadedOrScheduled;
private final static Category _logClass = Category.getInstance(TextSpider.class);
/* 显示信息: 2005-05-01 11:40:44,250 [main] INFO? TextSpider.java:105 - Starting Spider... */ _logClass.info("Starting Spider...");
else if(queueSize() == 0) /* queueSize()已经被同步 */{ break;}URLToDownload nextURL;synchronized(queue){ nextURL = queue.getNextInQueue(); downloadsInProgress++;}synchronized(urlsDownloading){ urlsDownloading.add(nextURL);}int newDepth = nextURL.getDepth() + 1; **********************
synchronized(queue){ nextURL = queue.getNextInQueue(); if(nextURL == null) { continue; } downloadsInProgress++;}
I had to get obsessed with keyboard shortcuts when using IDEA. Apparently some of that must have rubbed off, because lately I've been looking for shortcuts to methods and classes in Eclipse 3.0.
There are two traversal shortcuts I use all the time: Ctrl-O and Ctrl-T.
Ctrl-O shows the methods of the class in the current editor in a popup. Hit Ctrl-O when the popup is up, and you'll see all the inherited methods as well. This is incredibly useful, as it allows me to bounce between methods even when I'm not sure which class is implementing which method.
Ctrl-T shows the type hierarchy of a selected type in a popup. This is the complement to Ctrl-O. When I'm sure of what interface I'm looking at, but I really want to pick a particular implementation and want to go trawling through that implementation for a bit, Ctrl-T will show me all the subclasses or implementors for that type.
There is a third option which I haven't used much. Ctrl-F3 shows the methods of a selected type in a popup. I can see how this can be useful, but in practice I have a pretty good idea of which methods are attached to which classes and Ctrl-Space fills most of my needs there.
However, I have been missing a couple of things. These are the shortcuts I just found recently, and are very good for hitting up random files:
Ctrl-E shows a popup list of all the open files.Ctrl-Shift-T creates a dialog box that you can use to navigate to any class.Ctrl-Shift-R creates a dialog box that shows any resource in the project (basically any file.)Alternately, there's an Eclipse plugin called GotoFile which seems to behave a little more "IDEAish".
Finally, I found a plugin which actually integrates Eclipse with Windows! Eclipse Platform Extensions is actually functional and useful, although you wouldn't guess it by looking at the website. Although it says that it provides a "System GC" functionality, it actually does far more, like provide a "Open in Windows Explorer" and "Open Command Window here" dialog to the Package Explorer.
You can allow your users to access the help system over the Internet or an intranet, by installing the infocenter and the documentation plug-ins on a server. Clients view help by navigating to a URL, and the help system is shown in their web browser. The infocenter help system can be used both for client applications and for web applications, either of which can have their help accessed remotely. All features of help system except infopops and active help are supported.
The infocenter help system allows passing number of options that can be used to customize various aspects of the infocenter. The following options are supported:
-nl en -locales de en es fr it ja ko pt_BR zh_CN zh_TW
-vmargs -Xmx256M
These steps are for the help system integrator and are not meant to address all the possible scenarios. It is assumed that all your documentation is delivered as Eclipse plug-ins and, in general, you are familiar with the eclipse help system.
The org.eclipse.help.standalone.Infocenter class has a main method that you can use to launch infocenter from a command line. The command line arguments syntax is:
-command start | shutdown | [-eclipsehome eclipseInstallPath] [-data instanceArea] [-host helpServerHost] [-locales localeList] [-port helpServerPort] [-dir rtl] [-noexec] [platform options] [-vmargs JavaVMarguments]
To start an infocenter on port 8081 issue a start command by running
java -classpath d:\myApp\eclipse\plugins\org.eclipse.help.base_3.1.0.jar org.eclipse.help.standalone.Infocenter -command start -eclipsehome d:\myApp\eclipse -port 8081
To shut the infocenter down issue a shutdown command by running
java -classpath d:\myApp\eclipse\plugins\org.eclipse.help.base_3.1.0.jar org.eclipse.help.standalone.Infocenter -command shutdown -eclipsehome d:\myApp\eclipse
Start the web server. Point a web browser to the path "help" web application running on a port specified when starting the infocenter. On the machine the infocenter is installed, this would be http://localhost:8081/help/.
When including infocenter as part of another application, it may be more convenient to start it and stop using Java APIs instead of using system commands. Follow the steps if it is the case:
String[] options = new String[] { "-eclipsehome", "d:\\myApp\\eclipse" , "-port", "8081" };
Infocenter infocenter = new Help(options);
helpSystem.start();
To shut the infocenter down:
helpSystem.shutdown();
Eclipse contains a complete infocenter and does not require other server software to run. However, in unsecure environment like Internet, it is recommended infocenter is not accessed directly by clients, but is made available through an HTTP server or an application server. Most servers come with modules or servlets for delegating certain request to other web resources. For example, one may configure a proxy module of Apache HTTP Server to redirect requests made to http://mycompany.com/myproduct/infocenter to http://internalserver:8081/help that runs an infocenter. Adding the lines
LoadModule proxy_module modules/ApacheModuleProxy.dll ProxyPass /myproduct/infocenter http://internalserver:8081/help ProxyPassReverse /myproduct/infocenter http://internalserver:8081/help
Some versions of Apache HTTP server, may contain AddDefaultCharset directive enabled in configuration file. Remove the directive or replace with
AddDefaultCharset Off
Multiple instances of infocenter can be run on a machine from one installation. Each started instance must use its own port and be provided with a workspace, hence -port and -data options must be specified. The instances can serve documentation from different set of plug-ins, by providing a valid platform configuration with -configuration option.
-port
-data
-configuration
If -configuration is not used and configuration directory is shared among multiple infocenter instances, with overlapping set of locales, it must be ensured that all search indexes are created by one infocenter instance before another instance is started. Indexes are saved in the configuration directory, and write access is not synchronized across infocenter processes.
The infocenter does not require the entire Eclipse Platform package. It is possible to run the infocenter with the following plug-ins (located in the eclipse\plugins directory):
org.apache.luceneorg.eclipse.core.runtimeorg.eclipse.helporg.eclipse.help.appserverorg.eclipse.help.baseorg.eclipse.help.webapporg.eclipse.osgiorg.eclipse.tomcatorg.eclipse.update.configurator
Some documentation plug-ins may have dependencies on other plug-ins, usually by specifying required plug-ins in their plugin.xml. The dependent plug-ins need to be installed on the infocenter as well. Additionally, plug-ins that were designed for earlier than 3.0 version of Eclipse implicitly require an org.eclipse.core.runtime.compatibility being present plug-in to work.
org.eclipse.core.runtime.compatibility
Infocenter plug-ins can be updated without restarting the infocenter, using commands explained in Updating a running infocenter from command line topic. To use this functionality, the minimal set of plug-ins must include org.eclipse.update.core plug-in.
org.eclipse.update.core
See Help System Preferences for more information on customizing help system.
Class.forName("weblech.util.Log4j");
调试网页时出错,无意中发现出错页的源文件中有这样一段注释:<title>404 Not Found</title><h1>404 Not Found</h1>/asfsfdsd.jsp was not found on this server.<p /><hr /><small>Resin 2.0.3 (built Wed Oct 17 10:11:08 PDT 2001)</small></address><!-- -- Unfortunately, Microsoft has added a clever new -- "feature" to Internet Explorer. If the text in -- an error's message is "too small", specifically -- less than 512 bytes, Internet Explorer returns -- its own error message. Yes, you can turn that -- off, but *surprise* it's pretty tricky to find -- buried as a switch called "smart error -- messages" That means, of course, that many of -- Resin's error messages are censored by default. -- And, of course, you'll be shocked to learn that -- IIS always returns error messages that are long -- enough to make Internet Explorer happy. The -- workaround is pretty simple: pad the error -- message with a big comment to push it over the -- five hundred and twelve byte minimum. Of course, -- that's exactly what you're reading right now. -->这就叫以牙还牙:凡是用Resin服务器的网站,都不会出现M$的恼人友好信息了。
friend
Java by default restricts the friends of a class to those classes that are in the same package. If there is a functionality that you want share just among classes in the same package, use package-private modifier in definition of a constructor, a field or a method and then it will remain accessible only to friends.
friends
Sometimes however it is more useful to extend the set of friends to a wider range of classes - for example one wants to define a pure API package and put the implementation into separate one. In such cases following trick can be found useful. Imagine there is a class item:
public final class api.Item { /** Friend only constructor */ Item(int value) { this.value = value; } /** API method(s) */ public int getValue() { return value; } /** Friend only method */ final void addListener(Listener l) { // some impl } }
Accessor
public abstract class impl.Accessor { public static Accessor DEFAULT; static { // invokes static initializer of Item.class // that will assign value to the DEFAULT field above Class c = api.Item.class; try { Class.forName(c.getName(), true, c.getClassLoader()); } catch (ClassNotFoundException ex) { assert false : ex; } assert DEFAULT != null : "The DEFAULT field must be initialized"; } /** Accessor to constructor */ public abstract Item newItem(int value); /** Accessor to listener */ public abstract void addListener(Item item, Listener l); }
Item
api
final class api.AccessorImpl extends impl.Accessor { public Item newItem(int value) { return new Item(value); } public void addListener(Item item, Listener l) { return item.addListener(l); } }
api.Item
public final class Item { static { impl.Accessor.DEFAULT = new api.AccessorImpl(); } // the rest of the Item class as shown above }
api.Item item = impl.Accessor.DEFAULT.newItem(10); impl.Accessor.DEFAULT.addListener(item, this);
posted Friday, 30 December 2005
原文见: http://today.java.net/pub/a/today/2005/07/07/j2me3.html?page=3
定义游戏的角色和特征一个只能将图片左右移动的游戏是没有意思的。我们现在要对清单1的代码作一些改动,让它变得更有趣些。首先我们要定义游戏显示的边界,这样能保证在所有设备上的大小一致,先定义一些常量,如下代码所示:
(注意,我们这里引入了一个游戏特征:couple小精灵很快就可以在屏幕上跳动了)在游戏屏幕上定义的这些常量规定了游戏的边界,如图2所示。
图 2. 用常量定义游戏边界当然,我们现在需要修改代码来使用这些常量。在清单1的代码中添加一个buildGameScreen(Graphics g)方法,如下代码所示:
再在updateGameScreen()方法里绘制couple之前添加一个该方法的调用,还要将couple小精灵的开始位置由CENTER_Y改为BASE(在start()方法里设置coupleY = BASE)。
couple小精灵可以左右移动,我们要限制它走出边界,更改calculateCoupleX()方法里左右移动的代码,避免坐标超出边界。修改后的代码如下:
方法使用Math.max()和min()函数使图片显示在游戏边界内。注意我们在计算中还考虑了图片的大小。
我们刚才说过要实现couple小精灵在屏幕上跳跃的功能,我们现在增加一个方法使图片在Y轴上移动,跳跃时移动的具体路径将不受玩家影响。
在清单1的代码中添加三个新的实例变量:up、jumpHeight 和random。如下所示:
jumpHeight初始值被设为MAX_HEIGHT。jumpHeight变量会在couple小精灵每次跳跃时动态设为随机值,新增的calculateCoupleY()方法如下:
你可能已经发觉,这个方法不依赖于用户的按键,传入的keyState信息也没有用到。传入这个值是为了与calculateCoupleX()方法保持一致。方法刚开始时通过渐增coupleY变量值使couple小精灵上升,直到达到这次的跳跃高度(刚开始是MAX_HEIGHT)。达到这个高度后,小精灵开始往下降,降到BASE后又随机生成一个介于MAX_HEIGHT和图像高度之间的数值,按这个高度开始下一次跳跃。
游戏的整个效果是一个以随机高度跳跃的couple小精灵,它可以在用户的操纵下左右移动。图3是游戏的一个截屏: 图 3. 游戏截屏
承接第一部分,介绍小游戏的具体实现,实现第一个版本,并介绍GameCanvas类的使用及运行机制。
原文见:http://www.blogjava.net/Andyluo/archive/2005/12/08/23003.html
图中有14个著名的开源项目,你都能看出来吗?(答案附文后)答案:
原文见:http://today.java.net/pub/a/today/2005/07/07/j2me3.html?page=2构建一个J2ME游戏:从GameCanvas类开始
GameCanvas类继承自Canvas,提供了一个屏幕后端的缓冲区,所有的绘制操作都先在这个缓冲区里进行。当所有绘制操作完成后,我们调用flushGraphics()方法将缓冲区内容输出到屏幕。这种双缓冲机制可以使图像的移动更加平滑,避免图像的闪烁。缓冲区大小等于屏幕的大小,而且每一个GameCanvas实例有且仅有一个缓冲区。
GameCanvas类提供一种存储按键状态的机制,我们可以通过它方便的了解用户与游戏的交互。这种机制可以跟踪用户按特殊键的次数,调用getKeyStates()方法返回所有游戏键按键状态的二进制表示,1代表上次调用方法后按过该键,0表示上次调用后还没有按过该键。我们可以跟踪的游戏状态有(这里的键都是在Canvas类里定义的):DOWN_PRESSED, UP_PRESSED, RIGHT_PRESSED, LEFT_PRESSED, FIRE_PRESSED, GAME_A_PRESSED, GAME_B_PRESSED, GAME_C_PRESSED和GAME_D_PRESSED。
首先扩展GameCanvas类,定制一个游戏画布,代码见清单1。清单2是运行例子的MIDlet。
清单 1. MyGameCanvas:游戏画布的第一个版本
清单 2 是使用这个游戏画布的MIDlet:
清单 2. 运行游戏示例的MIDlet类
使用Wireless工具建立一个工程,导入这两个类,然后生成并运行工程。确保你的工程目录res中有这个图片文件,并保证名称为couple.gif, 图1是运行结果。
图1. 构建一个游戏:使用GameCanvas类
使用设备的方向键可以左右移动屏幕中的小图像,这是通过从checkUserInput()里取得按键状态,然后调用calculateCoupleX(),通过将按键状态与GameCanvas里预定义的按键值进行与操作(&),得到用户当前按的键,然后将实例变量更新,最终反映到设备屏幕上。
图像是在updateGameScreen()方法里被绘制到屏幕上的。这个方法使用传入的Graphics对象进行绘制,每一个GameCanvas只有一个Graphics对象。方法首先擦除上次绘制的图像,然后基于当前的coupleX值(还有一直不变的coupleY值)绘制couple.gif图像,最后将缓冲区的数据输出到屏幕。
run()方法里的循环体遵循我们刚开始提出的游戏结构。循环每30毫秒检查一次用户输入并刷新屏幕。你可以试着将这个值改变一下,这会改变刷新的频率。
最后,注意MyGameCanvas的构造器里调用了父类GameCanvas的构造方法,传入的参数为true,这表示从Canvas类继承的按键事件机制被抑制了,因为我们的代码不需要这些通知机制。我们的游戏状态用GameCanvas里自带的按键信息(由getKeyStates()方法取得)来处理已经足够了。通过抑制“keyPressed”、“keyReleased”和“keyRepeated”等通知机制,可以提高游戏的性能。
原文见:http://today.java.net/pub/a/today/2005/07/07/j2me3.htmlJ2ME是一个很流行的用于移动设备游戏开发的平台。J2ME中的MIDP 2.0引入了一个新的API包,它提供了一些定义好的游戏结构,这在以前的1.0版中要通过很多累赘代码来实现。在这部分tutorial中,我们会学习这个API包,然后用它开发一个小游戏(为了学习需要,我们会用到包中所有的类)。这个包是javax.microedition.lcdui.game. 它的建立基于我们前两次学的J2ME概念。
J2ME游戏API:摘要javax.microedition.lcdui.game包只有5个类:GameCanvas, Layer, Sprite, TiledLayer和LayerManager. 这5个类提供了开发各种游戏应用的平台。
Layer是Sprite和TiledLayer的父类。这个类封装了游戏中可视化元素的行为。可视化元素可以是小精灵(sprite),代表一个可以在屏幕上来回移动的独立图形(或组成动画的一组图形),或是一个背景层:通过很少的图片,就可以生成庞大游戏中的背景。我们可以用Layer来布置图形和进行可视化操作。Layer的子类通过重写paint(Graphics g)方法将元素绘制到屏幕上。
LayerManager类可以控制各层的绘制及绘制顺序,因此我们可以更方便地管理游戏中的可视化元素(包括小精灵和背景层)。
GameCanvas类扩展了上两节我们讲过的Canvas类(画布),提供一个在屏幕后端运行(off-screen)的缓冲区,所有绘制操作都先在这个缓冲区上进行,然后再显示到屏幕。它还提供了得到用户按键信息的快捷方法。
最好的学习方法应该是写一个完整的小游戏,通过这个小游戏我们可以了解游戏制作的方方面面。我们在介绍完这个小游戏的构造后(针对目前还没有游戏开发经验的),会在开发游戏的过程中具体介绍包中的每个类。
构建游戏的简短入门
游戏和动画是建立在重复执行某段代码的机制上的。这段代码跟踪实例变量的值,然后更新相应状态。基于当前游戏状态,代码将游戏元素绘制到屏幕上。实例变量值是随着用户交互和游戏内部行为而改变的。
代码的重复执行是通过将这段代码放入循环中实现的。在进入循环前,先检查一下实例变量,看是否要继续游戏,否则退出循环。为了控制实例变量的更新频率(其实是屏幕刷新的频率),循环体中的代码应该每次休眠一段时间(毫秒计)。
游戏的结构如下列代码所示:
我们将在以下几节中使用这个结构来开发一个游戏。
转自:http://forum.ubuntu.org.cn/viewtopic.php?t=6774
1、临时更改(不需要重启):代码: $ sudo ifconfig eth0 down $ sudo ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX $ sudo ifconfig eth0 up
这样做完以后default route可能就没有了,要重新加一下 代码: $ sudo route add default gw xxx.xxx.xxx.xxx
2、永久更改:代码: $ sudo gedit /etc/iftab
eth0 mac 00:e0:4d:75:8e:50(改成你要的物理地址mac)
代码: $ sudo gedit /etc/network/interfaces
将iface eth0 inet static后面添加一行
hwaddress ether 00:E0:4d:75:8E:50
如:iface eth0 inet static hwaddress ether 00:E0:4d:75:8E:50(自己加的) address 219.220.214.113 。 。 。
然后就好了 可能要重启一下
Getting Started with MIDP 2.0
J2ME Tutorial, Part 1: Creating MIDlets
J2ME Tutorial, Part 2: User Interfaces with MIDP 2.0
J2ME Tutorial, Part 3: Exploring the Game API of MIDP 2.0
SQL错误信息
1、无效的描述符索引
解决办法:数据库表里字段按什么顺序排,程序也按什么顺序读。
2、无效的游标状态
可能的解决办法:用ResultSet读数据前要先调用resultSet.next();
解决办法:数据库表里字段是按什么顺序排的,程序也按什么顺序读。
e文请参考:http://www.linuxcommand.org/lts0080.php
Linux下使用Shell命令控制任务(Jobs)执行
下列命令可以用来操纵进程任务:ps 列出系统中正在运行的进程kill 发送信号给一个或多个进程(经常用来杀死一个进程)jobs 列出属于当前用户的进程bg 将进程搬到后台运行(Background)fg 将进程搬到前台运行(Foreground)
将job转移到后台运行
如果你经常在X图形下工作,你可能有这样的经历:通过终端命令运行一个GUI程序,GUI界面出来了,但是你的终端还停留在原地,你不能在shell中继续执行其他命令了,除非将GUI程序关掉。
为了使程序执行后终端还能继续接受命令,你可以将进程移到后台运行,使用如下命令运行程序: #假设要运行xmms$xmms &
这样打开xmms后,终端的提示又回来了。现在xmms在后台运行着呢(可以继续工作和听音乐了^_^)
但万一你运行程序时忘记使用“&”了,又不想重新执行(Eclipse启动速度太慢了,我不想重启啊,:))。你可以先使用ctrl+z挂起程序,然后敲入bg命令,这样程序就在后台继续运行了。
察看jobs
使用jobs或ps命令可以察看正在执行的jobs。(the two have a little diff. have a try ^_^)
kill a job
方法一:通过jobs命令查看job号(假设为num),然后执行kill %num方法二:通过ps命令查看job的进程号(PID,假设为pid),然后执行kill pid
kill的其他作用
kill除了可以终止进程,还能给进程发送其它信号,使用kill -l 可以察看kill支持的信号。
SIGTERM是不带参数时kill发送的信号,意思是要进程终止运行,但执行与否还得看进程是否支持。如果进程还没有终止,可以使用kill -SIGKILL pid,这是由内核来终止进程,进程不能监听这个信号。
下期预告:Writing shell scripts(跟我写Shell脚本)
名词
Ubuntu 团队免费给你邮寄 Ubuntu 光盘,你可以用来安装或者分享给其他人。 我们会承担这些光盘的货运费用。
The link address is: http://shipit.ubuntulinux.org/
原文见:http://www.ubuntu.org.cn/shipit
链接
Ubuntu 团队免费给你邮寄 Ubuntu 光盘,你可以用来安装或者分享给其他人。 他们会承担这些光盘的货运费用。
在此填写你的邮寄地址: http://shipit.ubuntulinux.org/
详情见:http://www.ubuntu.org.cn/shipit
jorgeOct 26, 2005- Show original item
Have you ventured beyond Ubuntu’s default GNOME desktop applications? There’s a wealth of great tools available in the Ubuntu repositories. The Universe is a huge place, and it’s easy to get overwhelmed by the amount of software available. But don’t worry, because Jorge ‘whiprush’ Castro will pilot our guided tour of universe applications that will make you fall in love with Ubuntu all over again. Whether you’re an experienced user or brand new to Linux, there’s always new hidden gems in Ubuntu waiting to be discovered.
Pre-flight Checklist
Universe is composed of packages from Debian that aren’t fully supported by Ubuntu. But we need not worry - the MOTU team of over 30 developers ensures these packages build and work, and they’re very responsive to bug reports.
Universe requires some manual set up before being used. Luckily for us, our hard working ground crew (aka the Documentation Team) has already outlined the process for us. Once you’ve followed those steps, you’re ready to go.
Blast Off!
The deskbar-applet is a small multipurpose text box which sits in the panel. Typing in the box allows you to quickly search amazon.com, Google, wikipedia, yahoo, ebay, Creative Commons, and even Beagle. It also acts as an application launcher, allowing you to launch applications or open folders right from your panel. Fridge Tip: The default keyboard shortcut to use the applet is Alt-F3.
The Breezy release features two new applications that improve the Ubuntu laptop experience. GNOME Power Manager is an application which monitors and lets you control many power management features on modern laptops.
The NetworkManager tool provides an easy to use applet for controlling wireless interfaces. It features autoscanning, graphical control of which network to join, and Virtual Private Networking support for Cisco VPNs. This allows a user to click on the icon, see which networks are available, and then join one by clicking on the name of the network. It automatically gets an IP address and shows a graphical status icon. It also manages wired connections, so when a user plugs in an ethernet cable, NetworkManager will automatically configure the wired connection.
Both NetworkManager and gnome-power-manager are relatively new, so there are still instances where it might not work for you, but development on both tools is progressing rapidly, so if you have problems with these, make sure you revisit them when Ubuntu 6.04 is released.
Gobby is a small collaborative text editor that updates documents in real time. Think of it as a multi-user gEdit. One user starts a session as a host, creates or opens a document, and then the other users join that session. The bottom of the application has an IRC-like window for chatting, while the user-assigned colors allow the users to see who is making changes to which specific portions of the file.
Brightside is a tool for making “hot corners” on your desktop. You can assign different tasks to each corner; for example, you can configure it so that your screensaver activates when you move the mouse cursor to the bottom left corner. Fridge Tip: You can also make Brightside switch the workspace as you move the mouse to the edge of the screen.
Gajim is a Jabber client with a simple interface. It supports different icon themes and full support for using the user’s GPG key to encrypt instant messaging traffic. A built-in notification dialog the user of incoming instant messages. The included “Human” color theme also looks great on an Ubuntu desktop.
The Mono Galaxy
This part of the universe is well travelled, but we’ll do a quick flyby just in case. Tomboy is a simple applet that allows you to quickly take and organize notes. Tomboy automatically links text in a note to another note’s title as it’s being written, so as the user continues to make notes the application it becomes a self-referencing wiki-like repository of information. Clicking on the icon shows the recent edited notes and a search feature.
f-spot is a photo management application. It includes camera import support and exporting to Flickr, Gallery, or to CD-R/W. The GNOME Journal has a fairly complete introduction to f-spot.
Two newly forming stars, the Banshee music player (with iPod read and write support) and the famous Beagle desktop search are also available, but they’re still being developed, so we’ll have to check up on them next time.
Keep on Truckin’…
Monkey Bubble is a bust-a-move clone that is great for killing a few hours. The goal is to shoot a colored bubble at the stack of other colored bubbles near the top of the screen. When three bubbles of the same color come in contact, they explode. The goal is to clear the screen of bubbles before they fill up your screen. Fridge Tip: It supports up to 4 players with network play on a LAN, so set aside some time with your friends.
Here’s a program that we should have used before we left! Celestia is a space simulator, a “browser” for the solar system. It allows you to seamlessly move between heavenly bodies and explore the real universe in three dimensions.
glabels is a program for making printed labels. It has support for over 100 kinds of labels, just pick a template, insert the text, and print.
Manually trudging through art sites for nifty artwork can be a pain. gnome-art takes the hard work out of the process, by connecting to the art.gnome.org web service and letting you browse and download wallpapers right from the application itself.
Sometimes it’s just plain difficult to explain something to someone over the phone or via chat. Istanbul places a record button in your notification area. Clicking on it makes Istanbul record your desktop session as a video. After you’ve made your video, clicking on it again stops the recording and outputs the file as Ogg video. As you can see from the screenshot, it also supports streaming the video directly to an Icecast server.
The Trip Home
So, not a bad little journey. You’d be surprised what you can find if you go out and look for adventure, and we haven’t even scratched the surface of applications, so make sure you keep checking in so we can keep freewheeling through space. Feel free to contact me if you’ve found hidden nebula of desktop goodness and we’ll bring the ship on by.
jorgeOct 26, 2005 - Show original item
Ubuntu Documentation软件列表是一个大书库
标准且全面
It's really crazy
现在总共有952本书/文档)
i don't have to find ebooks on web anymore, it's enough, also a good place to improve my English skills.
使用Ubuntu Linux操作系统才有这个软件列表,在软件包管理器里选择安装某个文档,会自动下载到本地,然后就可以阅读了,一般都是开源软件(如Apache2、Emacs、VI、CVS、Subversion等)的资料。
标准且全面,大多数文档有对应的中文版本,可以对照着看。
really crazy
现在总共有952本书/文档
(ps: >_< 以后去哪里工作呢!)
来上海两个多月了,谈谈感想:在上海两个多月的生活是我倍加的喜欢杭州,怀念杭州。初到上海,感觉上海的人有些别扭,原以为是新到一个城市,所以不习惯。但是经过两个多月的生活,我渐渐的感觉到了一些东西。总体上来说就是上海的生活不如在杭州舒服。究竟哪里不舒服呢?人多,拥挤?太大,去个地方都特别麻烦?卫生情况不好,走在街上经常飘来阵阵异味?物价太贵,买不起东西?等等等等。原来以为是这些细微上的差异使我不喜欢上海的生活。但是最近我越发的感觉,上海和杭州存在着一个巨大的差异,这也应该是我感觉上海生活不如杭州舒服的主要原因。经过两个多月的“充实”的工作,我的身心积累了大量的疲劳,我该如果去化解它呢?如果在杭州,我会找几个朋友,周末一起出去,到西溪湿地,找片树荫下面的草坪,铺上野餐布,大家吃着零食,打打牌,聊聊天,有说有笑,将这在工作中积累下来的疲惫无声无息的散发给大自然。即便朋友不能陪我,我也可以自己到西湖边遛达遛达,到曲院风荷散散步,自己骑着自行车穿越于九溪的山林、树木、花草、溪流之间。等等等等,这一切可以接触到大自然的地方,都可以把我身心中的疲惫净化的干干净净。然而在上海,我却找不到这样的地方,当然也许是我来的时间还太短。但是看公司里的前辈,无论是上海本地人还是外地的,好像也没什么去处,在周末唯一解脱的方法就是睡觉,看电视,打打球。这种生活我不知道我能忍受多久。来上海之前我早就听说上海的生活很累,我对自己说:我不怕累,天将降降大任于斯人也,必先……,世上哪有不经过一番努力就得到成功的人!但是却没有想到,上海没有一个可以让身心得到片刻舒展的地方。都说上海是女人的天堂,因为上海的男人对自己的女人特别好,我当然不是反对男人把自己的女人当成宝贝,而是想说,在上海对于男人来说,似乎除了找个心爱的女人在身边陪伴,也没有其他的使自己的身心得到安慰的方式了。现在我知道为什么到上海感觉上海的人有些别扭,尤其是上海的中年男人,不论是本地人,还是外地人,都或多或少有些畸形,大概就是长期压抑的结果。上海的男人好可怜,而我也要成为这可怜人中一员了。而且现在是最可怜的状态,初来工作最辛苦,工资又低,既无法投入大自然的怀抱,也无法投入女人的怀抱,还好就是还没有积累太多的疲惫,使我看上去很畸形。 也许在看这篇随笔的你就是上海人,所以要提出异议,那可能是你在上海生活久了所以习惯了。但是我刚从杭州到上海确实不太习惯。
PS. System.out.println(上海人.equals(上海的人));〉false
转自:http://www.blogjava.net/mstar/archive/2005/09/17/13200.html
软件
公告
问题虚拟背景:A项目组要实现一个基于Sql Server的应用,但工作环境只安装有MySql(公司对开源比较看好: )),而且客户有可能会转移到Oracle数据库环境。要求应用具有数据库移植能力和快速更换能力,使应用在工作环境调试成功后能迅速转移到客户的Sql Server环境,而且将来可以方便地转向Oracle。
Andy提出的可用方案:1、使用标准JDBC2、使用抽象类定义数据访问单元3、定义具体数据源访问单元继承2中接口
代码示例:定义数据访问单元抽象类,包含数据访问逻辑
定义具体数据源访问单元
在调用数据访问层时,可以声明一个DataManager的引用,然后在构造器中实例化为具体子类,如:
以后要迁移到另一个数据库(有JDBC驱动),只需定义具体子类继承DataManager(如HsqlDataManager),然后修改资源文件中的DataManager名称(或者将new的类名改一下),不需要修改代码。
这兴许可以解释另一个问题:不赞成使用存储过程,而应将SQL语句嵌在代码中(适用于Java;微软注定.Net不会有平台移植性,数据库大都用Sql Server,所以写存储过程还是比较好的)。(我在我的一个Eclipse RCP项目里使用了这种模式,从Sql server 2000到Hsql,特别方便,看起来感觉也比较好)欢迎大家拍转,^_^
Job代表一个异步操作。要执行的操作在run方法里。
schedule后,任务在平台线程等待队列中排队,等待调度执行。调用方式1:
调用方式2:
DatabaseMetaData?接口有超过150个方法,根据提供的信息可以分为以下几类:
DatabaseMetaData?接口还有超过40个字段,这些字段用于DatabaseMetaData中各种方法的常量返回值。
这一章粗略介绍一下DatabaseMetaData接口,通过举例子对元数据方法进行分类,同时介绍一些新的方法。详细介绍请参考JDBC 4.0 类库规范
JDBC中的ResultSetMetaData接口将在第15章“结果集”介绍。
// con是一个Connection对象 DatabaseMetaData dbmd = con.getMetadata(); int maxLen = dbmd.getMaxTableNameLength();
代码示例 7-1 创建和使用DatabaseMetaData对象
判断是否支持某个特性的方法如下:
查看特性支持级别的方法:
方法返回一个整型的限制数。0表示没有限制或未知限制。
这些方法的完整定义见JDBC 4.0 类库规范(javadoc)。
JDBC 4.0 类库规范中有这些方法更新后的定义。
翻译进度请参考http://www.pgsqldb.org/twiki/bin/view/PgSQL/JDBC4说明书
这一章描述了JDBC类库实现在各个兼容级别要支持的特性。一个JDBC类库实现包含了一个JDBC驱动和底层数据源。兼容性定义了在驱动层之上要实现的特性。
任何没有提到的特性都是可选的。通常,如果底层数据源不支持,驱动不需要实现这个特性。
下列指导原则适合所有级别的兼容性:
与JDBC 1.0 类库兼容的驱动应满足以下条件:
JDBC 2.0类库中不赞成使用的构造器和方法: java.sql.CallableStatement.getBigDecimal(int, int)
java.sql.Date(int, int, int)java.sql.Date.getHours()java.sql.Date.getMinutes()java.sql.Date.getSeconds()java.sql.Date.setHours(int)java.sql.Date.setMinutes(int)java.sql.Date.setSeconds(int)
java.sql.DriverManager.getLogStream()java.sql.DriverManager.setLogStream(PrintStream?)
java.sql.PreparedStatement.setUnicodeStream(int, InputStream?, int)
java.sql.ResultSet.getBigDecimal(int, int)java.sql.ResultSet.getBigDecimal(String, int)java.sql.ResultSet.getUnicodeStream(int)java.sql.ResultSet.getUnicodeStream(String)
java.sql.Time(int, int, int)java.sql.Time.getDate()java.sql.Time.getDay()java.sql.Time.getMonth()java.sql.Time.getYear()java.sql.Time.setDate(int)java.sql.Time.setMonth(int)java.sql.Time.setYear(int)
java.sql.Timestamp(int, int, int, int, int, int, int)
也可参考http://www.pgsqldb.org/twiki/bin/view/PgSQL/兼容性
以下类和接口组成了JDBC类库
java.sql.AutoGeneratedKeys java.sql.Arrayjava.sql.BaseQueryjava.sql.BatchUpdateException java.sql.Blobjava.sql.CallableStatementjava.sql.ClientInfoException java.sql.Column java.sql.Clobjava.sql.Connectionjava.sql.DataSetjava.sql.DataTruncation java.sql.DatabaseMetaDatajava.sql.Date java.sql.Driverjava.sql.DriverManager java.sql.DriverPropertyInfo java.sql.NClobjava.sql.ParameterMetaDatajava.sql.PreparedStatementjava.sql.Query java.sql.QueryObjectFactory java.sql.QueryObjectGeneratorjava.sql.Refjava.sql.ResultSetjava.sql.ResultSetMetaDatajava.sql.RowIdjava.sql.RowIdLifeTime java.sql.Savepointjava.sql.SQLDatajava.sql.SQLDataException java.sql.SQLException java.sql.SQLInputjava.sql.SQLIntegrityConstraintViolationException java.sql.SQLInvalidAuthorizationSpecException java.sql.SQLNonTransientConnectionException java.sql.SQLNonTransientException java.sql.SQLOutputjava.sql.SQLPermissionjava.sql.SQLSyntaxErrorException java.sql.SQLTimeoutException java.sql.SQLTransactionRollbackException java.sql.SQLTransientConnectionException java.sql.SQLTransientException java.sql.SQLXMLjava.sql.SQLWarning java.sql.Statementjava.sql.Structjava.sql.Table java.sql.Time java.sql.Timestamp java.sql.Types java.sql.Update java.sql.Wrapper
下列类和接口是新增的或经过修改的。新的类和接口用粗体标出。
java.sql.AutoGeneratedKeys java.sql.BaseQuery java.sql.Blobjava.sql.CallableStatementjava.sql.ClientInfoException java.sql.Clobjava.sql.Column java.sql.Connectionjava.sql.DatabaseMetaDatajava.sql.NClob java.sql.PreparedStatementjava.sql.Query java.sql.QueryObjectFactory java.sql.QueryObjectGenerator java.sql.ResultSetjava.sql.RowId java.sql.RowIdLifeTime java.sql.SQLDataException java.sql.SQLExceptionjava.sql.SQLIntegrityConstraintViolationException java.sql.SQLInvalidAuthorizationSpecException java.sql.SQLNonTransientConnectionException java.sql.SQLNonTransientException java.sql.SQLSyntaxErrorException java.sql.SQLTimeoutException java.sql.SQLTransactionRollbackException java.sql.SQLTransientConnectionException java.sql.SQLTransientException java.sql.SQLXML java.sql.SQLWarningjava.sql.Statementjava.sql.Table java.sql.Typesjava.sql.Update java.sql.Wrapper javax.sql.CommonDataSource javax.sql.StatementEvent javax.sql.StatementEventListener
图5-1显示了java.sql包中关键类和接口之间的交互和关系,以及用于创建语句、设置参数、检索结果的方法。
图5-1 java.sql包中主要类和接口之间的关系
javax.sql.CommonDataSourcejavax.sql.ConnectionEvent javax.sql.ConnectionEventListenerjavax.sql.ConnectionPoolDataSourcejavax.sql.DataSourcejavax.sql.PooledConnectionjavax.sql.RowSetjavax.sql.RowSetEvent javax.sql.RowSetInternaljavax.sql.RowSetListenerjavax.sql.RowSetMetaDatajavax.sql.RowSetReaderjavax.sql.RowSetWriterjavax.sql.StatementEvent javax.sql.StatementEventListenerjavax.sql.XAConnectionjavax.sql.XADataSource
图5-2,图5-3,图5-4和图5-5显示了以下功能领域中关键类和接口之间的关系:DataSource对象,池化连接,分布式事务,行集。
图5-2 javax.sql.DataSource和java.sql.Connection之间的关系
图5-3 连接池化过程中涉及的关系
图5-4 分布式事务支持中涉及的关系
图5-5 行集涉及的关系
-- Main.Andyluo - 6 Oct 2005
Job代表一个异步操作。要执行的操作写在run方法里。
-- Main.Andyluo - 6 Oct 2005也可参照http://www.pgsqldb.org/twiki/bin/view/PgSQL/类和接口
==========================================================
概述
JDBC类库使得Java程序可以访问多个数据源,但在大多数情况下,这个数据源是关系数据库,并且通过SQL访问。然而,实现JDBC技术的驱动也可以基于其它的数据源,包括遗留文件系统和面向对象的系统。JDBC类库的一个主要目的就是提供一个应用程序访问多种数据源的标准接口。
这一章介绍JDBC类库的一些关键概念,并描述JDBC应用的两个通用环境及其中的功能实现。两层和三层模型都是能被实现在多个物理配置上的逻辑模型。
=================================================
4.1 创建连接
JDBC类库中的Connection接口代表了底层数据源的一个连接。
在典型场景中,JDBC应用程序使用两种机制连接到数据源:
1.DriverManager --- 这个类在JDBC 1.0中引入,它使用硬编码的URL来加载驱动。
2.DataSource --- 这个接口在JDBC 2.0可选包中引入。它优于DriverManager方式,因为它隐藏了数据源的详细信息。我们通过设置DataSource的属性来标明它代表的数据源。当getConnection方法被调用时,DataSource对象会返回一个对应的连接。我们可以通过改变DataSource的属性来使它指向另一个数据源,而不是改变程序代码。而且,即使DataSource的实现改变了,使用它的应用程序代码也不需要改变。
JDBC类库定义了两个DataSource的扩展来支持企业级应用,如下:
1.ConnectionPoolDataSource --- 支持物理连接的缓存和重用,这样可以提高应用的性能和可伸缩性。
2.XADataSource --- 提供可以使用在分布式事务中的连接。
=========================================================
4.2 执行SQL语句和操纵结果
连接建立后,我们可以使用JDBC类库对目标数据源进行查询和更新。JDBC类库提供了对大多数SQL2003通用特性的支持。由于各个厂商可能要支持不同的特性,JDBC类库提供了一个DatabaseMetadata接口。应用可以通过这个接口了解数据源是否支持某个特性。JDBC类库也定义了转义语义来支持特定厂商非标准的特性。转义语义使得我们可以访问与本地程序相同的SQL特性集,同时保持应用的可移植性。
应用通过使用Connection接口来设置事务属性和创建Statement, PreparedStatement和CallableStatement. 这些statement被用来执行SQL语句和检索结果。ResultSet接口封装了SQL查询的结果。语句也可以批处理,这样应用可以通过一次单元执行提交对数据源的多次更新。
RowSet接口扩展了ResultSet接口。它提供了一个比标准结果集功能更多的表数据容器。RowSet对象是Java Beans组件,它可以在中断数据库连接的情况下操纵数据。例如,一个RowSet实现可以被序列化从而传送到网络上,这对于吞吐量小的客户端尤为有用,因为这可以省去加载JDBC驱动和建立JDBC连接的开销。RowSet还可以使用定制的阅读器(Reader)来访问表格数据(不仅仅是关系数据库的数据)。甚者,RowSet对象可以在中断数据库连接的情况下更新数据,并在连接正常时通过一个定制的书写器(Writer)将更新写入数据源。
4.2.1 对SQL高级数据类型的支持
JDBC类库定义了SQL数据类型到JDBC数据类型的标准映射。映射也包含了对SQL2003高级数据类型如BLOB,CLOB,ARRAY,REF,STRUCT和DISTINCT的支持。JDBC驱动也可以实现多个用户自定义类型(UDTs,user-defined types)的映射,在这里,每个UDT映射到Java中的一个类。
JDBC类库也提供对外部数据的支持,例如数据源外部的一个文件。
========================================
4.3 两层模型
两层模型将功能分配到客户端和服务器端,如图4-1.
FIGURE 4-1 两层模型
客户端包含了应用和一个或多个JDBC驱动,这些应用负责下列内容:
* 表示逻辑
* 业务逻辑
* 对多语句事务(multiple-statement transactions)或分布式事务的管理
* 资源管理
在这个模型中,应用直接跟JDBC驱动打交道,包括建立和管理物理连接,以及处理底层数据源的相关细节。应用可以通过对数据源实现的了解来使用它的非标准特性或者提升性能。
模型的缺点:
* 将表示逻辑、业务逻辑和基础设施、系统级别的功能混淆在一起,不利于维护。
* 由于被绑定到特定的数据库,应用很难被移植。需要连接到多个数据库的应用要注意各个厂商实现的区别。
* 缺少可伸缩性。典型地,应用将从始至终占有一个或多个物理连接,缺少对并发应用的支持。在这个模型中,性能、可伸缩性和可靠性问题都是由JDBC驱动和底层数据源处理的。如果应用要跟多个驱动打交道,它需要注意每个驱动/数据源对是怎么处理这些问题的。
======================================================
4.4 三层模型
三层模型引入了中间层服务器来管理业务逻辑和基础结构,如图4-2.
FIGURE 4-2 三层模型
这个架构为企业级应用提供了更好的性能、可伸缩性和可靠性。功能划分如下:
1.客户端 --- 只负责表示逻辑,处理人机交互。Java应用程序、网页浏览器和PDA等都是典型的客户端。客户端与中间层应用交互,它不需要了解底层的基础结构和数据源实现。
2.中间层服务器 --- 中间层包含:
* 一些应用程序。这些应用负责跟客户端打交道和实现业务逻辑。如果应用包含与数据源的交互,它应该使用高层抽象,例如DataSource对象和逻辑连接,而不是底层的驱动程序类库。
* 一个应用服务器。提供支持大部分应用的基础结构。这可能包含管理和池化物理连接、管理事务和掩盖不同JDBC驱动的细节。最后一点使得应用更容易被移植。应用服务器可以使用J2EE服务器。它应该直接和JDBC驱动交互和提供高层应用使用的功能抽象。
* 一个或多个JDBC驱动。提供与底层数据源的连接,每个驱动使用底层数据源支持的特性来实现标准JDBC类库。驱动层需要掩盖SQL2003标准和底层数据源语言的不同。如果数据源不是一个关系型数据库管理系统(DBMS),那么驱动要实现应用服务器使用的关系层。
3.底层数据源 --- 存放数据的层。包含关系型数据库管理系统(relational DBMS),遗留文件系统,面向对象的DBMS,数据仓库,报表或者其他包装和表示数据的方式,只要有对应的支持JDBC类库的驱动。
===================================================
4.5 J2EE平台中的JDBC
J2EE组件,例如JSP,Servlets和EJB,经常需要利用JDBC类库访问关系型数据。当在J2EE组件里使用JDBC类库时,容器可能帮你管理事务和数据源(译者注:Container Managed Persistence,容器管理持久性)。这样,J2EE组件开发者就不直接使用JDBC类库的事务和数据源管理功能。详情请见J2EE平台规范。
=====================================================概述
这一章介绍JDBC类库的一些关键概念,并描述JDBC应用的两个通用环境及其中的功能实现。两层和三层模型都是能被实现在多个物理配置上的逻辑模型。=====================================================4.1 创建连接JDBC类库中的Connection接口代表了底层数据源的一个连接。
在典型场景中,JDBC应用程序使用两种机制连接到数据源:1.DriverManager --- 这个类在JDBC 1.0中引入,它使用硬编码的URL来加载驱动。2.DataSource --- 这个接口在JDBC 2.0可选包中引入。它优于DriverManager方式,因为它隐藏了数据源的详细信息。我们通过设置DataSource的属性来标明它代表的数据源。当getConnection方法被调用时,DataSource对象会返回一个对应的连接。我们可以通过改变DataSource的属性来使它指向另一个数据源,而不是改变程序代码。而且,即使DataSource的实现改变了,使用它的应用程序代码也不需要改变。
JDBC类库定义了两个DataSource的扩展来支持企业级应用,如下:1.ConnectionPoolDataSource --- 支持物理连接的缓存和重用,这样可以提高应用的性能和可伸缩性。2.XADataSource --- 提供可以使用在分布式事务中的连接。======================================================4.2 执行SQL语句和操纵结果 连接建立后,我们可以使用JDBC类库对目标数据源进行查询和更新。JDBC类库提供了对大多数SQL2003通用特性的支持。由于各个厂商可能要支持不同的特性,JDBC类库提供了一个DatabaseMetadata接口。应用可以通过这个接口了解数据源是否支持某个特性。JDBC类库也定义了转义语义来支持特定厂商非标准的特性。转义语义使得我们可以访问与本地程序相同的SQL特性集,同时保持应用的可移植性。
应用通过使用Connection接口来设置事务属性和创建Statement,PreparedStatement和CallableStatement. 这些statement被用来执行SQL语句和检索结果。ResultSet接口封装了SQL查询的结果。语句也可以批处理,这样应用可以通过一次单元执行提交对数据源的多次更新。
4.2.1 对SQL高级数据类型的支持 JDBC类库定义了SQL数据类型到JDBC数据类型的标准映射。映射也包含了对SQL2003高级数据类型如BLOB,CLOB,ARRAY,REF,STRUCT和DISTINCT的支持。JDBC驱动也可以实现多个用户自定义类型(UDTs,user-defined types)的映射,在这里,每个UDT映射到Java中的一个类。
========================================4.3 两层模型 两层模型将功能分配到客户端和服务器端,如图4-1. FIGURE 4-1 两层模型 客户端包含了应用和一个或多个JDBC驱动,这些应用负责下列内容: * 表示逻辑 * 业务逻辑 * 对多语句事务(multiple-statement transactions)或分布式事务的管理 * 资源管理
模型的缺点: * 将表示逻辑、业务逻辑和基础设施、系统级别的功能混淆在一起,不利于维护。 * 由于被绑定到特定的数据库,应用很难被移植。需要连接到多个数据库的应用要注意各个厂商实现的区别。 * 缺少可伸缩性。典型地,应用将从始至终占有一个或多个物理连接,缺少对并发应用的支持。在这个模型中,性能、可伸缩性和可靠性问题都是由JDBC驱动和底层数据源处理的。如果应用要跟多个驱动打交道,它需要注意每个驱动/数据源对是怎么处理这些问题的。
======================================================4.4 三层模型 三层模型引入了中间层服务器来管理业务逻辑和基础结构,如图4-2. FIGURE 4-2 三层模型 这个架构为企业级应用提供了更好的性能、可伸缩性和可靠性。功能划分如下: 1.客户端 --- 只负责表示逻辑,处理人机交互。Java应用程序、网页浏览器和PDA等都是典型的客户端。客户端与中间层应用交互,它不需要了解底层的基础结构和数据源实现。
2.中间层服务器 --- 中间层包含: * 一些应用程序。这些应用负责跟客户端打交道和实现业务逻辑。如果应用包含与数据源的交互,它应该使用高层抽象,例如DataSource对象和逻辑连接,而不是底层的驱动程序类库。 * 一个应用服务器。提供支持大部分应用的基础结构。这可能包含管理和池化物理连接、管理事务和掩盖不同JDBC驱动的细节。最后一点使得应用更容易被移植。应用服务器可以使用J2EE服务器。它应该直接和JDBC驱动交互和提供高层应用使用的功能抽象。 * 一个或多个JDBC驱动。提供与底层数据源的连接,每个驱动使用底层数据源支持的特性来实现标准JDBC类库。驱动层需要掩盖SQL2003标准和底层数据源语言的不同。如果数据源不是一个关系型数据库管理系统(DBMS),那么驱动要实现应用服务器使用的关系层。
===================================================4.5 J2EE平台中的JDBC J2EE组件,例如JSP,Servlets和EJB,经常需要利用JDBC类库访问关系型数据。当在J2EE组件里使用JDBC类库时,容器可能帮你管理事务和数据源(译者注:Container Managed Persistence,容器管理持久性)。这样,J2EE组件开发者就不直接使用JDBC类库的事务和数据源管理功能。详情请见J2EE平台规范。
其它章节的翻译参见:
http://www.pgsqldb.org/twiki/bin/view/PgSQL/JDBC4%E8%AF%B4%E6%98%8E%E4%B9%A6
=================================================================
序言
这个文档巩固了下面几个规范的内容:
“JDBC: Java的SQL类库”
“JDBC 2.1 类库”
“JDBC 2.0 标准扩展类库”
“JDBC 3.0 规范”
文档介绍了JDBC 4.0 类库的新特征和一些增强的特征。文档根据不同特征划分章节,这样可以更方便了解JDBC 4.0和3.0的不同之处。
读者如果想了解JDBC类库的详细信息,可以参考JDBC的类库文档(Javadoc),该文档可以由以下链接获得:
http://java.sun.com/products/jdbc
==========================================================================
介绍
1.1 JDBC类库
JDBC类库提供了通过Java语言访问关系数据库的能力。Java程序通过JDBC可以执行SQL语句,对获取的数据进行处理,并将变化了的数据存回数据库。在分布式异构环境中,我们还可以通过JDBC操纵多个数据源。
JDBC类库基于X/Open SQL通用语言接口(CLI),ODBC也基于此。JDBC提供了一个使用方便的映射方案:从Java语言到X/Open 通用语言接口和SQL标准的抽象实体及概念的映射。
自1997年的产生至今,JDBC类库已被广泛的接受和实现。类库的灵活性使得它可以有很多个具体实现。
1.2 平台
JDBC类库是Java平台的一部分。4.0版分为两个包:java.sql 和 javax.sql。这两个包都包含在JSE(Java桌面版)和JEE(Java企业版)中。
1.3 适合读者
该文档主要面向下列产品的开发者:
1. JDBC驱动程序
2. 基于数据库驱动提供三层架构服务的应用服务器
3. 使用JDBC类库来提供服务的工具
该文档想达到以下目的:
1.对使用JDBC类库的开发者的一个介绍
2.作为开发基于JDBC的类库的起始点
===============================================================
目标
2.1 历史
2.2 JDBC 4.0 之目标
---1.与JEE和JSE平台相处融洽
---2.与SQL:2003一致
---3.巩固前述四个规范
---4.提供中立于厂商的通用功能
---5.主要只针对SQL类型的数据源
---6.提供高层类库和工具的基础设施
---7.保持简单
---8.加强可靠性、可用性和可伸缩性
---9.保持向后兼容性
---10.与JDBC行集(RowSet)紧密联系
---11.与连接器架构(Connectors)兼容
---12.清晰描述JDBC需求
==================================================================
新特性概览
3.1 变更概览
JDBC 4.0 类库在以下领域注入了变化和新的元素:
1.自动加载java.sql.Driver
DriverManager.getConnection方法被修改以利用JSE的服务提供者机制来自动加载JDBC驱动。这样就不需要调用Class.forName方法了。
2.类库使用更容易
添加了标准JDBC注释。支持数据集(DataSet),使Java应用调用SQL数据源更加方便。
3.ROWID数据类型
添加了java.sql.RowID数据类型,使得JDBC程序可以访问SQL ROWID。
4.支持本地字符集转换(National Character Set Conversion)
添加了一些JDBC类型:NCHAR, NVARCHAR, LONGVARCHAR, NCLOB。对应的方法setNString, setNCharacterStream, setNClob也被添加到PreparedStatement接口中。
5.增强了对BLOB和CLOB的支持
Connection接口添加了生产BLOB,CLOB和NCLOB对象的方法。PreparedStatement接口添加了通过InputStream插入BLOB的方法和使用Reader插入CLOB,NCLOB的方法。Blob, Clob和NClob现在可以通过free方法释放资源。
6.SQL/XML和XML支持
SQL2003引入了用SQL表达XML数据的概念。一些类库被添加进来以支持应用对这些数据的访问。
7.包装器(Wrapper)模式
添加了解包JDBC实现的能力,使开发者可以利用在厂商实现中提供的非标准JDBC方法。
8.加强的SQLException
添加对JSE链式异常的支持。SQLException现在支持Iterable接口,所以我们可以在for-each循环里读取SQLExceptions。新添加了两类SQL异常:SQLTransientException和SQLNonTransientException。每个类都提供映射到普通SQLState类型值(译者注:SQLState?)的子类。
9.连接管理
Connection和Statement接口得到了增强,以利于对连接状态的跟踪,并增加在池环境中管理Statement对象的灵活性。
10.JDBC类库的变化
下面的JDBC接口被修改:
---10.1 Connection
添加了下列方法:createBlob, createClob, createNClob, createQueryObject, isValid, createXML, getClientInfo, setClientInfo。
---10.2 CallableStatement
添加了下列方法:getRowId, setRowId, getNClob, setNString, setNCharacterStream, setNClob, getSQLXML, setSQLXML。重载了setClob和setBlob方法。
---10.3 DatabaseMetaData
添加了下列方法:getRowIdLifetime, autoCommitFailureClosesAllResultSets, providesQueryObjectGenerator, getClientInfoProperties, supportsStoredFunctionsUsingCallSyntax. 重载了getSchemas方法。
---10.4 PreparedStatement
添加了下列方法:setRowId, setNString, setNCharacterStream, setSQLXML, isPoolable, setPoolable, setNClob。重载了setClob和setBlob方法。
---10.5 ResultSet
添加了下列方法:getHoldability, getRowId, updateRowID, getNClob, isClosed, updateNString, getSQLXML, updateSQLXML, updateNClob。
---10.6 Statement
添加了isClosed和getResultSetHoldability方法。
---10.7 DataSource
添加了createQueryObject方法。
---10.8 PooledConnection
添加了addStatementEventListener和removeStatementEventListener方法。
====================================================================
概览
JDBC类库使得Java程序可以访问多个数据源,但在大多数情况下,这个数据源是关系数据库,并且通过SQL访问。然而,实现JDBC技术的驱动也可以基于其它的数据源,包括遗留文件系统和面向对象的系统。
JDBC类库的主要目的就是提供应用程序访问多种数据源的标准接口。
这一章介绍JDBC类库的一些关键概念,并描述JDBC应用的两个通用环境及其中的功能实现。
2.DataSource --- 这个接口在JDBC 2.0可选包中引入。它优于DriverManager方式,因为它隐藏了数据源的详细信息。我们通过设置DataSource的属性来标明它代表的数据源。当getConnection方法被调用时,DataSource对象会返回一个对应的连接。我们可以通过改变DataSource的属性来使它指向另一个数据源,而不是改变程序代码。而且,如果DataSource的实现改变了,使用它的应用程序代码不需要改变。
JDBC类库也定义了两个DataSource的扩展,用来支持企业级应用,如下:
Chapter14 - END
14.批更新(Batch Update)---14.1 批更新概述-------14.1.1 Statements-------14.1.2 成功的执行-------14.1.3 在执行过程中处理失败-------14.1.4 PreparedStatement对象-------14.1.5 CallableStatement对象15.结果集(Result Sets)---15.1 结果集分类-------15.1.1 结果集类型-------15.1.2 结果集并发度-------15.1.3 结果集持久性(ResultSet Holdability)-------------15.1.3.1 决定结果集持久性-------15.1.4 设置结果集的类型、并发度和持久性---15.2 创建和操纵结果集-------15.2.1 创建结果集对象-------15.2.2 移动游标-------15.2.3 取值-------------15.2.3.1 数据类型转换-------------15.2.3.2 结果集元数据-------------15.2.3.3 取NULL值-------15.2.4 修改结果集-------------15.2.4.1 更新行-------------15.2.4.2 删除行-------------15.2.4.3 插入行-------------15.2.4.4 给定位置的更新和删除-------15.2.5 关闭结果集16.高级数据类型---16.1 SQL数据类型分类---16.2 SQL2003类型映射---16.3 Blob和Clob对象-------16.3.1 创建Blob和Clob对象-------16.3.2 在结果集中取BLOB和CLOB类型值-------16.3.3 访问Blob和Clob对象数据-------16.3.4 保存Blob和Clob对象-------16.3.5 更改Blob和Clob对象-------16.3.6 释放Blob和Clob资源---16.4 Array对象-------16.4.1 获取Array对象-------16.4.2 保存Array对象-------16.4.3 更新Array对象---16.5 Ref对象-------16.5.1 取REF值-------16.5.2 获取Ref引用的对象-------16.5.3 保存Ref对象-------16.5.4 保存Ref引用的对象-------16.5.5 元数据---16.6 DISTINCT类型-------16.6.1 获取DISTINCT类型-------16.6.2 保存DISTINCT类型-------16.6.3 元数据---16.7 结构化类型-------16.7.1 获取结构化类型-------16.7.2 保存结构化类型-------16.7.3 元数据---16.8 数据链接-------16.8.1 获取外部数据的引用-------16.8.2 保存外部数据的引用-------16.8.3 元数据17.定制类型映射---17.1 类型映射---17.2 类转换---17.3 SQL数据流-------17.3.1 取数据-------17.3.2 保存数据---17.4 示例-------17.4.1 一个SQL结构化类型-------17.4.2 SQLData的实现-------17.4.3 SQL类型继承在Java语言中的镜像-------17.4.4 SQL DISTINCT类型映射示例---17.5 转换组(Transform Groups)的作用---17.6 映射的普遍性---17.7 NULL数据18.和连接器(Connectors)的关系---18.1 系统约定---18.2 映射连接器系统约定到JDBC接口---18.3 用连接器的RAR文件格式将JDBC驱动打包19. SQL ROWID---19.1 RowId合理(Validity)期限---19.2 取RowId值---19.3 使用RowId20.新添的开发利器---20.1 概览-------20.1.1 JDBC注释(Annotations)-------20.1.2 Query接口-------20.1.3 BaseQuery接口-------20.1.4 DataSet接口-------20.1.5 自定义类-------20.1.6 QueryObjectGenerator接口---20.2 创建实现Query接口的实例-------20.2.1 创建一个Query接口-------20.2.2 Query接口的具体实现-------------20.2.2.1 Connection.createQueryObject和DataSource.createQueryObject方法-------------20.2.2.2 调用Query接口的方法-------------20.2.2.3 关闭Query对象---20.3 JDBC注释(Annotations)-------20.3.1 Query注释-------------20.3.1.1 sql注释成员-------------20.3.1.2 readOnly注释成员-------------20.3.1.3 connected注释成员-------------20.3.1.4 allColumnsMapped注释成员-------------20.3.1.5 scrollable注释成员-------------20.3.1.6 参数化的sql注释成员-------20.3.2 Update注释-------------20.3.2.1 sql注释成员-------------20.3.2.2 keys注释成员-------------20.3.2.3 返回影响行数-------------20.3.2.4 参数化的sql注释成员-------20.3.3 Column注释-------------20.3.3.1 name注释成员-------------20.3.3.2 uniqueIdentifier注释成员-------20.3.4 AutoGeneratedKeys注释-------20.3.5 Table注释-------------20.3.5.1 name注释成员---20.4 数据集(DataSet)参数化类型-------20.4.1 创建数据集参数化类型实例-------20.4.2 操纵数据集-------------20.4.2.1 查看数据集-------------20.4.2.2 将数据集转换成行集(RowSet)-------------20.4.2.3 创建当前行的一个拷贝-------------20.4.2.4 插入行-------------20.4.2.5 删除行-------------20.4.2.6 修改行-------------20.4.2.7 关闭数据集对象-------------20.4.2.8 同步数据集对象---20.5 QueryObjectFactory类-------20.5.1 QueryObjectFactory的方法-------------20.5.1.1 createDefaultQueryObject方法-------------20.5.1.2 createQueryObject方法-------20.5.2 管理事务21.SQL2003和XML22.包装器(Wrapper)附录A.修正历史附录B.数据类型转换表附录C.标量方法(Scalar Functions)------C.1 数字方法------C.2 字符串方法------C.3 时间和日期方法------C.4 系统方法------C.5 转换方法附录D.JDBC注释------D.1 AutogeneratedKeys(自动生成关键字)注释------D.2 Query(查询)注释------D.3 Update(更新)注释------D.4 Column(列)注释------D.5 Table(表)注释附录E.相关文档
英文原文:14. Batch Updates 11714.1 Description of Batch Updates 11714.1.1 Statements 11714.1.2 Successful Execution 11814.1.3 Handling Failures during Execution 11914.1.4 PreparedStatement Objects 12014.1.5 CallableStatement Objects 121
15. Result Sets 12315.1 Kinds of ResultSet Objects 12315.1.1 ResultSet Types 12315.1.2 ResultSet Concurrency 12415.1.3 ResultSet Holdability 12515.1.3.1 Determining ResultSet Holdability 12515.1.4 Specifying ResultSet Type, Concurrency and Holdability 12615.2 Creating and Manipulating ResultSet Objects 12615.2.1 Creating ResultSet Objects 12615.2.2 Cursor Movement 12715.2.3 Retrieving Values 12815.2.3.1 Data Type Conversions 12915.2.3.2 ResultSet Metadata 12915.2.3.3 Retrieving NULL values 12915.2.4 Modifying ResultSet Objects 12915.2.4.1 Updating a Row 13015.2.4.2 Deleting a Row 13115.2.4.3 Inserting a Row 13215.2.4.4 Positioned Updates and Deletes 13315.2.5 Closing a ResultSet Object 134
16. Advanced Data Types 13516.1 Taxonomy of SQL Types 13516.2 Mapping of SQL2003 Types 13716.3 Blob and Clob Objects 13716.3.1 Creating Blob and Clob Objects 13716.3.2 Retrieving BLOB and CLOB Values in a ResultSet 13816.3.3 Accessing Blob and Clob Object Data 13816.3.4 Storing Blob and Clob Objects 13916.3.5 Altering Blob and Clob Objects 14016.3.6 Releasing Blob and Clob Resources 14016.4 Array Objects 14116.4.1 Retrieving Array Objects 14116.4.2 Storing Array Objects 14116.4.3 Updating Array Objects 14216.5 Ref Objects 14216.5.1 Retrieving REF Values 14216.5.2 Retrieving the Referenced Value 14316.5.3 Storing Ref Objects 14316.5.4 Storing the Referenced Value 14316.5.5 Metadata 14416.6 Distinct Types 14416.6.1 Retrieving Distinct Types 14416.6.2 Storing Distinct Types 14516.6.3 Metadata 14516.7 Structured Types 14616.7.1 Retrieving Structured Types 14616.7.2 Storing Structured Types 14616.7.3 Metadata 14716.8 Datalinks 14716.8.1 Retrieving References to External Data 14816.8.2 Storing References to External Data 14816.8.3 Metadata 148
17. Customized Type Mapping 14917.1 The Type Mapping 14917.2 Class Conventions 15017.3 Streams of SQL Data 15117.3.1 Retrieving Data 15117.3.2 Storing Data 15217.4 Examples 15317.4.1 An SQL Structured Type 15317.4.2 SQLData Implementations 15517.4.3 Mirroring SQL Inheritance in the Java Programming Language 15917.4.4 Example Mapping of SQL DISTINCT Type 16017.5 Effect of Transform Groups 16117.6 Generality of the Approach 16217.7 NULL Data 162
18. Relationship to Connectors 16518.1 System Contracts 16518.2 Mapping Connector System Contracts to JDBC Interfaces 16618.3 Packaging JDBC Drivers in Connector RAR File Format 167
19. SQL ROWID 16919.1 Lifetime of RowId Validity 16919.2 Retrieving RowId Values 17019.3 Using RowId Values 170
20. Ease of Development 17320.1 Overview 17320.1.1 JDBC Annotations 17320.1.2 Query Interface 17420.1.3 BaseQuery Interface 17420.1.4 DataSet interface 17420.1.5 User-Defined Class 17520.1.6 QueryObjectGenerator Interface 17620.2 Creating an instance of a Query interface 17620.2.1 Creating a Query Interface 17620.2.2 Concrete Query Interface implementation 17720.2.2.1 Connection.createQueryObject and DataSource.createQueryObject methods 17720.2.2.2 Invoking Query Interface Methods 17820.2.2.3 Closing a Query Object 17820.3 JDBC Annotations 17820.3.1 Query Annotation 17920.3.1.1 sql annotation element 17920.3.1.2 readOnly annotation element 18020.3.1.3 connected annotation element 18020.3.1.4 allColumnsMapped annotation element 18020.3.1.5 scrollable annotation element 18220.3.1.6 Parameterized sql Annotation element 18220.3.2 Update Annotation 18320.3.2.1 sql annotation element 18320.3.2.2 keys annotation element 18420.3.2.3 Returning an Update Count 18420.3.2.4 Parameterized sql Annotation element 18420.3.3 Column Annotation 18520.3.3.1 name annotation element 18520.3.3.2 uniqueIdentifier annotation element 18620.3.4 AutoGeneratedKeys annotation 18720.3.5 Table Annotation 18820.3.5.1 name annotation element 18820.4 DataSet Parameterized Type 18920.4.1 Creating a DataSet Parameterized Type Instance 19020.4.2 Manipulating a DataSet 19020.4.2.1 Traversing a DataSet 19120.4.2.2 Converting a DataSet to a RowSet 19120.4.2.3 Creating a copy of the Current Row 19120.4.2.4 Inserting Rows 19120.4.2.5 Deleting Rows 19320.4.2.6 Modifying Rows 19320.4.2.7 Closing a DataSet Object 19420.4.2.8 Synchronizing a DataSet 19420.5 QueryObjectFactory Class 19520.5.1 QueryObjectFactory Methods 19520.5.1.1 createDefaultQueryObject method 19520.5.1.2 createQueryObject method 19620.5.2 Managing Transactions 196
21. SQL:2003 and XML 197
22. Wrapper 199
A. Revision History 201B. Data Type Conversion Tables 203C. Scalar Functions 211C.1 NUMERIC FUNCTIONS 211C.2 STRING FUNCTIONS 212C.3 TIME and DATE FUNCTIONS 213C.4 SYSTEM FUNCTIONS 213C.5 CONVERSION FUNCTIONS 214D. JDBC Annotations 215D.1 AutogeneratedKeys Annotation 215D.2 Query Annotation 215D.3 Update Annoation 216D.4 Column Annotation 216D.5 Table Annotation 216E. Related Documents 217
欢迎提出修改意见
Chapter9 - Chapter139.事务---9.1 事务边界和自动提交(Auto-commit)------9.1.1 禁用自动提交模式---9.2 事务隔离级别------9.2.1 使用setTransactionIsolation方法------9.2.2 性能考虑---9.3 保存点(Savepoints)------9.3.1 设置和回滚保存点------9.3.2 释放(release)保存点10.连接---10.1 驱动程序分类---10.2 Driver接口-------10.2.1 加载一个实现了java.sql.Driver接口的驱动---10.3 DriverManager类-------10.3.1 SQLPermission类---10.4 DataSource接口-------10.4.1 DataSource属性-------10.4.2 JNDI类库和应用移植能力(Application Portability)-------10.4.3 用DataSource对象获得连接11.连接池---11.1 ConnectionPoolDataSource类和PooledConnection类---11.2 连接事件---11.3 三层架构中的连接池---11.4 DataSource的实现和连接池---11.5 部署---11.6 用池连接(Pooled Connections)实现语句(Statement)重用-------11.6.1 使用池语句(Pooled Statement)-------11.6.2 关闭池语句---11.7 ConnectionPoolDataSource类的属性12.分布式事务---12.1 基础设施---12.2 XADataSource和XAConnection接口-------12.2.1 部署一个XADataSource对象-------12.2.2 获得一个连接---12.3 XAResource接口---12.4 事务管理-------12.4.1 两阶段提交---12.5 关闭连接---12.6 XAResource接口的局限13.语句(Statements)---13.1 Statement接口-------13.1.1 创建Statements-------------13.1.1.1 设置ResultSet的相关特征-------13.1.2 执行Statement-------------13.1.2.1 返回ResultSet对象-------------13.1.2.2 返回影响行数(Update Count)-------------13.1.2.3 使用execute方法-------13.1.3 关闭Statement---13.2 PreparedStatement接口-------13.2.1 创建PreparedStatement对象-------------13.2.1.1 设置ResultSet的相关特征-------13.2.2 参数设置-------------13.2.2.1 类型转换-------------13.2.2.2 本地字符集转换(National Character Set Conversions)-------------13.2.2.3 使用setObject方法进行类型转换-------------13.2.2.4 设置NULL参数-------13.2.3 描述PreparedStatement的输出和输入-------13.2.4 执行PreparedStatement-------------13.2.4.1 返回ResultSet对象-------------13.2.4.2 返回影响行数-------------13.2.4.3 使用execute方法---13.3 CallableStatement接口-------13.3.1 创建CallableStatement对象-------13.3.2 参数设置-------------13.3.2.1 IN参数-------------13.3.2.2 OUT参数-------------13.3.2.3 INOUT参数-------13.3.3 执行CallableStatement-------------13.3.3.1 返回单个ResultSet对象-------------13.3.3.2 返回影响行数-------------13.3.3.3 返回Unknown或多个结果---13.4 转义语法(Escape Syntax)-------13.4.1 标量方法(Scalar Functions)-------13.4.2 日期和时间字符串-------13.4.3 外联结(Outer Joins)-------13.4.4 存储过程-------13.4.5 LIKE转义符---13.5 性能提示(Hints)---13.6 获取由数据库自动生成的关键字英文原文:9. Transactions 539.1 Transaction Boundaries and Auto-commit 539.1.1 Disabling Auto-commit Mode 549.2 Transaction Isolation Levels 559.2.1 Using the setTransactionIsolation Method 569.2.2 Performance Considerations 569.3 Savepoints 579.3.1 Setting and Rolling Back to a Savepoint 579.3.2 Releasing a Savepoint 58
10. Connections 5910.1 Types of Drivers 6010.2 The Driver Interface 6010.2.1 Loading a driver that implements java.sql.Driver 6110.3 The DriverManager Class 6110.3.1 The SQLPermission Class 6310.4 The DataSource Interface 6310.4.1 DataSource Properties 6410.4.2 The JNDI API and Application Portability 6510.4.3 Getting a Connection with a DataSource Object 66
11. Connection Pooling 6711.1 ConnectionPoolDataSource and PooledConnection 6911.2 Connection Events 7011.3 Connection Pooling in a Three-tier Environment 7111.4 DataSource Implementations and Connection Pooling 7211.5 Deployment 7411.6 Reuse of Statements by Pooled Connections 7511.6.1 Using a Pooled Statement 7611.6.2 Closing a Pooled Statement 7711.7 ConnectionPoolDataSource Properties 78
12. Distributed Transactions 8112.1 Infrastructure 8112.2 XADataSource and XAConnection 8412.2.1 Deploying an XADataSource Object 8512.2.2 Getting a Connection 8612.3 XAResource 8612.4 Transaction Management 8712.4.1 Two-phase Commit 8812.5 Closing the Connection 9012.6 Limitations of the XAResource Interface 90
13. Statements 9313.1 The Statement Interface 9313.1.1 Creating Statements 9313.1.1.1 Setting ResultSet Characteristics 9413.1.2 Executing Statement Objects 9413.1.2.1 Returning a ResultSet object 9513.1.2.2 Returning an Update Count 9513.1.2.3 Using the Method execute 9513.1.3 Closing Statement Objects 9613.2 The PreparedStatement Interface 9713.2.1 Creating a PreparedStatement Object 9713.2.1.1 Setting ResultSet Characteristics 9713.2.2 Setting Parameters 9813.2.2.1 Type Conversions 9813.2.2.2 National Character Set Conversions 9913.2.2.3 Type Conversions Using the Method setObject 9913.2.2.4 Setting NULL Parameters 10013.2.3 Describing Outputs and Inputs of a PreparedStatementObject 10113.2.4 Executing a PreparedStatement Object 10213.2.4.1 Returning a ResultSet Object 10213.2.4.2 Returning a Row Count 10213.2.4.3 Using the Method execute 10313.3 The CallableStatement Interface 10313.3.1 Creating a CallableStatement Object 10413.3.2 Setting Parameters 10413.3.2.1 IN Parameters 10513.3.2.2 OUT Parameters 10513.3.2.3 INOUT Parameters 10613.3.3 Executing a CallableStatement Object 10613.3.3.1 Returning a Single ResultSet Object 10713.3.3.2 Returning a Row Count 10713.3.3.3 Returning Unknown or Multiple Results 10713.4 Escape Syntax 10913.4.1 Scalar Functions 11013.4.2 Date and Time Literals 11113.4.3 Outer Joins 11113.4.4 Stored Procedures 11213.4.5 LIKE Escape Characters 11313.5 Performance Hints 11313.6 Retrieving Auto Generated Keys 113欢迎提出修改意见
/*Modified in 2005/9/27 by Andyluo."简介" change to "序言""目标听众" change to "适合读者""兼容性" change to "服从规则"*/序言 *排版格式提交反馈
1.介绍---1.1 JDBC 类库---1.2 平台---1.3 适合读者 *---1.4 鸣谢2.目标---2.1 历史---2.2 目标概要3.新特性概览---3.1 变动概要4.概要---4.1 建立连接---4.2 执行SQL语句和操纵结果------4.2.1 对高级SQL数据类型的支持---4.3 两层模型---4.4 三层模型---4.5 J2EE中的JDBC5.类和接口---5.1 java.sql包---5.2 javax.sql包6.服从规则(Compliance) *---6.1 定义---6.2 指导原则和要求---6.3 JDBC 1.0 API的服从规则---6.4 JDBC 2.0 API的服从规则---6.5 JDBC 3.0 API的服从规则---6.6 JDBC 4.0 API的服从规则---6.7 决定服从级别---6.8 不赞成使用的API7.数据库元数据(Database Metadata)---7.1 创建DatabaseMetadata对象---7.2 获取概要(general)信息---7.3 决定要支持的特性---7.4 对数据源的限制---7.5 SQL对象及其属性---7.6 对事务的支持---7.7 新加入的方法---7.8 经过修改的方法8.异常---8.1 SQLException类------8.1.1 对JSE中链式异常的支持------8.1.2 察看SQLException-----------8.1.2.1 使用ForEach循环体察看SQLException---8.2 SQLWarning类---8.3 DataTruncation类------8.3.1 不出声地截断(Silent Truncation)---8.4 BatchUpdateException类---8.5 SQL异常分类------8.5.1 非暂态SQL异常------8.5.2 暂态SQL异常英文原文:Preface 1Typographic Conventions 2Submitting Feedback 2
1. Introduction 31.1 The JDBC API 31.2 Platforms 31.3 Target Audience 41.4 Acknowledgements 4
2. Goals 72.1 History 72.2 Overview of Goals 7
3. Summary of New Features 113.1 Overview of changes 11
4. Overview 154.1 Establishing a Connection 154.2 Executing SQL Statements and Manipulating Results 164.2.1 Support for SQL Advanced Data Types 174.3 Two-tier Model 174.4 Three-tier Model 184.5 JDBC in the J2EE Platform 20
5. Classes and Interfaces 215.1 The java.sql Package 215.2 The javax.sql Package 26
6. Compliance 316.1 Definitions 316.2 Guidelines and Requirements 326.3 JDBC 1.0 API Compliance 336.4 JDBC 2.0 API Compliance 336.5 JDBC 3.0 API Compliance 346.6 JDBC 4.0 API Compliance 356.7 Determining Compliance Level 356.8 Deprecated APIs 36
7. Database Metadata 397.1 Creating a DatabaseMetadata Object 407.2 Retrieving General Information 407.3 Determining Feature Support 417.4 Data Source Limits 417.5 SQL Objects and Their Attributes 427.6 Transaction Support 427.7 New Methods 427.8 Modified Methods 43
8. Exceptions 458.1 SQLException 458.1.1 Support for the J2SE Chained Execeptions 468.1.2 Navigating SQLExceptions 468.1.2.1 Using a For-Each Loop with SQLExceptions 478.2 SQLWarning 488.3 DataTruncation 488.3.1 Silent Truncation 498.4 BatchUpdateException 498.5 Categorized SQLExceptions 508.5.1 NonTransient SQLExceptions 508.5.2 Transient SQLExceptions 51欢迎提出修改意见!
JSR 221Early DraftJune 02, 2005
JDBC是一个包含在JSE(Java桌面版)和JEE(Java企业版)里的API,它提供几乎所有SQL数据库之间的跨DBMS(数据库管理系统)连接,和对报表和文本文件等表格数据源(tabular data sources)的访问。通过一个JDBC的驱动程序,我们能聚集处在不同环境中(heterogeneous environment)的企业数据。
JDBC technology is an API (included in both J2SE and J2EE releases) that provides cross-DBMS connectivity to a wide range of SQL databases and access to other tabular data sources, such as spreadsheets or flat files. With a JDBC technology-enabled driver, you can connect all corporate data even in a heterogeneous environment.
历史
往事如风
函数内定义的局部变量的栈内存在函数结束后就会被释放,
但用{}隔开的作用域里定义的局部变量不会在离开作用域时马上释放掉
(见《高质量C++编程指南》P51,7.7杜绝野指针)
<My Opinion: 局部变量的内存释放发生于函数结束,与作用域无关>
将CString类型的变量转化成char*:
char* keyChar = key.GetBuffer(0); //key为CString类型
...
key.ReleaseBuffer(); //用完CString后记得释放缓冲
刚开始用C++,以前都是用的Java,希望Everything will go pretty well!
关键词: HSQL DB, Eclipse 3.1, Apache Commons, Swing Hacks
16:59 2005-7-23
在HSQL DB里,一个Database由四个文件组成:(如数据库test)
test.properties
test.script
test.log
test.data
test.backup
propertiest文件定义数据库的基本设置;
script包含数据库表和数据库对象的定义,还有non-cached tables的数据;
log包含最近对数据库进行的操作;
data包含被缓存表(cached tables)
HSqlDB的JDBC方法分为:
连接相关的方法
元数据方法
数据库访问方法
用Hsql建立数据库:
在一个项目里执行建立数据库的代码,生成的数据库在Workspace对应的项目文件夹下;
而在一个项目里调用另一个项目的生成数据库的方法,生成的数据库在Eclipse Home文件夹下
Indicate things are happening in the view –only through jobs
***getSite().getAdapter(IWorkbenchSiteProgressService.class)***
Eclipse3.1的一些新特性:
Open Untitled File
A text editor can be opened without creating a file first.
Simply go to File > New > Untitled Text File.
Text编辑器也开始支持超链接了,按住Ctrl键,将鼠标放在URL的上面就可以了
我以前写过一篇制作和使用库插件的文章,制作库插件得花一点时间,但在3.1里做就非常方便了,
可以直接将第三方库转换为库插件:
Create a plug-in from existing JAR
PDE now provides a wizard that creates a plug-in from existing JAR archives.
This wizard is ideal if you would like to package third-party non-Eclipse JARs as an
Eclipse plug-in.
The wizard can be invoked via File > New > Project > Plug-in from existing JAR archives.
Java SE6(Mustang)要提供中文的Doc了,尽管用英文的Doc已经习惯了,但对于大多数程序员来说
也是一件好事啊。呵呵(见blog图Excellence)
18:03 2005-8-3
Apache Commons Lang中的一些方法
首字母大写打印字符串:StringUtils.capitalize(string);
打印布尔值,用Yes或No表示:BooleanUtils.toStringYesNo(true);
求一个数值数组中的最大值: NumberUtils.max(array);
打印数组:ArrayUtils.toString(array);
测试数值是否在某一范围:
Range range = new DoubleRange(90,120);
range.containsDouble(102.5);
随机数:RandomUtils.nextInt(100);
测试字符串是否为数值:NumberUtils.isNumber(string/*eg. 0x3F*/);
String的split方法有时会得到意外的结果:
"aaa|bbb|ccc".split("|") 结果:{,a,a,a,}
用"aaa|bbb|ccc".split("\\|")才能得到正确结果,*和+也是如此
6:58 2005-8-6
w.k. Eclipse3.1垃圾回收后只占18M内存,我现在可以一直开着Eclipse了,呵呵
11:19 2005-8-7
找出Java反编译利器DJ,打算破解IDEA。
9:09 2005-8-8
晕,发现Eclipse的帮助不能显示了,显示找不着org.eclipse.help.internal.webapp.data包,
找到webapp的插件目录,发现里面的web-inf目录是小写的,里面lib目录包含的servlet.jar
刚好包括了org.eclipse.help.internal.webapp.data包,可以肯定是web-inf目录小写的缘故,
但为什么会变成小写的呢,我的D盘数据通过ghost从俱乐部的机器上拷过来的,以前好像听说过
一些软件不支持大小写,不出意外的话,就是ghost帮我改的咯。
16:00 2005-8-10
看一个项目的源代码时,如果出现字符方面的错误,有可能是Encoding没有设置好,
看看Readme要求怎么设(一般要设为UTF-8)
19:30 2005-8-11
运行程序和浏览URL(包括mailto:):
/** Launch default browser on Windows */
if (GlobalSettings.isWindows())
{
Program.launch(localHref);
}
19:38 2005-8-11
mailto:?body=TheEmailBody&subject=TheSubject
15:14 2005-8-12
将Shell最小化:shell.setMinimized(true);
18:19 2005-8-18
JDK5.0文档,CHM版本的:
http://www.matrix.org.cn/resource/upload/content/2005_07_30_191519_vorbArhhNZ.chm
22:47 2005-8-25
Get Large File Icons
Not to leave Windows lonely, here is an undocumented class that will let you obtain large desktop icons and other file information. The FileSystemView only provides access to file icons of a "default" size, which usually means 16 by 16 pixels. If you look at your operating system desktop, however, you may see icons that are much bigger, with more detail. There is no standardized way of getting to the larger icons, but on Windows you can use the hidden class called sun.awt.shell.ShellFolder to retrieve larger (32 by 32) desktop file icons. This class is only available in Sun's JVM, so it won't work with other vendors, or on other platforms.
The code below will take a filename and show the file's large icon in a window.
public class LargeIconTest {
public static void main(String[] args) throws Exception {
// Create a File instance of an existing file
File file = new File(args[0]);
// Get metadata and create an icon
sun.awt.shell.ShellFolder sf =
sun.awt.shell.ShellFolder.getShellFolder(file);
Icon icon = new ImageIcon(sf.getIcon(true));
System.out.println("type = " + sf.getFolderType());
// show the icon
JLabel label = new JLabel(icon);
JFrame frame = new JFrame();
frame.getContentPane().add(label);
frame.pack();
frame.show();
ShellFolder is a wrapper for the metadata of the selected file. From this object, you can retrieve both the icon and a text description of the file's type. If you run this on an MP3 file, it might print the string "type = MPEG Layer 3 Audio" and show a 32 by 32 pixel iTunes MP3 icon.
Change the Look and Feel of an App from the Command Line
Sometimes, Swing applications don't provide a way to change a look and feel at runtime. When using an application like this, you can override the default look and feel with your own setting from the command line using the swing.defaultlaf property.
java -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel
myapp.MainClass
You can also use this technique to apply a new look and feel that the original developer never thought of.
Hacks for the Metal Look and Feel
There are a variety of undocumented properties that control the look of Metal, Swing's cross-platform look and feel. JTree nodes can have lines connecting children to their parent, but depending on your current setup, the lines may or may not be showing. You can control the lines with a client property called JTree.lineStyle. Add this code after you create your JTree.
// show the lines in a JTree
tree.putClientProperty("JTree.lineStyle", "Angled");
// hide the lines in a jtree
tree.putClientProperty("JTree.lineStyle", "None");
One of the big complaints about Metal is that the menus and labels use bold fonts. With another quick undocumented system property, you can turn that off.
java -Dswing.boldMetal=false myapp.MainClass
You can also turn on the rollover for JToolBar buttons by using a secret property. A rollover is useful because it gives the user visual feedback that the mouse cursor is over the right place. Given the size of the typical toolbar button, this feedback is essential.
toolbar.putClientProperty("JToolBar.isRollover",Boolean.TRUE);
There is a longer (though, by no means comprehensive) list of properties on this wiki page. Swing, and Metal in particular, has lots of undocumented system properties. As you discover them, please add your own comments to the wiki page. Also remember that these are undocumented for a reason, and could easily change or go away in the future. Use them at your own risk.
Conclusion
Swing is a powerful toolkit with lots of hidden features that you can use to bring out the best in your application. This article documents just a few interesting techniques. Swing Hacks from O'Reilly covers another 100 hacks to improve your software. None of the techniques I've shown are required features, but they can add a level of polish that will make your apps stand out from the rest. And in a crowded software marketplace, anything that makes your program better than the competition is a good thing.
我比较喜欢看技术方面的文章,每次都是看RSS的时候将链接拖到MyIE,然后统一来看,有时候机房要关门了也没看完,我就从任务管理器里将MyIE的进程关掉,这样下次打开MyIE时选择打开上次关闭的网页就可以继续看了。
在我的快速启动栏上有三个记事本的快捷方式,一个连到文档中的Problem.txt,用于记录一些要完成的任务、程序中需要新增的功能。都是什么时候想到就什么时候记上去,比较方便。第二个连到Task.txt,用于记录要看的一些技术或要试用的软件,都是在看技术文章时记下来的。
使用FreeTextEditor预览Blog
使用http://xmlbuddy.com/ XmlBuddy Plugin
看Eclipse的VS.net皮肤http://www.sf.net/projects/eclipse-skins
看developworks上的Opensource中“SWT&JFace系列”
RCP(eclipse.org/rcp) RIA看收藏
开发一个远程桌面辅助程序。
将ImageAnalyser改为standalone
Wink(Screencast)在安装程序
The Eclipse 3.1 has a new feature. Now the Java project settings like Compiler and Code Style can be shared with the entire team using the version control tool.
To do this right click the project in Package Explorer or Navigator view and got to either Java Code Style or Java Compiler options. Check the Enable project specific settings.
This will create a .settings folder in the project root. Eclipse will add and maintain the project specific configuration in this folder. Commit this folder to the version control. Thats it. Now the project settings are shared with the team. When the other team members synchronize with the repository they will get the project settings too. Any team member can update and check in the settings. Cool!
The wizard in this code is a standard wizard that displays pages, then generates code in the doFinish method. What is most interesting about this class is that in performFinish, it demonstrates how to interact with Eclipse's process monitor for tasks that take a long time.
This code is a simple SWT wizard page. The most interesting characteristic of this class is in the handleBrowse method. This method uses Eclipse's ContainerSelectionDialog for displaying the folders in the workspace.
The JBoss TrailBlazer is a collection of interactive demos, runnable sample applications, technical articles, and other materials to help developers learn a new technology. These are part of JBoss's latest effort to make enterprise Java more easily accessible to everyone. There are currently two EJB 3.0 related TrailBlazer applications. They are hosted on the latest JBoss AS 4.0.3 RC1, which comes with full EJB 3.0 support out-of-the-box, and is available for generic public over the Internet.
在Eclipse的插件体系中,所有的类库文件都是以插件的形式存在的。如果你的Plugin项目要用到第三方API库或者另一个工程的API,你可以将他们包装成一个插件,这就是库插件的含义。
在我们小组的设计中,Plugin和控制逻辑是分成两个工程单独开发的,Plugin主要实现界面功能,通过调用控制逻辑实现数据存储、Blog发布、打印等功能,所以接触到了制作库插件这个过程,现在写下来,希望有点帮助。
如何制作库插件:将库工程转换为Plugin工程,在MANIFEST.MF的overview里定义ID,在Runtime里加入你要公开的包(Exported Packages)。OK
如何使用库插件,主要分为三步:1、在Dependencies Tab的Required Plug-ins中加入你的库插件(保证输出项目时导出相应的库插件)2、然后Compute build path(使项目能够顺利通过编译)3、在运行对话框的Plugin Tab里单击Add required plugins,这样项目才能正常运行有一点忘了就会挺郁闷的! RCP Eclipse Plugin
详细的制作Help过程我就不说了,在这里可以找到。
要注意三个问题:1、添加的插件要齐全,使用Help要增加以下几个插件:org.apache.ant org.apache.lucene org.eclipse.help.appserver org.eclipse.help.base org.eclipse.help.ui org.eclipse.help.webapp org.eclipse.tomcat 2、在Build里添加html文件的信息,使html文件能正确导出,如:bin.includes = plugin.xml,\ *.jar,\ plugin.properties,\ book.xml,\ html/,\ icons/3、在html文件中不能有中文的链接(显示为乱码,服务器会提示找不到该文件),所以html和图片的名称尽量用英文,内容用中文倒没有问题。
org.apache.ant
org.apache.lucene
org.eclipse.help.appserver
org.eclipse.help.base
org.eclipse.help.ui
org.eclipse.help.webapp
org.eclipse.tomcat
In some small companies, we may encounter such problems: Having some excellent ideas or innovation, but have no time to implement due to the afraid of disorder existing plans. It's a bad impact for innovation.
Some guys have developed a method: Hackathon. With this method, feedburner group add 7 useful functions to their feed reader software in 1 day.
Now let's have a look at the Hackathon method: (too simple)
在每周一段规定的时间内(Feedburner小组用了一天),小组成员各自开发与项目内容无关的功能,自己认为好的想法都可以实现(最好是那种在几个小时内就可以完成的功能),然后把做好的功能完好地集成到项目中。
some english, some chinese, enjoy it. : )
links about Hackathon:http://blog.jot.com/archives/2005/05/09/jotspot-inagural-hackathon
A good website for us eclipsors. Enjoy it!
http://eclipse.techforge.com/index.php
其中有2本JBoss的书,3本Spring的书和1本Hibernate的。你是否需要补充一下你的书架了?
Thank you for your recent evaluation of ReportMill.
A few questions:
Did you have a chance to install and test the product?
Are there any product features in ReportMill that you would like or found missing?
Are you using an existing reporting tool?
Do you plan on embedding reporting in an existing or new application?
Does it make sense to schedule a demo to give you a quick overview of the features?
Regards,
Brian Noll
ReportMill Operations
brian@reportmill.com
1-(609)-678-0058
“Reporting for Java Developers”
Our tutorial is here :
http://reportmill.com/support/docs/tutorial.pdf
Our design documentation is here:
http://reportmill.com/support/docs/user_guide.pdf
Our developer documentation is here:
http://reportmill.com/rm8/support/DevDocs.html
Our video based training is here:
http://reportmill.com/support/videos/animation
Our Yahoo community is here:
http://groups.yahoo.com/group/reportmill/join
真忙啊,又要搞课程设计,又要准备后天的Computer Architect考试。两边都不能放松,还希望两边都做得好。确是一件难事,有时看到同学还有时间玩游戏,而自己编程编的头都大了,感觉是应该放松一下,自己其实没必要那么忙的。时时想起远方一位好友的话:大学除了学知识,还要学会怎么玩。可能正常的应该是这样的,而我可能走了比较顺畅的路,现在都没法改回来了。
越来越“理解”《小薇》里的一句台词:聪明是他最大的缺点,帅是他天生的缺陷。呵呵
It's a bug fix version.
The last release candidate version.
After weeks, Eclipse3.1 Release will be able to download.
我们在写Plugin程序时,涉及的类一般都比较多(可能来自各个插件),有时候只知道类的名字,但不知道类所在的包名,查文档又有点浪费时间。但假如我们能够记住该类的一个方法或字段的话,我们就可以在类名后输入".方法名"或".字段",然后按Ctrl+1,或右键选择Quick Fix,Eclipse就会提供一个import列表,从中选择正确的包名就可以了。
RCP学习笔记(RCP Tutorial)在一个RCP中,我们将org.eclipse.core.runtime.applications扩展(extension)定义为工程中主程序的id,将org.eclipse.ui.perspectives扩展定义为工程中Perspective的id。
RCP的最小Plugin集合为org.eclipse.core.runtime、org.eclipse.ui,所以我们肯定要将他们加到Dependencies Tab
Plugin.xml用到的变量(如:%pluginName)在build.properties里定义,可以通过它实现国际化
plugin.xml的大体结构:<?xml version="1.0" encoding="UTF-8"?><?eclipse version="3.1"?><plugin id="org.eclipse.ui.tutorials.rcp.part1" name version provider-name <runtime> <library name="yourproject.jar"> <export name="*"> </library> </runtime> <requires> <import plugin="org.eclipse.core.runtime"/> <import plugin="org.eclipse.ui"/> </requires>
<extension id="RCPApplication" point="org.eclipse.core.runtime.applications"> <application> <run class="your application path"> </run> </application> </extension> <extension point="org.eclipse.ui.perspectives"> <perspective name="Display Name" class= id="eclipse.ui.tutorials.rcp.part1.RCPPerspective"> </perspective> </extension></plugin>
由于历史原因,eclipse优先考虑plugin的id而不是最顶层元素(如extension)的,所以尽管plugin.xml声明extension的id为RCPApplication,但这个extension的id还是org.eclipse.ui.tutorials.rcp.part1.RcpApplication。而perspective的id写在了perspective这个子元素里(不是顶层id),所以他的id要写成org.eclipse.ui.tutorials.rcp.part1.RCPPerspective,而不能像RCPApplication extension的id那样缩写。
Main program:主程序入口由org.eclipse.core.runtime.applications extension指定,告诉Eclipse runtime生成一个它的实例。Main program要实现IPlatformRunnable接口,程序执行代码放在run()里。
一个Perspective(视角:由视图、编辑器、导航器组成)至少要定义一个Perspective,实现IPerspectiveFactory,并将它赋值给org.eclipse.ui.perspectives extension。这个接口最主要的方法是createInitialLayout(),他负责管理程序start时views和editor的放置方式等。
Workbench Advisor管理Workbench上的toolbar、perspectives等的添加和删除(主要方法:getInitialWindowPerspectiveId()返回默认Perspective的id)
文章最后提到怎么部署一个独立的RCP程序,步骤比较烦,3.1M7以上版本可以参考PainFree RCP
Problem Description:新建了一个RCP Mail的Template Example,运行正常,但是当我将在另一个RCP工程里建好的View放进来时,工程运行就抛出Invalid Menu Extension (Path is invalid): org.eclipse.ui.edit.text.gotoLastEditPosition,而且菜单和工具栏里多出了一些Eclipse自己的东西(如Search,Go to Last Edit Location)。捣动半天未果,后来偶然发现另外一个一模一样的运行配置运行OK,只是使用了另一个Workspace,比较一下发现,出错工程的Workspace多了三四个Plugin的配置(org.eclipse.core.resources,org.eclipse.core.runtime,org.eclipse.debug.core,org.eclipse.debug.ui),而成功的工程workspace只有org.eclipse.ui.workbench的Plugin配置,其他都一样,即使我复制过来也不好使。现在只能用以前的那个成功的配置了,好使,但不知道为什么会出现上述情况, 难道是成功的工程已经将一些Extension注册了,所以后面的工程都用不了。
可能的原因:今天看Eclipse的RCP Tutorial时注意到Eclipse RCP所需的Plugin最小集是org.eclipse.core.runtime和org.eclipse.ui,又记起昨天使用了PDE的调试功能,所以org.eclipse.debug.core,org.eclipse.debug.ui可能是调试时生成的,或者是以前别的项目用过出错工程的workspace目录,生成了一些别的Plugin目录,而多出的Plugin在Plugin.xml文件里注册的menu在我的程序里没有被添加(或者没有定义对应的MenuPath),于是就抛出了:Invalid Menu Extension (Path is invalid)
不过还有一个问题:怎么workspace的.Plugin文件夹里只有org.eclipse.ui.workbench而没有org.eclipse.core.runtime,有谁知道这是为什么吗?
序列化:
反序列化:
一直都在做综合设计,由于项目采用了Eclipse RCP,而且我以前也没有接触过Eclipse Plugin和RCP,只是学过一点SWT和看过几个RCP的例子,所以现在做起来比较“郁闷”,一边是快乐地学习未来最热门的新技术(希望是哦),一边是为时不时蹦出的错误而不知所措,而苦恼。最可恶的是还要按部就班的写文档,本来在纸上已经画好了用户界面,但为了付诸文档还必须在Visio里画一遍。还有一些东西不知道怎么填,本来想删掉一些的,明明知道老师不会去翻那些文档,但还是没敢那样做。
Contributing to Eclipse看到了第6章,但是一直没有时间写心得,可能是心里还感觉写Blog是一种浪费时间的东东吧,这样子可不好,我得多练练。
刚刚画完时序图,e的不行了,趁这个时间写篇Blog,放松一下,理理头绪,待会还得继续写数据库的设计流程呢。
突然有个体会:好吧,让暴风雨来得更猛烈些吧!
Go on, be a tiger!
我发现,好像是firefox好使,ie不好使, 大家都用firefox上吧!~~~~~
Go on,be a tiger.
真希望快一点得到结果,对自己对家人也得有个交代啊。
不知道过去那边是做什么,我希望别做外包,多做一点项目。而且希望是Java的,呵呵
既锻炼实战能力,又有很多Money,何乐而不为呢。
不过现在想还有点早,呵呵
粗略看了一下回复页面的源码和相关的JS文件(通过查看源文件看的,我现在还没搞到asp源码呢),感觉有两个地方比较可疑,一个是validatePage变量(具体名字忘了,大概就是这个意思),还有一个validateFeedback,都在一个JS文件中。根据代码逻辑,只要它们两个当中有一个为false,我们写的回复就不能贴上去。
是不是变量的值弄错了或者页面和回复不符合标准
btw:出事那天我写了一篇《这样可以使用户不能关闭IE吗? 》,发布之后我上了一下QQ,等我再看Blog的时候,ttttt已经在那篇文章上留言了,
# re: 这样可以使用户不能关闭IE吗? Remove Comment 1478 js吧,有个什么onClose事件好像 6/12/2005 8:49 PM | ttttt
当我写好了我的回复准备提交时,submit按钮就不好使了,没有反应。所以accident应该就是这个时间段发生的,但不知道ttttt是谁?可以问一下那天是怎么操作的,呵呵。不能回复确是一件不爽的事啊。
1) Improve your math skill.2) Improve your English skill.3) Improve your computer science skill.4) Improve your communication skill.5) Remove BS from your vocabulary, learn from everyone, as long as they have one thing stronger than you.6) Try define every vague term you're using precisely.7) Do not stop at surface, think deeper, dig deeper.8) Do not stop at surface, think higher, look at bigger picture.9) Be the best at your current job, learn something new, and then try to get a better job.10) Help people less experienced than you.11) Believe you can be expert too, reward yourself for your progress, even if it's small.12) Do something grand with your life, realize your childhood dream.13) Enjoy life.14) Pass it to your kids.
为了打好做Plugin的基础,今天特地借了本《Contributing to Eclipse》,其实应该是买一本的,这本书这么经典。听说这本书是从Eclipse的内部构架来讲的,对于快速入门Plugin的开发可能不是特别合适,但没有发现书店有别的关于SWT或Plugin的书,555好了,开始切入正题,Go Go Go
《Contributing to Eclipse》分为四个循环,第一个循环是第零个循环(hahaha)。第零个循环介绍了Eclipse的基础架构,然后通过编写一个最简单的HelloWorld Plugin带我们走进Contributing的大门。
先说说这里列出的比较重要的概念:Eclipse分为三层:Platform、JDT、PDE。其中PDE是对JDT的扩展,提供了插件开发支持。
Platform又分为两层:Core(Workspace、Runtime)、UI(Workbench、JFace、SWT)。下面分别介绍一下:Runtime --- 定义了插件的基础设施。启动时发现所有可用插件并管理插件的加载。Workspace --- 管理一个或多个顶级项目。SWT(Standard Widget Toolkit)--- 提供图形显示功能,定义了一组标准窗体组件。JFace --- 建立在SWT上的一组比较小的UI框架,提供对常用UI任务的支持。Workbench --- Eclipse的UI聚合体,核心要素是编辑器、视图(View)和视角(Perspective)。其中视角(Perspective)定义了各工作台部件的可视化排列方式。
All Right. That's how you get it. Go on, be a tiger.
刚才看了Examples里的Web Browser实例,感觉特别像一个Rss Reader里的简易浏览器。
上software.hit.edu.cn看Flash没有问题,打开一个Word文档也OK,应该是内嵌了IE吧。
看了代码也只发现一个setLocation(URL),没有跟本地系统联系的代码,难道SWT里的Browser本身就内嵌了IE。
以前也听说过SWT是不用虚拟机的(是吗?),都是调用本地的dll,只是现在亲眼目睹了。
这不有点像AWT吗?!
这就是定制的Controls?有什么特别的地方吗?我好像也没看出来CCombo就是一个ComboBox,不过可以设为Flat,这样比较酷。CLabel有一个Shadow相关的属性,可以设置IN或OUT(就是突出或凹进,这是Label啊!搞得这么花哨)。CTabFolder在视觉上有些改进,也是Flat Style,看着看着就忍不住想碰一下。当Size缩小时,CTabItem可以隐藏起来,在右上方显示一个下拉双箭头,还显示了隐藏的Item数目,应该就是Eclipse里的那种风格了。StyledText,顾名思义。比较特别的:可以将句子Strikeout,就是在选择的句子上划一条“删除线”。TableTree跟上节Controls里讲的Tree差不多。有一个SWT.FULL_SELECTION Style不知道有什么用。例子看完了,休息...休息一下。
假如不考研的话,我就要在这一段时间多弄弄技术了,决定学学Eclipse的plugin和RCP,于是首先得学SWT。上次看了几篇中文的paper,知道了SWT的基本应用,现在该动动手了(尽管我向来都提倡君子动口不动手的,呵呵),当然是首先看看swt都能干什么啦,最好的下手之处就是swt examples。运行环境就是Eclipse啦,我的Eclipse本来不打算换的,我已经装了RC1(那天下RC2也是一位朋友要用,我的电脑上从3.0.1到3.1RC2都有,pat),但听说RC2超级快,所以也解压缩试一下。说了这么多废话,真有点对不起观众,555现在看看怎么运行SWT Examples,我们启动Eclipse,从Help的Welcome里选择Samples,单击SWT下面的红圆圈,链接到download examples(我在Update里设了代理,速度马马虎虎),自动安装完examples后,单击OutLine里的run examples,不要害怕,这时会弹出一个Eclipse的启动画面,不要认为哪里做错了,对,这就是Examples的Laucher。在Laucher打开的workbench里选择Window->Show View->Other,选择Swt Examples里的例子。现在可以慢慢看了。
BEA, VMware and Red Hat have partnered to provide a single, easy to install package that gives you everything you need to be quickly up and running with BEA WebLogic Platform 8.1 on Red Hat Enterprise Linux.
The VMware image provided here can be installed on your VMware Workstation, which may be running on a Linux or Microsoft Windows box. After installing the image, you will have a fully operational WebLogic Platform 8.1 system running on a virtual Red Hat Enteprise Linux. No fuss, no additional installation necessary.
source: http://dev2dev.bea.com/wlplatform/vmware/
我们在IE里编辑blog时,如果按下关闭按钮,会弹出一个确认对话框,点“取消”之后IE不会关闭。
这是不是能实现rt功能?是什么促使对话框的弹出,是JS还是内嵌的word或其他?
以前有人问过怎么避免用户误关闭IE,当时觉得不可能实现(那不成病毒网页了吗?),现在发现好像还是可以的,山外有山啊!!!
得出一个道理: 多接触一点东西,趁现在年轻
今天看一个Rails on Ruby的视频时,那位高手在一个文件夹上单击右键(具体是rails文件夹,),在弹出的菜单上单击Open Command Window Here(诸位的菜单上有吗?),随即打开的cmd进入了选中的文件夹,这可是一个创新啊,再不用copy + paste了。所以我决定做一个,用百度搜了一篇添加windows右键菜单的文章,照着做了一下,后来又参考了Far(一个类似rar的压缩工具,目前在我的右键菜单上寄居,当时装着玩的)的command知道了“选择目录”的参数:%1 。于是一个类似Open Command Window Here的功能实现了
具体步骤:regedit -> HKEY_CLASSES_ROOT -> Folder -> shell -> 新建/项:Open in cmd -> 在Open in cmd上新建/项:Command -> 设置Command的默认值为:C:\WINDOWS\system32\cmd.exe %1
呵呵,大功告成
Yesterday, Steve Jobs proudly announced the 3rd major transition in Apple's history. After the move from the 68000 family to the PowerPC and after the move from MacOS 9 to beloved MacOS X, Apple will move from PowerPC to Intel x86 family. And Steve Jobs confirmed the rumors: Apple compiled and built all its applications and releases of MacOS X for x86. "Just in case" said Jobs. Why does it has to do with Java anyway? Well moving from one CPU architecture to another will demand a lot of work from the Mac community. Sure it won't be as hard as moving from MacOS 9 to MacOS X, but still, it's huge. As usual, Apple takes care of easing the pain: Xcode 2.1 can generate PowerPC and x86 binaries. Best, you can generate them in one single universal (or "fat") executable. MacOS X will also be shipped with Rosetta (Steve Jobs maybe want to be seen as the Champollion of IT), a runtime library to run PowerPC binaries on x86. Despite these (wonderful) tools, nothing will be as easy as porting your Java apps from MacOS X PPC to MacOS X x86. You'll just have nothing to do. Jobs even emphasized this point when, speaking about the amount of work required to port existing applications to x86, he explained that neither Dashboard Widgets nor Java apps will need the slighest change. Unfortunately he deceived us. Some Dashboard Widgets will need a bit of work, at least a new build. That's why we are the winners in this transition. We can rejoice to get a user friendly, stable and elegant OS on our well known x86 hardware and still enjoy our favorite development platform without bothering a minute about it. If you needed a proof of the advantage of hardware decoupled bytecode, you got it right in front of you my friends. We live interesting times and I'm glad I'm not talking about server side or mobile stuff. P.S: This is one more reason to check out the Quaqua Look and Feel and to contribute. As WinLAF, this look and feel aims to fix the glitches and minor bugs in comparison to the native look and feel.
Source: http://weblogs.java.net/blog/gfx/archive/2005/06/apple_moves_to.html
1、代码:Toolkit.getDefaultToolkit().setDynamicLayout(true); 功能:动态调整Components的位置和大小 as soon as Parent Container resized.
2、代码:UIManager.put("swing.boldMetal", Boolean.FALSE); 功能:用默认的Metal Layout时,字体一般都是粗体,不咋好看,用上述代码可以改为常规字体
在一个Editor的Tab上单击右键,选择New Editor,可以对当前文件打开一个新的编辑器。
两个编辑器是同步的。
前段时间,团队开始实施一个新项目。这个项目有着中国IT行业的三个共同特点:需求繁、工期紧、资源缺。虽然从目前情况来看,它还有希望不会沦为“死亡项目”,但如果实施过程中不小心翼翼、步步为营,结局就很难预料了。虽然有着诸多不利因素,但是我们团队也还有一些有利因素,也许可以主宰项目的命运:1)开明的领导。俺们的各级领导都算通情达理,不会做那种拍脑袋下结论、赶鸭子上架的事情;2)详尽和准确的需求调研。前期的很多准备工作不是白作的,最后出来的需求调研文档基本反映了用户的最终需求;3)迭代的设计评审制度。大量时间花在编码前的设计上是值得的,原因我就不多说了,凡是学过PM的都清楚;4)陆续加入的资源。(这一点很有可能从优势变为劣势,因为谁都知道项目中途加入新人只会影响进度)在项目的初期,作为一个普通员工,在这种情况下最应该做什么呢?我觉得最重要的一样事情是做好个人计划。不是从项目管理出发的那种整体计划,而是针对自己的任务(功能点)出发的个人计划--WBS清单:项目经理制订的项目计划通常都比较粗线条,并没有具体到一个个的功能点,只是给出了哪个模块由谁负责、在哪个期限之前完成。如果你不去自己细化它,而是抱着一种做了多少是多少的态度来实施这个计划,那么可能有两个问题出现:1)你负责的模块对于整个项目来说是个不可见的“黑盒子”,没人知道它到底完成到什么程度、完成得怎么样、存在什么问题。连你自己都不知道自己的进度情况,领导就更不知道了,说不定就会出现拍脑袋的事情出现;2)万一由于资源、时间或者技术难关的原因无法按时完成任务,那你就成了整个项目进度拖延的罪魁祸首--领导会问你:既然有问题,为什么不早提出来?为什么要等到项目工期近了才提出来?为了避免成为罪人,就要做一个聪明的项目参与者。首先要做的是制订一份有关个人的详细的WBS(Work Breakout Structure,工作分解结构)清单。把自己的负责的模块的功能点全部列出来,注明每一项可能需要花费的时间、前提条件、可能存在风险等。其目的无非是使得自己的工作足够透明、使得自己的工作时刻处于可控状态。制订完WBS清单之后,当然是把它呈现给项目经理看,通常这个时候你的台词应该是:“hello,经理,这是我的详细计划。根据我的评估,你分派给我的任务,是无法在项目限期内完成的,请你给我多分派人手、或者裁剪一下需求,要不,发我双薪让我拼命加班?”如果在你有WBS为据的前提下,经理还是逼迫你去完成原来规定的任务,我想这个时候你是不是应该考虑一下项目失败之后你的出路啦?最后是几个需要注意的问题:1)留余地。 制订计划一定要正常,不要把自己的一天工作时间安排到12个小时,不要把自己的周末时间全部占用,不要忽略了陪老婆孩子、打球、生病的时间;2)计划与需求密切配合。要知道项目的验收是看需求的,如果你的计划能够与需求上的每一个用例密切配合,相信领导会觉得你的WBS清单更可信更科学,而且这样的计划实施起来也会很爽的;3)在出现意外情况时(例如领导要你临时接点额外任务时),记得拿出你的WBS清单,跟领导讲价:“工期给我延长几天吧?”? 如果不这样,你还是一样会很有可能成为一个可怜的失败的项目参与者,呵呵。
Source:做一个聪明的项目参与者--制订WBS清单
下载一个商业软件进行学习和研究使用时,我们一些同学会立即找他的破解方法,而且在安装后的第一时间将它破解。
其实我们很多软件都不必破解的,他的试用期已经足够我们用了。我们现在用的软件如Power Designer只是为了一时的课程学习使用,在其他时候一般是不用的,用Sql Server Manager就足够了,大实验中也就用个四五天。
还有一些我们只是做界面的时候才用,如JBuilder,别的部分可能就用Eclipse了,而JBuilder试用期好像有30天吧,即使以后真的还要用,我们再来破解也不迟啊(这样的几率还是不大的)。
这样我们兴许能够减轻一下盗版的“罪名”,而且也能促使自己多使用开源免费软件。
呵呵,随感而发,发现我应该多练一下自己的写作水平和表达能力了: )
public void run(){ if(isSetToFront) { this.toFront(); }}
界面 (继承JWindow) extends Thread 或 implements Runnable, run之后sleep一下。可用于Splash Window。
long single = fileBean.getLength()// fileBean.getSplits().length;
// 设定所有子线程的起点for (int i = 0; i < fileBean.getSplits().length; i++){ fileBean.getSplits()[i][0] = (long) (i * single);}// i end = i+1 startfor (int i = 0; i < fileBean.getSplits().length - 1; i++){ fileBean.getSplits()[i][1] = fileBean.getSplits()[i + 1][0];}// set end to lengthfileBean.getSplits()[fileBean.getSplits().length - 1][1] = fileBean.getLength();
if (index > 0 && conn.responseCode != 206){ log.debug("由于服务器不支持断点续传,子线程无法运行"); return;}
获取剪贴板:
Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();Transferable contents = clip.getContents(this);try { String str = (String) contents.getTransferData(DataFlavor.stringFlavor); if (str.startsWith("http://")) { remote.setText(str); }
统一界面字体设置(其他UI设置也可用这种思想,有点像CSS)
setUIFont(new javax.swing.plaf.FontUIResource(null, Font.PLAIN, size));
public static void setUIFont(javax.swing.plaf.FontUIResource f){ java.util.Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof javax.swing.plaf.FontUIResource) UIManager.put(key, f); }}
漫漫长假,悠悠岁月
(WinXP)在开始--〉运行,输入:at 12:30 shutdown -s即在12:30关闭计算机。取消关机可输入:shutdown -a (还记得当年怎么对付LoveGate吗?:))要想在Win2000中使用,可将WinXP system32下的shutdown.exe拷入
自己定制可参考:shutdown /?用法: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
没有参数 显示此消息(与 ? 相同) -i 显示 GUI 界面,必须是第一个选项 -l 注销(不能与选项 -m 一起使用) -s 关闭此计算机 -r 关闭并重启动此计算机 -a 放弃系统关机 -m \\computername 远程计算机关机/重启动/放弃 -t xx 设置关闭的超时为 xx 秒 -c "comment" 关闭注释(最大 127 个字符) -f 强制运行的应用程序关闭而没有警告 -d [u][p]:xx:yy 关闭原因代码 u 是用户代码 p 是一个计划的关闭代码 xx 是一个主要原因代码(小于 256 的正整数) yy 是一个次要原因代码(小于 65536 的正整数)
• Custom license specific to the product
• Sometimes allows free use for non-profit organizations
• Sometimes allows free use for everyone
• Usually prohibits reverse engineering
• Usually prohibits redistribution
• Rarely includes source code
• May include all sorts of bizarre terms
GNU/General Public License (GPL)
• You are free to do whatever you want with the source code (modify, redistribute, etc.)
• But… any changes you make that you distribute must also be GPL
• And… any code you distribute that uses GPL code must be available under GPL
• Defeats “embrace and extend”
• Often called “viral” by both friend and foe
GNU Lesser General Public License (LGPL)
• Used to be called “Library GPL”
• Non-LGPL code can use it without becoming LGPL (e.g. linking during compile)
• Resulting combined executable is LGPL
• Many people think this means that you can use LGPL Java libraries from non-LGPL code
• Not clear whether that interpretation is correct
• We are not your lawyers :)
BSD/Apache Licenses
• You can freely use, modify, re-license, etc. as long as you maintain the copyright notices
• You can include the code in a commercial product without releasing your source code
• You can embrace and extend
• Safest for corporate use