Re: Why oh why don't my updates stick?
"Bayless Kirtley" <[email protected]> Wed, 26 Jul 2006 14:15:21 -0500
| Newsgroups | gmane.comp.db.mckoi |
|---|---|
| Message-ID | <001e01c6b0e8$a01a7eb0$0a00a8c0@Desktop> |
The JDBC standard is for autocommit to be off by default. You have to either
commit each transaction or turn autocommit on. The code to do so is
connection.autocommit(true);
where connection is your preestablished JDBC Connection, the one you will
use to make the updates.
Hope this helps
Bayless
----- Original Message -----
From: <[email protected]>
To: <[email protected]>
Sent: Wednesday, July 26, 2006 10:54 AM
Subject: RE: Why oh why don't my updates stick?
No... I have no commit... Didn't know I needed one, since it all works
fine on SQL Server.
How would I enable autocommit? And is there a reason I wouldn't want to
do that?
Mary Whetsel
Apps Systems Engineer
3i Development
Phone: 612.667.4411
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of
Christopher Lambert
Sent: Wednesday, July 26, 2006 10:51 AM
To: [email protected]
Subject: Re: Why oh why don't my updates stick?
Mary,
Are you missing a commit or do you have autocommit enabled somewhere?
Chris
[email protected] wrote:
>Hi everyone... I'm a newbie to this whole SQL & McKoi world, so forgive
>me if I'm doing something really basic wrong here, but I'm at my wits
>end trying to figure out what it is.
>
>I'm using McKoi for JUnit tests of code where a MS SQL server would
>otherwise be used. The code works just fine against the SQL Server
>database, but my updates against McKoi just do not stick. There is no
>error message or exception. It all appears to work fine, only the data
>is unchanged so all my update tests fail. Add's work just fine, it is
>only the updates that are the problem. Here is a sample bit of code.
>
>>From the system code:
>
> public void updateLineOfBusiness(LineOfBusiness lob) throws
>DtsServiceException{
>
> if (lob.getId()==-1)
> throw new DtsServiceException("Cannot update,
line of business id is
>not set.");
> StringBuffer updateSQL = new StringBuffer();
> updateSQL.append("UPDATE ");
> updateSQL.append(LOB_TABLE);
> updateSQL.append(" SET
>").append(LOB_CODE_COLUMN).append("=\'");
> updateSQL.append(lob.getCode()).append("\'");
> updateSQL.append(",
>").append(LOB_SHORT_NAME_COLUMN).append("='");
> updateSQL.append(lob.getShortName()).append("\'");
> updateSQL.append(",
>").append(LOB_NAME_COLUMN).append("=\'");
> updateSQL.append(lob.getName()).append("\'");
> updateSQL.append(", ").append(LOB_DESC_COLUMN);
>
>updateSQL.append("=\'").append(lob.getDescription()).append("\'");
> updateSQL.append(" WHERE
>").append(LOB_ID_COLUMN).append("=\'");
> updateSQL.append(lob.getId()).append("\'");
>
> try {
> log.debug("Updating line of business " +
lob.toString());
> log.debug(updateSQL);
> Statement updateStatement =
>dbConnection.createStatement();
> updateStatement.execute(updateSQL.toString());
> } catch (SQLException e) {
> throw new DtsServiceException("SQL error
updating line of business:
>" + lob);
> }
> }
>
>>From the test case:
>
> public void testUpdateLineOfBusiness(){
> try{
> dts.createTable_LOB();
>
> Connection connection = dts.getConnection();
> LineOfBusinessServiceImpl service = new
>LineOfBusinessServiceImpl(connection);
>
> //Get a line of business directly
> Statement statement =
>connection.createStatement();
> statement.execute("Select * from
>T_LINE_OF_BUSINESS");
> ResultSet results = statement.getResultSet();
> results.next();
> LineOfBusiness lob =
>getNextLineOfBusiness(results);
>
> //Change and update it
> lob.setDescription("My test description");
> lob.setName("My test LOB");
> lob.setShortName("test");
> service.updateLineOfBusiness(lob);
>
> //Make sure we can get the updated result
through the service
> LineOfBusiness resultLOB =
>service.getLineOfBusinessById(lob.getId());
> assertEquals(lob, resultLOB);
>
> } catch(Exception e){
> log.error(e.getMessage(), e);
> fail();
> }
> }
>
>
>Thanks much for the help in advance!
>
>Mary Whetsel
>
>
>
>
>
>
>
>---------------------------------------------------------------
>Mckoi SQL Database mailing list http://www.mckoi.com/database/ To
>unsubscribe, send a message to [email protected]
>
>
>
>
---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/ To
unsubscribe, send a message to [email protected]
---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]
---------------------------------------------------------------
Mckoi SQL Database mailing list http://www.mckoi.com/database/
To unsubscribe, send a message to [email protected]