小编Byr*_*ron的帖子

字符串的Jdbctemplate查询:EmptyResultDataAccessException:结果大小不正确:预期1,实际0

我正在使用Jdbctemplate从db中检索单个String值.这是我的方法.

    public String test() {
        String cert=null;
        String sql = "select ID_NMB_SRZ from codb_owner.TR_LTM_SLS_RTN 
             where id_str_rt = '999' and ID_NMB_SRZ = '60230009999999'";
        cert = (String) jdbc.queryForObject(sql, String.class); 
        return cert;
    }
Run Code Online (Sandbox Code Playgroud)

在我的方案中,完全可能不会得到我的查询,所以我的问题是如何解决以下错误消息.

EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
Run Code Online (Sandbox Code Playgroud)

在我看来,我应该回到null而不是抛出异常.我怎样才能解决这个问题?提前致谢.

java spring jdbctemplate

99
推荐指数
8
解决办法
21万
查看次数

如何传递包含对象列表的parcelable对象?

我在Parcelable下面创建了一个对象,我的对象包含一个ListProducts.在我的构造函数中,如何处理重新创建我ParcelableList

我检查了包裹中可用的所有方法,所有可用的方法都是readArrayList(ClassLoader).我不确定这是不是最好的方法,你的建议真的很值得赞赏.

public class Outfits implements Parcelable {

    private String url;
    private String name;
    private List<Product> products;

    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public List<Product> getProducts() {
        return products;
    }
    public void setProducts(List<Product> products) {
        this.products = products;
    }

    public void writeToParcel(Parcel dest, int …
Run Code Online (Sandbox Code Playgroud)

android android-intent android-activity

87
推荐指数
4
解决办法
7万
查看次数

Java项目:无法加载ApplicationContext

我有一个Java项目,我正在编写一个简单的JUNIT测试用例.我已将applicatinoContext.xml文件复制到root java源目录中.我已经尝试了一些我在StackOverflow上阅读的推荐设置,但仍然得到相同的错误.这个错误是由于我的项目是一个java项目而不是一个Web项目,或者这甚至是否重要?我不确定我哪里出错了.

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"C:/projs/sortation/src/main/java/applicationContext.xml"})
// Also tried these settings but they also didnt work,
//@ContextConfiguration(locations={"classpath:applicationContext.xml"})
//@ContextConfiguration("classpath:applicationContext.xml")
@Transactional
public class TestSS {

    @Autowired
    private EmsDao dao;

    @Test
    public void getSites() {

        List<String> batchid = dao.getList();

        for (String s : batchid) {
            System.out.println(s);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

junit spring unit-testing

33
推荐指数
1
解决办法
15万
查看次数

Android开发者名称更改

我刚刚在市场上发布了我的第一个应用程序,并将我的名字放在开发人员名称下,而不是我的公司名称,这应该是它应该是的.然后我将开发人员名称更新为我的公司名称,但更改似乎没有更新.

有谁知道我什么时候可以看到更改名称?

android google-play

11
推荐指数
1
解决办法
2万
查看次数

HornetQ JMSException:无法创建会话工厂

我正在尝试直接实例化JMS资源而不使用JNDI到REMOTE HORNETQ.

我在Eclipse IDE中运行我的测试代码.设置我的类路径以使用HornetQ 2.2.5库.

目标HornetQ是版本2.1.2.Final,我认为他们应该向后兼容,也许我错了?

好的,所以我已经阅读了在线文档,并按照连接到远程JMS服务器的示例而不使用JNDI.我继续得到以下异常.我不知道我错过了什么,但我相信我已经正确设置了一切.有人可以指出我在这里失踪了吗?提前致谢.

JMSException:无法创建会话工厂

hornetq-configuration.xml上的连接器是:

  <connector name="netty">
     <factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
          <param key="host"  value="${10.100.111.222}"/>
          <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>
  </connector>
Run Code Online (Sandbox Code Playgroud)

接受者是:

  <acceptor name="netty">
     <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
      <param key="host"  value="${10.100.111.222}"/>
     <param key="port"  value="${hornetq.remoting.netty.port:5445}"/>
  </acceptor>
Run Code Online (Sandbox Code Playgroud)

我的测试代码是:Connection connection = null;

   try
   {
    Queue queue = HornetQJMSClient.createQueue("TESTQ");

    Map<String, Object> connectionParams = new HashMap<String, Object>();
    connectionParams.put(TransportConstants.PORT_PROP_NAME, 5445);
    connectionParams.put(TransportConstants.HOST_PROP_NAME, "10.100.111.222");        

    TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(),
                                                                               connectionParams);
    ConnectionFactory factory = (ConnectionFactory) HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration);
    System.out.println("debug: " + factory.getClass());

    connection = factory.createConnection();

    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    MessageProducer producer = session.createProducer(queue);

    TextMessage …
Run Code Online (Sandbox Code Playgroud)

jms hornetq

6
推荐指数
1
解决办法
2万
查看次数

如何使用Fragment显示ProgressDialog

我有一个Fragment活动,左边有一个ListFragment,右边有一个带有WebView的Fragment.功能正常但我想在网页完成加载时显示一个显示"正在加载..."的进度对话框.我怎样才能完成这个看似微不足道的任务呢?

以下是我的代码:

public class ArticleListActivity extends FragmentActivity implements
    ArticleListFragment.OnArticleSelectedListener {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.articlelist_fragment);
    }

    public void onArticleSelected(String contentLink) {
        ArticleViewerFragment viewer = (ArticleViewerFragment) getSupportFragmentManager()
                .findFragmentById(R.id.articleview_fragment);

        if (viewer == null || !viewer.isInLayout()) {
            Intent showContent = new Intent(getApplicationContext(),
                    ArticleViewerActivity.class);

            showContent.setData(Uri.parse(contentLink));
            startActivity(showContent);
        } else {
            viewer.updateUrl(contentLink);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的FragmentActivity

public class ArticleViewerActivity extends FragmentActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.articleview_fragment);

        Intent launchingIntent = getIntent();
        String content = launchingIntent.getData().toString();

        ArticleViewerFragment viewer = (ArticleViewerFragment) getSupportFragmentManager() …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

5
推荐指数
1
解决办法
1万
查看次数

以编程方式无法在RelativeLayout中对齐ImageView

我无法将imageview添加到相对布局中.我想将图像添加到我使用RelativeLayout动态创建的菜单项列表中.我的所有菜单项都显示正常并且按顺序排列但是当我尝试为每个项目添加图像时,我只得到一个箭头并且它不是垂直居中的.以下是我的代码.

在我的XML文件中

<RelativeLayout 
            android:id="@+id/pMenu"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

在我的代码中:

private void buildMenu(String name, int id) {

    String[] menuItems = getResources().getStringArray(pMenus[id]);
    // Get the rel layout from xml
    RelativeLayout container = (RelativeLayout) findViewById(R.id.pMenu);

    int imageId=1;
    Typeface tf = Typeface.createFromAsset(this.getAssets(),"mreavesmodot-reg.otf");
    for(String menuItem: menuItems) {           

        // Defining the layout parameters
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);


        StyledButton menuImage = new StyledButton(this);
        menuImage.setBackgroundResource(R.drawable.menu_button);
        menuImage.setText(menuItem);
        menuImage.setTypeface(tf);
        menuImage.setTextSize(19);
        menuImage.setPadding(20, 0, 0, 0);
        menuImage.setTextColor(Color.WHITE);
        menuImage.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
        menuImage.setOnClickListener(getOnClickListener(menuImage, name));
        menuImage.setId(imageId);

        if(imageId==1) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        } else { …
Run Code Online (Sandbox Code Playgroud)

android android-layout

5
推荐指数
1
解决办法
4423
查看次数

如何使用Spring Framework调用Runnable?

我有一个需要调用runnable类的服务.

以下是我的服务中使用的代码行.

@Autowired
private LinkBrc2MemberProfile brcTask;                

// Background Task.
SimpleAsyncTaskExecutor sate = new SimpleAsyncTaskExecutor();
sate.createThread(new LinkBrc2MemberProfile(user));
Run Code Online (Sandbox Code Playgroud)

这是我的Runnable类

@Service
public class LinkBrc2MemberProfile implements Runnable {

    private final Logger log = LoggerFactory.getLogger(LinkBrc2MemberProfile.class);

    @Autowired
    private LoyaltyDao dao;

    private Member member;

    public LinkBrc2MemberProfile() {
        super();
    }

    public LinkBrc2MemberProfile(Member member) {
        this.member = member;
    }

    public void run() {
        log.debug("*** Member User Name: " + member.getString("USER_NAME"));
        String emailAddress = member.getString("USER_NAME");
        Map<String, Object> map = dao.findBrcByEmailAddress( emailAddress );
        log.debug("==========================================================");

        if( ! map.isEmpty() ) {
            try { …
Run Code Online (Sandbox Code Playgroud)

spring multithreading autowired

3
推荐指数
1
解决办法
9998
查看次数

如何按月和日对日期进行排序但排除年份

我必须按出生日期对一组人员对象进行排序,因此我创建了以下 pojo。

    public class Person implements Comparable<Person> {

    private long id;
    private String name;
    private Date birthDate;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getBirthDate() {
        return birthDate;
    }

    public void setBirthDate(Date birthDate) {
        this.birthDate = birthDate;
    }

    @Override
    public int compareTo(Person person) {
        if (getBirthDate() == null || person.getBirthDate() == null)
            return …
Run Code Online (Sandbox Code Playgroud)

java

1
推荐指数
1
解决办法
4665
查看次数