Re: Behavior of Connection.commit()



Thank you for taking the time to test this with another driver. The
intention of the program is to show that with this driver when you get this
type of data corruption we will throw on Commit. It is an ugly problem, but
to us it seemed like a better option than having commit succeed and silently
corrupting your data.

This is why I mentioned that this could be a very serious error, your code
could be silently corrupting your data with your previous driver. With this
driver you can at least realize that there may be a problem but it will
probably require code changes to fix the underlying issue.


>I don't understand
> how your program expects the commit to fail, but
> then expects the row inserted in a failed tx to still
> be there?
I am sorry for not making it clearer, I am afraid I just threw it together
to post it while everybody is looking at this thread. The program was
intended to show that others drivers that don't throw on commit still have
the same data corruption issue.

--
Angel Saenz-Badillos [MS] DataWorks
This posting is provided "AS IS", with no warranties, and confers no
rights.Please do not send email directly to this alias.
This alias is for newsgroup purposes only.
I am now blogging: http://weblogs.asp.net/angelsb/




"Joe Weinstein" <joeNOSPAM@xxxxxxx> wrote in message
news:43D17774.7090200@xxxxxxxxxx
> Ok, I just tested another driver that fails the tx because
> the table is there. The subsequent commit does not fail.
> The select gives only the 9999 row. I don't understand
> how your program expects the commit to fail, but
> then expects the row inserted in a failed tx to still
> be there?
> Joe
>
> Angel Saenz-Badillos[MS] wrote:
>
>> Just a quick repro program that explains the problem, I would be
>> interested to see how other Sql Server drivers handle this:
>>
>> import java.lang.*;
>> import java.util.*;
>> import java.sql.*;
>> import java.math.*;
>> import java.text.*;
>> import java.io.*;
>>
>> public class test
>> {
>> public static String ConnectionString = "<set your connection string
>> here>";
>>
>> public static void main(String[] args) throws Exception
>> {
>> Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
>> Connection conn = DriverManager.getConnection(ConnectionString);
>> Statement stmt = conn.createStatement();
>> String tablename= "testTX";
>> stmt.executeUpdate("if exists (select * from dbo.sysobjects where id =
>> object_id(N'[dbo].[" + tablename + "]') and OBJECTPROPERTY(id,
>> N'IsUserTable') = 1) DROP TABLE [" + tablename + "]");
>> stmt.executeUpdate("CREATE TABLE [" + tablename + "] (a int)");
>>
>> conn.setAutoCommit(false);
>> stmt.executeUpdate("INSERT into [" + tablename+ "] values (1)");
>> try{
>> //This will kill the transaction!
>> stmt.executeUpdate("CREATE TABLE [" + tablename + "] (a int)");
>> }catch(Exception ex){System.out.println(ex.getMessage());}
>> stmt.executeUpdate("INSERT into [" + tablename+ "] values (99999)");
>> try{
>> conn.commit();
>> }catch(Exception ex){System.out.println("We correctly throw an
>> exception: "+ex.getMessage());}
>> conn.close();
>>
>> //Verify data inserted.
>> Connection conn2 = DriverManager.getConnection(ConnectionString);
>> Statement stmt2 = conn2.createStatement();
>> ResultSet rs = stmt2.executeQuery("SELECT * FROM [" + tablename + "]");
>> while(rs.next()){
>> System.out.println(rs.getObject(1));
>> }
>> System.out.println("If this did not print out 2 lines: 1, 99999 you
>> have data corruption.");
>> }
>> }
>>
>>
>>
>>
>


.



Relevant Pages

  • [GIT PATCH] ACPI patches for 2.6.21 - part II (resend)
    ... Adds the sony-laptop driver, which controls brightness on akpm's vaio... ... Adds the ACPI support needed by the upcoming rtc driver ... ACPI: bay: fix wrong order of kzalloc arguments ... commit 255f0385c8e0d6b9005c0e09fffb5bd852f3b506 ...
    (Linux-Kernel)
  • Re: [RESEND x9+ patch 2.6.26-git 1/2] lm75: cleanup and reorg
    ... This patch have been in Mark's tree for a month or so. ... commit 530598a47e8562f680d155eb280dddd6af1b3d9e ... hwmon: ... Misc cleanups to the lm85 hardware monitoring driver: ...
    (Linux-Kernel)
  • Re: Behavior of Connection.commit()
    ... but to us it seemed like a better option than having commit succeed and silently corrupting your data. ... This is why I mentioned that this could be a very serious error, your code could be silently corrupting your data with your previous driver. ... If somewhere in a tx we try to insert a value into a row where it doesn't fit, we get an exception, but the tx is still alive for us to pursue or close as we see fit. ... The program was intended to show that others drivers that don't throw on commit still have the same data corruption issue. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • cvs-src summary for 04/04/2004
    ... You can get old summaries, and an HTML version of this one, at ... Vinod Hashyap added a driver for `3ware's 9000 series`_ ... depending on which branch the commit is being made to. ... this same change means that USB keyboards will not be ...
    (freebsd-current)
  • [git pull request] ACPI patches for 2.6.32-rc1
    ... sony-laptop: Don't unregister the SPIC driver if it wasn't registered ... ACPI: EC: Restart command even if no interrupts from EC ... commit c7db7ba5fc84e76044f403efbbba3af5fb01d19b ...
    (Linux-Kernel)

Loading