Skip to Content
0

Why the number of rows affected is zero?

Feb 15, 2017 at 12:58 PM

97

avatar image

Spring application works with database Sybase ASE.

Environment: jdk 1.7.0_80, spring 4.2.3.RELEASE,

Sybase ASE : TEST = Adaptive Server Enterprise/12.5.4/EBF 16800 ESD#10/ase1254/2159/64-bit

PRODUCTION = Adaptive Server Enterprise/15.5/EBF 19399 SMP ESD#5/asear155/2568/64-bit

JConnection: jconn3.jar and jconn4.jar

This code work with database:

import javax.sql.DataSource;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.SQLException;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.annotation.Qualifier;

import org.springframework.transaction.annotation.Propagation;

import org.springframework.transaction.annotation.Transactional;

@Repository("DAO")

public class DAO {

@Autowired

@Qualifier("dataSource")

private DataSource dataSource;

@Autowired private JdbcTemplate jdbcTemplate;

public void setDataSource(DataSource dataSource)

{

this.dataSource = dataSource;

this.jdbcTemplate = new JdbcTemplate(dataSource);

}

public void commit1(String value) {

int rows = jdbcTemplate.update("UPDATE TABLE SET COLUMN_1 = GETDATE()

WHERE COLUMN_1 = ?", value);

System.out.println("rows = " + rows);

}

public void commit2(String value) {

Integer count = -1;

try {

Connection con = null;

PreparedStatement ps = null;

try {

con = dataSource.getConnection();

ps = con.prepareStatement("UPDATE TABLE SET COLUMN_1 = GETDATE()

WHERE COLUMN_1 = ?");

ps.setString(1, value);

count = ps.executeUpdate();

System.out.println("rows = " + rows);

}

finally {

if (ps != null) ps.close();

if (con != null) con.close();

} } catch (SQLException ex) { }

}

}

Problem in PRODUCTION :

execute method commit1(value) OR commit2(value)

In fact I update several rows but with jconn4 library I get next results(console):

rows = 0


with jconn3 library I get next (correct) results:

rows = correct result (1 or more )

in TEST environment with jconn3 and jconn4 library methods work correct:

rows = correct result (1 or more )

How to fix this problem?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers