executeUpdate() freezes JRE or at least GUI thread

I am attempting to insert a row into a table in an Oracle database via a connection with the JDBC Oracle thin driver, but when executeUpdate() is called with a valid INSERT statement, the program freezes! Here's my query...

StringBuffer query =new StringBuffer("INSERT INTO test_epp_transaction(id, transaction_date, emp_id, product_code, gallons)"

+" VALUES (4, '2/JUN/2', 1002, 12, 222)");

No exceptions are thrown... Any idea what could cause this?

Thanks in advance!

-Jay

[617 byte] By [Stickman_1] at [2007-9-26 1:21:27]
# 1
Are u using a Timer?Post some more code
srinivas_1982 at 2007-6-29 0:57:08 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

I've been suffering with this problem too.

I'll be glad if anybody could help me.

Then, here is a piece of my code that should execute 8 million times and is freezing around 2 million iterations:

try{

do {

iteration_count++;

try {

line = stcReader.readLine();

if (line != null) {

currentByte += line.length() + 2;

stc.load(line, this);

stc.setRule(rule.evaluate(stc, this));

// freezes inside this method

stcdao.saveOrUpdate(stc);

report.add(stc);

//Addds the keys only

if (stc.getCodigoDeExclusao() != ServTelCon.STC_OK) {

stcFailCount++;

} else {

stcSuccessCount++;

}

}

if (iteration_count % TRANSIENT_PERIOD == 0) {

stcimpdao.saveOrUpdate(this);

try {

reportDAO.saveOrUpdate(report);

} catch (Exception e) {

logger.warn("Ops", e);

}

try{

MSSQLUtil.commit();

}catch(SQLException e){

logger.warn("Erro realizando commit",e);

}

}

} catch (IOException e) {

logger.debug("OOOPS! IOExption ocurred.", e);

} catch (STCParsingException e) {

unparsedCount++;

uline.load(line, this, e.getCode());

uldao.saveOrUpdate(uline);

continue;

}

} while (line != null);

}catch (Exception e){

logger.error(?Unexpected error?,e);

}

// Method save in DAO

private void save(ServTelCon stc) throws SQLException {

StringBuffer sql = new StringBuffer(400);

sql.append("INSERT INTO servtelcon (baseOperationId , ");

sql.append("stcRuleId , codificacao , identificacao , chaveValidacao , ");

sql.append("codOper , creditosCartao , diags , dtHoComun , ");

sql.append("dtHoInicial , duracaoCham , fi , fz , holding , idSSTP , ");

sql.append("idSV , linha , lote , mesFabricacao , ns , numCreditos , ");

sql.append("numDestino , numPulsos , numSeqCartao , tipoReg ) values (");

BaseOperation operation = stc.getOperation();

long baseOperationId = 0;

if (operation == null) {

logger.warn("Operation in servTelCon should not be null");

return;

} else {

baseOperationId = operation.getBaseOperationId();

if (baseOperationId == 0) {

//Operacao nao salva

MSSQLBaseOperationDAO.getInstance().saveOrUpdate(operation);

baseOperationId = operation.getBaseOperationId();

}

}

sql.append(baseOperationId);

sql.append(" , ");

STCRule rule = stc.getRule();

int ruleId = 0;

if (rule == null) {

logger.warn("rule should not be null");

return;

} else {

ruleId = rule.getStcRuleId();

if (ruleId == 0) {

MSSQLSTCRuleDAO.getInstance().saveOrUpdate(rule);

ruleId = rule.getStcRuleId();

}

}

sql.append(ruleId);

sql.append(" , ");

sql.append(ConversionUtils.prepareString2SQL(stc.getCodificacao()));

sql.append(" , ");

sql.append(ConversionUtils.prepareString2SQL(stc.getIdentificacao()));

sql.append(" , ");

sql.append(stc.getChaveValidacao());

sql.append(" , ");

sql.append(stc.getCodOper());

sql.append(" , ");

sql.append(stc.getCreditosCartao());

sql.append(" , ");

sql.append(stc.getDiags());

sql.append(" , ");

sql.append(

ConversionUtils.prepareString2SQL(

dateFormat.format(stc.getDtHoComun().getTime())));

sql.append(" , ");

sql.append(

ConversionUtils.prepareString2SQL(

dateFormat.format(stc.getDtHoInicial().getTime())));

sql.append(" , ");

sql.append(stc.getDuracaoCham());

sql.append(" , ");

sql.append(ConversionUtils.bool2int(stc.isFi()));

sql.append(" , ");

sql.append(ConversionUtils.bool2int(stc.isFz()));

sql.append(" , ");

sql.append(stc.getHolding());

sql.append(" , ");

sql.append(stc.getIdSSTP());

sql.append(" , ");

sql.append(stc.getIdSV());

sql.append(" , ");

sql.append(ConversionUtils.prepareString2SQL(stc.getLinha()));

sql.append(" , ");

sql.append(stc.getLote());

sql.append(" , ");

sql.append(stc.getMesFabricacao());

sql.append(" , ");

sql.append(ConversionUtils.bool2int(stc.isNs()));

sql.append(" , ");

sql.append(stc.getNumCreditos());

sql.append(" , ");

sql.append(ConversionUtils.prepareString2SQL(stc.getNumDestino()));

sql.append(" , ");

sql.append(stc.getNumPulsos());

sql.append(" , ");

sql.append(stc.getNumSeqCartao());

sql.append(" , ");

sql.append(stc.getTipoReg());

sql.append(" ) ");

Connection con = MSSQLUtil.getConnection();

Statement stm = con.createStatement();

logger.debug(sql);

//freezes here

int atual =

stm.executeUpdate(sql.toString());

if (atual != 1) {

logger.warn(

"Number of registries updated is not 1 on insert: Number of registries updated "

+ atual);

}

logger.debug("select @@identity as id ");

ResultSet rs = stm.executeQuery("select @@identity as id ");

if(rs.next()){

long id = rs.getLong("id");

logger.debug("Seting servTelConid to "+id);

stc.setServTelConsId(new Long(id));

}

stm.close();

}

Thanks in advance.

rafaelrp at 2007-6-29 0:57:08 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...