db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kristian Waagan <Kristian.Waa...@Sun.COM>
Subject Re: Update took too long and at last it does not do anything
Date Thu, 15 Sep 2005 12:59:42 GMT

I feel the need to clarify a few points:

  * You do prepare your statement?
    I can't see the prepare call (i.e. conn.prepareStatement(uStr)).

  * I am not sure your SQL does what you intend it to do, but as I do not
    have your database schema, it is hard to tell for sure. Based on the
    names you are using, I would guess the field EMPNO is a number
    (integer?), but you are supplying a last name (string).
    Apart from that, the SQL statement looks correct.

This is only guessing, but the code could be like this:

 >>>> CODE START >>>>
String uStr = "update EMPLOYEE set FIRSTNAME=?,MIDINIT=?,LASTNAME=? 
where EMPNO=?";
PreparedStatement pstmt = conn.prepareStatement(uStr);

// Some kind of loop here, iterating though all tuples to be updated.
	pstmt.setString(1, getFirstName());
	pstmt.setString(2, getMidName());
	pstmt.setString(3, getLastName());
	pstmt.setInt(4, getEmpNo());

// Don't forget to commit!
<<<< CODE END <<<<

Using prepared statements in Derby is very important to get high 
performance. Autocommit mode must also be turned off, and then one must 
not forget to commit :)

If my attempt at helping you is off, please provide error messages or 
more information, and we will have another try at it!


Legolas Woodland wrote:
> Hi
> I used derby for a project (i have latest version)
> When i update a record from my java code its dies and do nothing where i 
> think my codes are true,
> here is the code.
> String uStr = "update EMPLOYEE set FIRSTNME=?,MIDINIT=? where EMPNO=?";
> pstmt.setString(1, getFirstName());
>                 pstmt.setString(2, getMidName());
>                 pstmt.setString(3, getLastName());
> pstmt.executeUpdate()
> where the connection comes from a connection pool,
> I test the connection by inserting data and data insert correctly.
> can some one help me pleas?

View raw message