|
|
Sponsor |
Re: [jira] Commented: (DERBY-133) Autocommit turned false and rollbacks: msg#00365apache.db.derby.devel
Works for me with the attached testcase - can you clarify what you are doing differently? -- Jeremy Anil Venkobarao wrote: Hello Rick,package tests; import java.sql.SQLException; import java.sql.Statement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import util.DerbyTestBase; import junit.framework.TestCase; import org.apache.derby.jdbc.EmbeddedDriver; /** * @version $Revision$ $Date$ */ public class MissingFKTest extends TestCase { static { new EmbeddedDriver(); } private Connection c; public void testDummy() throws SQLException { Connection c1 = DriverManager.getConnection("jdbc:derby:bar;create=true"); c1.setAutoCommit(false); Statement s = c1.createStatement(); try { s.execute("INSERT INTO employee values(100, 'John', 100)"); s.execute("INSERT INTO salary values(100, '01/01/2003')"); try { s.execute("INSERT INTO salary values(200, '01/01/2003')"); fail(); } catch (SQLException e) { // ok } c1.commit(); ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM salary"); rs.next(); assertEquals(1, rs.getInt(1)); } catch(SQLException e) { e.printStackTrace(); fail(); } finally{ c1.rollback(); s.close(); c1.close(); } } protected void setUp() throws Exception { super.setUp(); c = DriverManager.getConnection("jdbc:derby:bar;create=true"); Statement s = c.createStatement(); s.execute("CREATE TABLE employee( empid INTEGER NOT NULL primary key,full_name VARCHAR(30) NOT NULL, salary DECIMAL(10,2) NOT NULL )"); s.execute("CREATE TABLE salary(empid INTEGER NOT NULL,pay_date DATE NOT NULL)"); s.execute("ALTER TABLE salary ADD CONSTRAINT salary_fk1 FOREIGN KEY (empid) REFERENCES employee(empid)"); s.close(); } protected void tearDown() throws Exception { Statement s = c.createStatement(); s.execute("DROP TABLE salary"); s.execute("DROP TABLE employee"); s.close(); c.close(); super.tearDown(); } }
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [jira] Assigned: (DERBY-124) Result type for CONCAT operator with blobs appears to be incorrect., Mamta A. Satoor (JIRA) |
|---|---|
| Next by Date: | [jira] Resolved: (DERBY-124) Result type for CONCAT operator with blobs appears to be incorrect., Mamta A. Satoor (JIRA) |
| Previous by Thread: | Re: [jira] Commented: (DERBY-133) Autocommit turned false and rollbacks, RPost |
| Next by Thread: | [PATCH] demo suite, myrna |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|