小编Fra*_*sco的帖子

如何在捕获后在erlang中编写异常堆栈跟踪?

假设我有这样的事情:

try code_that_fails()
catch _:_ -> .....
Run Code Online (Sandbox Code Playgroud)

如何在catch块中打印stacktrace?该块捕获所有异常,但我不知道如何打印堆栈...

你能帮助我吗?

erlang stack exception

16
推荐指数
3
解决办法
7428
查看次数

如何使用 spring JdbcTemplate 更新 postgresql 数组列?

我正在使用 Spring JdbcTemplate,并且我陷入了一个查询,该查询更新实际上是一个 int 数组的列。数据库是postgres 8.3.7。这是我正在使用的代码:

public int setUsersArray(int idUser, int idDevice, Collection<Integer> ids) {

    int update = -666;

    int[] tipi = new int[3];
    tipi[0] = java.sql.Types.INTEGER;
    tipi[1] = java.sql.Types.INTEGER;
    tipi[2] = java.sql.Types.ARRAY;

    try {
        update = this.jdbcTemplate.update(setUsersArrayQuery, new Object[] {
                ids, idUser, idDevice }, tipi);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return update;
}
Run Code Online (Sandbox Code Playgroud)

查询是“update table_name set array_column = ? where id_user = ? and id_device = ?”。我得到这个例外:

org.springframework.dao.DataIntegrityViolationException:PreparedStatementCallback;SQL [更新acotel_msp.users_mau 设置denied_sub_client = ? 其中 id_users = ? 和 …

arrays postgresql spring jdbctemplate

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

用Spring注入Log4J记录器

我有一个带有以下web.xml的spring 2.5 webapp

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>Spring BlazeDS Integration Samples</display-name>


<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>ServerBlaze</param-value>
</context-param>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring/*-context.xml
    </param-value>
</context-param>

<context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/config/log4j.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
    <listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>

<servlet>
    <servlet-name>serverBlaze</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
    <servlet-name>serverBlaze</servlet-name>
    <url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

</web-app>
Run Code Online (Sandbox Code Playgroud)

我宣布了这个豆子

    <bean id="mylog"
    class="org.springframework.beans.factory.config.CommonsLogFactoryBean">
    <property name="logName" value="mylog" />
</bean>
Run Code Online (Sandbox Code Playgroud)

在services-context.xml中(它是一个blazeds/spring项目).

我将这种方式注入UserDAO bean:

    <bean id="user" class="com.acotel.msp.database.UserDAO" >
    <property name="mylog" ref="mylog" />
    <property name="jsonClient" ref="jsonClient" />
</bean>
Run Code Online (Sandbox Code Playgroud)

这是log4j.xml配置文件:

    <?xml version="1.0" …
Run Code Online (Sandbox Code Playgroud)

spring log4j blazeds code-injection

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