??xml version="1.0" encoding="utf-8" standalone="yes"?>日本精品二区,国产丝袜在线观看视频,中文字幕人成一区http://www.aygfsteel.com/Jhonney/archive/2007/07/22/131734.htmlJhonneyJhonneySun, 22 Jul 2007 08:42:00 GMThttp://www.aygfsteel.com/Jhonney/archive/2007/07/22/131734.htmlhttp://www.aygfsteel.com/Jhonney/comments/131734.htmlhttp://www.aygfsteel.com/Jhonney/archive/2007/07/22/131734.html#Feedback0http://www.aygfsteel.com/Jhonney/comments/commentRss/131734.htmlhttp://www.aygfsteel.com/Jhonney/services/trackbacks/131734.html随时找个人,很容易就能替?/span>”Q因此,自己没有核心竞争力了?
 
  q位朋友大学毕业两年Q同学中有部分h从事软g开发,而我q位朋友选择了在互联|行业发展,目前的职位是一个中型网站的~辑部经理。朋友的同学中有个学Java的,写了2q程序,p己开始招生搞培训班。于是,朋友开始担心自q竞争力问题了?/div>
 
  那么Q什么是个h核心竞争力呢Q所谓个人核心竞争力Q就是指不断提高自己核心能力的能力?span style="BACKGROUND-COLOR: yellow">所谓核心能力,是相对其他h而言的,q种能力能很好的实现自己在某斚w的h|且别ZҎ模仿?/span>核心竞争?span style="COLOR: red">不仅表现在所掌握的技术上Q更重要的体现在所h的独到思想或见解、对某个领域业务的综合把?/span>?/div>
  说到底,技术是不值钱的,只有业务和市场才能ؓ企业赢利Q技术只是实C务的一个工兯已。因此,一个h要想h核心竞争力,必d所在行业、所在企业的业务有深ȝ理解Q这q远不是学一两门E序设计语言p搞定的事情。例如,朋友的同学搞Java培训班,其核心竞争力是对IT培训业务的理解和z察Q而不是其JavaE序设计的能力。(即是JavaE序设计能力Q只毕业2q的学生Q能核心到哪里去呢?如果?0q?q的l验Q还说得q去Q)如果其缺乏对培训业务的理解,~Z培训公司q作的经验,其生存将是十分艰隄Q倒闭是眼前的事情?/div>
  个h核心竞争力其实是一个相对的概念Q我们只能说某个人在某个斚wh核心竞争力,而不能笼l说甲具有核心竞争力Q乙不具有核心竞争力。比如,拿大学教师ؓ例,中文pȝ老师中会出名教授Q具有核心竞争力Q,数学pȝ老师中也会出名教授(也具有核心竞争力Q。但是,如果把中文系的名教授分配到数学系M数学课,他就没有竞争力了?/div>

  我认为,对于软g开发h员而言Q掌握一门程序设计语aq是核心竞争力Q而只是入门的一个工兯已Q?strong style="COLOR: #ffffff; BACKGROUND-COLOR: #ff0000">能够利用q个工具熟悉某个行业的业务流E和q作方式Q能够娴熟地利用q个工具为某个行业提供解x案,q才是核心竞争力Q对于从事互联网行业的h员而言Q能够把|络量变成现金量Q能够把|络q_与单位业务结合v来,能够z察互联|的发展方向Q这才是核心竞争力;对于理人员Q能够在有限的资源下Q提高整个团队的战斗力和凝聚力,使团队紧密团l在自己的周_向团队目标努力奋q,q才是核心竞争力?/strong>

  因此Q就个h核心竞争力而言Q行业不分好坏,职业不分好坏Q工作不分好坏。只要你是有心hQ在本职工作中潜心工作,努力摸烦。这P你收L不仅仅是每个月的工资,而且随着旉的增长,你的能力不断提高,对业务的理解和把握能力将不断加强Q最lŞ成自q核心竞争力?br>
---------------------------------------------------------------------------------------
ȝ于一点,自q技能无论采用什么办法一定要辑ֈ和市场直接相l合


Jhonney 2007-07-22 16:42 发表评论
]]>Message-Driven POJOs http://www.aygfsteel.com/Jhonney/archive/2007/06/20/125227.htmlJhonneyJhonneyTue, 19 Jun 2007 18:25:00 GMThttp://www.aygfsteel.com/Jhonney/archive/2007/06/20/125227.htmlhttp://www.aygfsteel.com/Jhonney/comments/125227.htmlhttp://www.aygfsteel.com/Jhonney/archive/2007/06/20/125227.html#Feedback0http://www.aygfsteel.com/Jhonney/comments/commentRss/125227.htmlhttp://www.aygfsteel.com/Jhonney/services/trackbacks/125227.htmlhttp://jroller.com/page/habuma/20050715#message_driven_pojos

Message-Driven POJOs

In my preparation for a presentation I'll be giving next month, I have been tinkering with Message-driven POJOs as proposed by James Strachan and as implemented in ActiveMQ.

Message-driven POJOs offer MDB-like functionality to simple JavaBeans. I have found message-driven POJOs to be a compelling alternative to MDBs, especially if you're already a big fan of Spring and are using it to develop your applications. Message-driven POJOs can take advantage of all of the features provided by Spring (such as dependency injection and AOP).

Although message-driven POJOs aren't exactly new news, I had a hard time finding much information about them online. ActiveMQ's own documentation isn't too bad, but left me with several unanswered questions. As a service to everyone out there who may be searching for more info on message-driven POJOs, I'm writing this article to document what I've learned. I hope you find it useful and maybe it will fill in some of the gaps for you.

What you'll need

To get started, here's a summary of the JARs that I used when developing and running the examples:

  • activemq-core-3.1-SNAPSHOT.jar
  • activemq-container-3.1-SNAPSHOT.jar
  • activemq-ra-3.1-SNAPSHOT.jar
  • commons-logging-1.0.3.jar
  • concurrent-1.3.4.jar
  • geronimo-spec-j2ee-connector-1.5-rc4.jar (or equivalent J2EE JAR)
  • geronimo-spec-j2ee-management-1.0-rc4.jar (or equivalent J2EE JAR)
  • geronimo-spec-jms-1.1-rc4.jar (or equivalent J2EE JAR)
  • geronimo-spec-jta-1.0.1B-rc4.jar (or equivalent J2EE JAR)
  • log4j-1.2.9.jar
  • spring.jar (version 1.2.2)

The biggest challenge you'll face when developing message-driven POJOs is pulling together all of these JARs. To make things easier on you, I've made everything you'll need (including the example code) available here.

Your mileage may vary if you choose to use different versions of JARs than what I've listed above. One important note, however, is that in my examples, I'm using the shorthand XML available in Spring 1.2, so if you use an older version of Spring, you'll need to tweak the XML appropriately.

Writing the message-driven POJO

Writing a message-driven POJO isn't dramatically different than writing a message-driven EJB. The major difference is that you don't have to implement javax.ejb.MessageDrivenBean, which means that you also don't have to implement the EJB lifecycle methods mandated by that interface. (If you need to hook into a POJO's lifecycle, you can use Spring's init-method and destroy-method attributes when declaring the bean.)

In the interest of keeping the focus on how to develop message-driven POJOs, my example will be as simple as possible. In the grand tradition of all simple examples, here's a "Hello World" message-driven POJO:

  package com.habuma.mdpojo;

  import javax.jms.JMSException;
  import javax.jms.Message;
  import javax.jms.MessageListener;

  public class HelloBean implements MessageListener {
    public void onMessage(Message msg) {
      try {
        String name = msg.getStringProperty("name");
        if(name == null) {
          name = "World";
        }

        System.out.println("Hello " + name + "!");
      } catch (JMSException e) {
        // handle exception?
      }
    }
  }

Notice that (as with MDBs) message-driven POJOs still must implement javax.jms.MessageListener. Even though James Strachan refers to these as POJOs, I don't consider this a pure POJO because in order to work it must implement a platform/framework-specific interface. But the MessageListener interface isn't too much of a burden to bear and it's still lighterweight than MDBs, so I guess I can't complain too much.

The onMessage() method should be self-explanatory. When a message is dispatched to this bean, this method is called. Inside of the method, we extract the "name" property from the message and use it to display the traditional greeting.

Listening for messages

The next thing to do is to declare HelloBean as a bean in a Spring context and associate it with a message queue. Declaring the bean itself is simple enough (in hello-mdpojo.xml):

  <bean id="helloBean" class="com.habuma.mdpojo.HelloBean"/>

There's really nothing special about this bean. In a real application, however, your message-driven POJO would probably be more interesting and be injected with references to DAOs, service-layer beans, or some other beans that it collaborates with to do its job. It may also be proxied by some Spring aspects for declarative transactions, security, etc.

To associate "helloBean" with a message queue, we'll need to use ActiveMQ's JCAContainer. The JCAContainer associates itself with a specific ActiveMQ server and acts as a factory to produce connectors to that server. It is declared in Spring as a <bean>:

  <bean id="activeMQContainer" class="org.activemq.jca.JCAContainer">
    <property name="workManager">
      <bean id="workManager" class="org.activemq.work.SpringWorkManager"/>
    </property>

    <property name="resourceAdapter">
      <bean id="activeMQResourceAdapter"
          class="org.activemq.ra.ActiveMQResourceAdapter">
        <property name="serverUrl" value="tcp://localhost:61616"/>
      </bean>
    </property>
  </bean>

For the most part, this chunk of XML is boiler-plate code to set up a JCAContainer to interact with the message queue. The good news is that you'll only need one JCAContainer, regardless of how many of your POJOs will be message-driven.

The only thing of interest is the value assigned to the "serverUrl" property of the "activeMQResourceAdapter" inner-bean. This property tells the container how to connect to your ActiveMQ server--in this case, via TCP on port 61616 of the localhost (where ActiveMQ will be listening by default.)

At this point we have a JCAContainer that is associated with the ActiveMQ server and we have a POJO that is ready and willing to accept messages. All that's left is to connect the POJO to the JCAContainer. The following <bean> does the trick:

  <bean id="HelloMDP"
      factory-method="addConnector"
      factory-bean="activeMQContainer">
    <property name="activationSpec">
      <bean class="org.activemq.ra.ActiveMQActivationSpec">
        <property name="destination" value="Hello.Queue"/>
        <property name="destinationType" value="javax.jms.Queue"/>
      </bean>
    </property>
    <property name="ref" value="helloBean" />
  </bean>

This bean is where the proverbial "rubber meets the road". Using Spring's factory-method feature, this bean declaration leans on the JCAContainer's addConnector() method to create a connector to associate the "helloBean" with the ActiveMQ server. Specifically, the "activationSpec" property tells the JCAContainer to set up a connector that listens to the queue named "Hello.Queue" and the "ref" property tells it to send messages from that queue to the bean named "helloBean".

Bringing this message-driven POJO to life requires two things. First, you'll need to fire up an ActiveMQ server. In the bin directory of the ActiveMQ distribution, you'll find either an activemq.bat (for Windows) or an activemq script (for UNIX). Running this script will start up an ActiveMQ server instance listening on port 61616.

The next thing you'll need is a simple application that loads the Spring application context. The following main() method should suffice (I'll leave the class you place this in up to you):

  public static void main(String[] args) {
    new FileSystemXmlApplicationContext("hello-mdpojo.xml");
  }

If all goes well, running this program will result in a HelloBean POJO that is patiently awaiting a message to process. So, let's send it a message.

Sending a message

There are a variety of ways to send a JMS message, but for the purposes of this example, I'm going to use Spring's JmsTemplate (as described in chapter 7 of Spring in Action). The following declaration of a JmsTemplate is what I used to test the HelloBean (in mq-client.xml):

  <bean id="jmsTemplate"
      class="org.springframework.jms.core.JmsTemplate">
    <property name="defaultDestinationName" value="Hello.Queue"/>
    <property name="connectionFactory" ref="connectionFactory"/>
  </bean>

The "defaultDestinationName" property tells the template the name of the message queue to attach to. The "connectionFactory" property tells the template how to connect. I could've used Spring's JndiObjectFactoryBean to pull a connection factory from JNDI (as I described in SiA) or any implementation of javax.jms.ConnectionFactory. But so that I don't have to mess with JNDI for this simple example, let's use ActiveMQ's ActiveMQConnectionFactory:

  <bean id="connectionFactory"
      class="org.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://localhost:61616" />
  </bean>

Now we just need to use the "jmsTemplate" bean to send a message. In a real application, you might inject "jmsTemplate" into a property of another bean to use. But for simplicity's sake we'll just access the bean directly from a main() method (again, I'll leave the choice of a class up to you):

  public static void main(String[] args) {
    ApplicationContext ctx = new
        FileSystemXmlApplicationContext("mq-client.xml");

    JmsTemplate template = (JmsTemplate) ctx.getBean("jmsTemplate");
    template.send(
      new MessageCreator() {
        public Message createMessage(Session session)
            throws JMSException {
          MapMessage message = session.createMapMessage();
            message.setStringProperty("name", "Craig");
          return message;
        }
      }
    );
  }

Run this program in a separate window from where the application that runs the JCAContainer. If things are going your way, you should see "Hello Craig!" in the window running the JCAContainer app. Congratulations, you've just invoked a message-driven POJO.

So what?

What's the big deal? Why are message-driven POJOs better than MDBs? Well, I never actually claimed any superiority of message-driven POJOs over MDBs. But here are some things to consider:

  • MDBs must be run within an EJB container. Depending on the architecture of your app, this may be an excessive requirement, especially if you aren't use any other EJBs and do not require the features of a full-blown EJB container. Message-driven POJOs, on the other hand, can run anywhere, even (as shown here) in a simple main() method. The only requirement is an ActiveMQ message queue.
  • MDBs require that you implement the lifecycle methods of javax.ejb.MessageDrivenBean. Often these lifecycle methods aren't needed and are left as empty implementations. This isn't a real problem, except that it's simply unnecessary.
  • Although it may not be apparent from the simple HelloBean example, message-driven POJOs can take full advantage of the dependency injection and AOP support offered by Spring (including Spring's support for declarative transactions and Acegi's support for declarative security). In short, you can do anything with the POJO that you can do with any other bean in a Spring context.
  • The XML used to declare a message-driven POJO is slightly more verbose then for an MDB. You should, however, keep in mind that you'll only need to declare one JCAContainer bean, regardless of how many message-driven POJOs your application has.

One thing that I've not yet considered is how EJB 3 MDBs compare the message-driven POJOs. Honestly, I've not taken the time to perform this comparison. Perhaps this is something I'll do soon. If you have any insight in this subject, I'd be quite interested in hearing it.

Message-driven POJOs are just a small portion of a talk that I'll be presenting at the LoneStar Software Symposium in Austin, TX next month. If you're in the Austin area, I hope to see you there.



Jhonney 2007-06-20 02:25 发表评论
]]>
Limit指南http://www.aygfsteel.com/Jhonney/archive/2007/06/12/123717.htmlJhonneyJhonneyTue, 12 Jun 2007 13:28:00 GMThttp://www.aygfsteel.com/Jhonney/archive/2007/06/12/123717.htmlhttp://www.aygfsteel.com/Jhonney/comments/123717.htmlhttp://www.aygfsteel.com/Jhonney/archive/2007/06/12/123717.html#Feedback0http://www.aygfsteel.com/Jhonney/comments/commentRss/123717.htmlhttp://www.aygfsteel.com/Jhonney/services/trackbacks/123717.htmlquto:http://www.aygfsteel.com/lucky/archive/2006/02/23/32059.html

1. 引言

在你需要处理大量数据时你应该考虑使用eXtremeTable的LimitҎ。Limitq个名字来自MySQL的limit 命oQLimit接口的目的就是如何对表的l果集进行limit处理。Limit实现知道当排序、过滤、分c导出时Q用户如何与表互怽用。有了这些信息你 能够用可能是最有效的方式显C正的qo、排序后的请求页面?/p>

ZCLimitҎ,我将要做的工作将分解为JSP、Controller、Service和DAO。这C了一U用分层的方式来处?Limit。你可以Ҏ自己的需要来增加或减层。本CZ也用了Spring框架来重新得C用Spring的JDBC取得的数据,因此你的代码看v来可能有点不同。eXtremeTable的一个特点就是不依赖M框架和容器?

1.1. JSP

Z使用LimitҎ,eXtremeTable需要用limit特定的RetrieveRowsCallback?FilterRowsCallback和SortRowsCallback接口。eXtremeComponents提供了每个接口的一个实玎ͼ可以单地通过讄每个属性gؓlimit来简单来使用?

<ec:table 
items="presidents"
retrieveRowsCallback="limit"
filterRowsCallback="limit"
sortRowsCallback="limit"
view="limit"
>
...

另外视图属性参照一个名为limit的定制视图。这是一个简单修攚w认eXtremeTable视图Q不包含最后页工具条的实现。这仅仅关系C是否能取得确切需要的行?一些数据库例如Oracle和MySQL都提供了一U得到确定行的特性,但是Q其他的数据库例如:Sybase没有提供Ҏ。在我的CZ中我考虑最坏的情况你的数据库不支持q种Ҏ?/p>

即你的数据库不提供取得特定行的Ҏ,当你考虑用户如何和表协同工作ӞLimit仍然非常有意义。用户通常会对一些数据进行排序、过滤和分页?q个例子?5条数据构成一,W一需?5条数据,W二需?0条数据,W三需?5条数据,以此cL。在l过一D|间分后Q他们常怋用过滤来提炼数据?即他们不这样做Q他们也必须在此之前对大量的数据q行分页Q这媄响效率。当然如果允许用LL后页Q那么所有的数据都将被取出,q将非常影响效率?/p>

1.2. Controller

提示QSpring框架的Controller和Struts框架的Action非常相像?/em>

controller首先需要创Z个Limit。ؓ了完成这个你需要得C些关于Context和LimitFactory的帮助?/p>

Context context = new HttpServletRequestContext(request);
LimitFactory limitFactory = new TableLimitFactory(context);
Limit limit = new TableLimit(limitFactory);

Context是一个处理取得属性的接口QLimitFactory使用Context来找出用户如何和eXtremeTable交互?然后Limit使用LimitFactory来组装自己?/p>

Z初始化LimitQ它包含所有的有用的信息。这些信息包括数据将被如何排序和qoQ哪一将被显C和是否允许被导出?/p>

然而,Limit仍然需要得到行的信息,q样正确的信息页面才能被昄l用戗行信息包括开始行、结束行、当前显C?controller必须从service得到q些信息Q而Service从dao中得到这些信息。这里我只给出Controller端的代码?/p>

int totalRows = presidentsService.getTotalPresidents(limit.getFilterSet(), limit.isExported());
limit.setRowAttributes(totalRows, defaultRowsDisplayed);

limit需要得到所有的行来得到行的信息。service需要知道那些被qoQ不这些数据是否要导出。ؓ了设|行信息Q默认的一|C的行数需要被讄?q可以通过对TableTag的rowsDisplayed属性设|一个确定的数值来实现?/p>

现在我们只需要从services得到Collection数据?/p>

Collection presidents = presidentsService.getPresidents(limit.getFilterSet(), limit.getSort(), limit.getRowEnd());

因ؓlimit已经包含所有信息,q将十分Ҏ。所有需要做的就是传入过滤器Q排序和最后行的信息?最后要做的是将Collections和totalRowq些信息传送回JSP以便eXtremeTable知道如何昄q些信息?/p>

request.setAttribute("presidents", presidents);
request.setAttribute("totalRows", new Integer(totalRows));

1.3. Service

service需要和daoq行交互来得到总行数和Collection?/p>

1.3.1. 取得总行?/h4>

controller需要到W一条信息就是总行数?/p>

public int getTotalPresidents(FilterSet filterSet, boolean isExported) {
String totalQuery = presidentsDao.getTotalPresidentsQuery();
String modTotalQuery = filterQuery(filterSet, totalQuery);
int totalRows = presidentsDao.getTotalPresidents(modTotalQuery);
if (isExported && totalRows > maxExportRows) {
totalRows = maxExportRows;
}
return totalRows;
}

service和dao一hqol果集,它的工作方式是在Where语句后面增加更多的AND语句来修Ҏ询字W串。ؓ此,你需要和Limit FilterSet一起工作?/p>

FilterSet是一个过滤器对象数组Q一个过滤器包括一个bean property和这个过滤器的倹{或者,单的说就是用h要过滤的行和他们输入的倹{这使得它非常容易交互。service只需要P代所有的 FilterSetq调用dao来拼接查询语句。(译者注Q过滤的实现方式是:在Where后面增加And语句来改变查询语句以辑ֈҎ据进行过滤的效果Q?/p>

private String filterQuery(FilterSet filterSet, String query) {
if (!filterSet.isFiltered() || filterSet.isCleared()) {
return query;
}

Filter filters[] = filterSet.getFilters();
for (int i = 0; i < filters.length; i++) {
Filter filter = filters[i];
String property = filter.getProperty();
String value = filter.getValue();
query = presidentsDao.filterQuery(query, property, value);
}

return query;
}

query修改包括了filter信息Q总行数。在一些情况下q就_Q但是当用户导出数据时仍然存在一个潜在的问题。ؓ了保持高?service不允许导Z个最大行数的数据?/p>

1.3.2. 取得Collection

controller需要到W二条信息就是Collection?/p>

public Collection getPresidents(FilterSet filterSet, Sort sort, int rowEnd) {
String patientsQuery = presidentsDao.getPresidentsQuery();
String modPatientsQuery = filterQuery(filterSet, patientsQuery);
modPatientsQuery = sortQuery(sort, modPatientsQuery);
modPatientsQuery = presidentsDao.limitQuery(rowEnd, modPatientsQuery);
return presidentsDao.getPresidents(modPatientsQuery);
}

和前面一Pservice和dao一hqol果集?/p>

另外query字符串需要扩展ORDER BY语句以便数据按照正确的方式进行排序。Sort包含一个bean property?sortOrder|正序q是逆序Q。service仅仅需要用Sort来调用dao?/p>

private String sortQuery(Sort sort, String query) {
if (!sort.isSorted()) {
String defaultSortOrder = presidentsDao.getDefaultSortOrder();
if (StringUtils.isNotBlank(defaultSortOrder)) {
return query + defaultSortOrder;
}

return query;
}

String property = sort.getProperty();
String sortOrder = sort.getSortOrder();

return presidentsDao.sortQuery(query, property, sortOrder);
}

query字符串最后需要的修改是增加数据库特别的指o来limit要被返回的l果集。这是limitQuery() Ҏ的作用?/p>

1.4. DAO

dao为service负责底层数据工作?/p>

1.4.1. 定义Query字符?/h4>

Z真正理解daoQquery字符串需要被展示?/p>

q就是得到数据的presidents query字符Ԍ

private final static String presidentsQuery = 
" SELECT " +
" president_id presidentId, " +
" first_name firstName, " +
" last_name lastName, " +
" nick_name nickName, " +
" concat(first_name, ' ',last_name) fullName, " +
" term, " +
" born, " +
" died, " +
" education, " +
" career, " +
" political_party politicalParty " +
" FROM presidents ";

q是得到总行数的query字符Ԍ

private final static String totalPresidentsQuery = 
" SELECT count(*) FROM presidents ";

1.4.2. Filter ?Sort Query 字符?/h4>

两个最有趣的方法就是过滤和排序?/p>

filter看v来像q样Q?/p>

public String filterQuery(String query, String property, String value) {
StringBuffer result = new StringBuffer(query);

if (query.indexOf("WHERE") == -1) {
result.append(" WHERE 1 = 1 "); //stub WHERE clause so can just append AND clause
}

if (property.equals("fullName")) {
result.append(" AND concat(first_name, ' ',last_name) like '%" + value + "%'");
} else if (property.equals("nickName")) {
result.append(" AND nick_name like '%" + value + "%'");
} else {
result.append(" AND " + property + " like '%" + value + "%'");
}

return result.toString();
}

filterQuery()Ҏ需要增加正的AND语句到query字符丌Ӏ?/p>

sort看v来非常类|

public String sortQuery(String query, String property, String sortOrder) {
StringBuffer result = new StringBuffer(query + " ORDER BY ");

if (property.equals("fullName")) {
result.append("concat(first_name, ' ',last_name) " + sortOrder);
} else {
result.append(property + " " + sortOrder);
}

return result.toString();
}

sortQuery()Ҏ需要增加正的ORDER BY语句到query字符丌Ӏ?/p>

1.4.3. Limit Query String

现在query字符串修改能够正的q行filter和sortQ它q需要修改以便只取页面显C相关的数据。MySQL为s the limit命o?/p>

public String limitQuery(int rowEnd, String query) {
return query + " limit " + rowEnd;
}

1.4.4. 取回总行数和Collection.

service需要的唯一东西是Q总行数和Collection?/p>

public Collection getPresidents(final String query) {
return jdbcTemplate.query(query, new ResultReader() {
List results = new ArrayList();
public List getResults() {
return results;
}

public void processRow(ResultSet rs)
throws SQLException {
President president = new President();
president.setPresidentId(new Integer(rs.getInt("presidentId")));
president.setFirstName(rs.getString("firstName"));
president.setLastName(rs.getString("lastName"));
president.setNickName(rs.getString("nickName"));
president.setFullName(rs.getString("fullName"));
president.setTerm(rs.getString("term"));
president.setBorn(rs.getDate("born"));
president.setDied(rs.getDate("died"));
president.setEducation(rs.getString("education"));
president.setCareer(rs.getString("career"));
president.setPoliticalParty(rs.getString("politicalParty"));
results.add(president);
}
});
}

public int getTotalPresidents(final String query) {
return jdbcTemplate.queryForInt(query);
}

ResultReader是一个帮助处理JDBC查询的SpringҎc,作ؓ一个callback来处理JDBC ResultSet。jdbcTemplate是对JDBCq接的抽象?/p>

1.4.5. 默认的Sort序

最后,q是service需要的默认sort序Q?/p>

public String getDefaultSortOrder() {
return " ORDER BY concat(first_name, ' ', last_name) ";
}


Jhonney 2007-06-12 21:28 发表评论
]]>
rowset下蝲地址http://www.aygfsteel.com/Jhonney/archive/2007/06/08/122830.htmlJhonneyJhonneyFri, 08 Jun 2007 05:23:00 GMThttp://www.aygfsteel.com/Jhonney/archive/2007/06/08/122830.htmlhttp://www.aygfsteel.com/Jhonney/comments/122830.htmlhttp://www.aygfsteel.com/Jhonney/archive/2007/06/08/122830.html#Feedback0http://www.aygfsteel.com/Jhonney/comments/commentRss/122830.htmlhttp://www.aygfsteel.com/Jhonney/services/trackbacks/122830.html
http://java.sun.com/products/jdbc/download.html#rowsetcobundle1_0
//////////////////////////////////

在用rowset包的时候遇Cq样的问题:
java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:61)
at java.io.InputStreamReader.<init>(InputStreamReader.java:80)
at java.util.Properties.load(Properties.java:266)
at java.util.PropertyResourceBundle.<init>(PropertyResourceBundle.java:96)
at com.sun.rowset.JdbcRowSetResourceBundle.<init>(JdbcRowSetResourceBundle.java:92)
at com.sun.rowset.JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(JdbcRowSetResourceBundle.java:114)
at com.sun.rowset.CachedRowSetImpl.<init>(CachedRowSetImpl.java:360)Exception: null
at com.sun.rowset.WebRowSetImpl.<init>(WebRowSetImpl.java:68)
at test.Test.generateXML(Test.java:98)
at test.Test.main(Test.java:168)

在网上看了一《用最新sun公司的rowset.jar包的h意》的文章Q用了感觉不太好使,又看了一下sunC֌的那,里面有种ҎQ挺好用Q也不用修改rowset包,我写了一个CachedRowSet生成c?把自q代码贴出来,和大家分享?不知道代码好使不?.

rowset.jar包可以在下面的连接页面下?/p>

http://java.sun.com/products/jdbc/download.html#rowsetcobundle1_0

import javax.sql.rowset.CachedRowSet;
import com.sun.rowset.CachedRowSetImpl;
import java.util.Locale;
import java.sql.*;

public class cachedRowsetCreater {
  protected CachedRowSet crs=createCachedRowset();
  public void close(){
    try {
      crs.release();
    }
    catch (SQLException ex) {
    }
    crs=null;
  }
  public cachedRowsetCreater(String JNDI_NAME) throws Exception {
    crs.setDataSourceName(JNDI_NAME);
}

  public CachedRowSet createCachedRowset() throws SQLException
{
Locale locale = Locale.getDefault ();
try
{//讄资源Z国大?br>Locale.setDefault (Locale.CHINESE);//在linux下好像要用CHINA
return new CachedRowSetImpl ();
}
finally
{
Locale.setDefault (locale);
}
}
public CachedRowSet executeQuery(String QueryString){
  try{
  CachedRowSet crs1=crs.createCopySchema();
  crs1.setCommand(QueryString);
  crs1.execute();
  return crs1;
}catch(SQLException e){
  return null;
}
}

}



Jhonney 2007-06-08 13:23 发表评论
]]>
cvc-complex-type.2.4.a错误解决Ҏhttp://www.aygfsteel.com/Jhonney/archive/2007/05/19/118546.htmlJhonneyJhonneySat, 19 May 2007 06:56:00 GMThttp://www.aygfsteel.com/Jhonney/archive/2007/05/19/118546.htmlhttp://www.aygfsteel.com/Jhonney/comments/118546.htmlhttp://www.aygfsteel.com/Jhonney/archive/2007/05/19/118546.html#Feedback0http://www.aygfsteel.com/Jhonney/comments/commentRss/118546.htmlhttp://www.aygfsteel.com/Jhonney/services/trackbacks/118546.html<jsp-config>
<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
  <taglib-uri>/tags/struts-bean</taglib-uri>
  <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>
  
  <taglib>
  <taglib-uri>/tags/struts-logic</taglib-uri>
  <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>
</jsp-config>
///////把所有跟jsp讄有关的内定w攑֜<jsp-config></jsp-config>里面////////


Jhonney 2007-05-19 14:56 发表评论
]]>单例的实?/title><link>http://www.aygfsteel.com/Jhonney/archive/2007/04/12/110281.html</link><dc:creator>Jhonney</dc:creator><author>Jhonney</author><pubDate>Thu, 12 Apr 2007 13:55:00 GMT</pubDate><guid>http://www.aygfsteel.com/Jhonney/archive/2007/04/12/110281.html</guid><wfw:comment>http://www.aygfsteel.com/Jhonney/comments/110281.html</wfw:comment><comments>http://www.aygfsteel.com/Jhonney/archive/2007/04/12/110281.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/Jhonney/comments/commentRss/110281.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/Jhonney/services/trackbacks/110281.html</trackback:ping><description><![CDATA[public class Singleton {      <br>     <br>  static class SingletonHolder {      <br>    static Singleton instance = new Singleton();      <br>  }      <br>     <br>  public static Singleton getInstance() {      <br>    return SingletonHolder.instance;      <br>  }      <br>     <br>}   <br> <p>See in : <a target=blank><u><font color=#800080>http://crazybob.org/2007/01/lazy-loading-singletons.html</font></u></a> <br>See also : <a target=blank><u><font color=#0000ff>http://www.oreillynet.com/onjava/blog/2007/01/singletons_and_lazy_loading.html</font></u></a></p> <img src ="http://www.aygfsteel.com/Jhonney/aggbug/110281.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/Jhonney/" target="_blank">Jhonney</a> 2007-04-12 21:55 <a href="http://www.aygfsteel.com/Jhonney/archive/2007/04/12/110281.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">Ĭ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ֿ</a>| <a href="http://" target="_blank">կ</a>| <a href="http://" target="_blank">ũ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ӣ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">˳</a>| <a href="http://" target="_blank">ɣ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̩</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ϣ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ػʵ</a>| <a href="http://" target="_blank">ɳ</a>| <a href="http://" target="_blank">ɳ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͭ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ݳ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank">Т</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͨ</a>| <a href="http://" target="_blank">ܿ</a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>