db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Waqar Hassan" <aceofspade1...@gmail.com>
Subject Re: [jira] Updated: (DERBY-3299) Uniqueness violation error (23505) occurs after dropping a PK constraint if there exists a foreign key on the same columns.
Date Wed, 20 Feb 2008 05:51:26 GMT
Below is my code, wats problem wit it? when i run it got this

init:
deps-jar:
Compiling 1 source file to G:\Java SE\Net Beans
Projects\HRIS_2\build\classes
compile-single:
run-single:
Unexpected Exception: org.apache.derby.jdbc.ClientDriver
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at fr.NewJFrame.main(NewJFrame.java:60)

Need Help !

--------------------------------------------------------------------
package fr;

import java.sql.*;

public class NewJFrame extends javax.swing.JFrame {


    public NewJFrame() {
        initComponents();
    }


    // <editor-fold defaultstate="collapsed" desc=" Generated Code
">
    private void initComponents() {
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout
(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(98, 98, 98)
                .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 228,
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(74, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(60, 60, 60)
                .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 154,
javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(86, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>




     private static java.sql.Connection conn = null;
 public static String conntype;
 public static Driver dbDriver= null;
        public static ResultSet rs;
        public static String res="";
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NewJFrame().setVisible(true);
            }
        });
        try {

   String driver = "org.apache.derby.jdbc.ClientDriver";
   String url = "jdbc:derby://localhost:1527/hris1";
   Driver driverClass = (Driver) Class.forName(driver).newInstance();
   conn = DriverManager.getConnection(url,"wack","wack");
   conn.setAutoCommit(false);
   setup(conn);

   // Tests for jira 821 and 491 from lang/procedure.java are used in this
repro
   //testImplicitClose(conn);
   conn.rollback();

   setup(conn);
   //jira491Test(conn);


  } catch(Exception e) {
   System.out.println("Unexpected Exception: " + e.getMessage());
   e.printStackTrace();
  }
    }

    // Variables declaration - do not modify
    public static javax.swing.JScrollPane jScrollPane1;
    public static javax.swing.JTextArea jTextArea1;
    // End of variables declaration
    private static void setup(Connection conn) throws SQLException{
  Statement stmt = conn.createStatement();
  try {
   rs = stmt.executeQuery("select * from WACK.empInfo");
                                //execute();
  } catch (SQLException se) {
                    se.printStackTrace();
                }
                while(rs.next()){
                res=  "\n " + rs.getString("empname");
                //res=  rs.getString("empname");
                }
               jTextArea1.setText(res) ;
               conn.close();

    }
}
-----------------------------------------------------



On 2/19/08, A B (JIRA) <jira@apache.org> wrote:
>
>
>     [
> https://issues.apache.org/jira/browse/DERBY-3299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>
> A B updated DERBY-3299:
> -----------------------
>
>    Attachment: d3299_tests_v2.patch
>
> Committed d3299_dropSharedConglom_v2.patch with svn # 629160:
>
> URL: http://svn.apache.org/viewvc?rev=629160&view=rev
>
> Attaching d3299_tests_v2.patch, which is sync'ed with the latest codeline.
>
> > Uniqueness violation error (23505) occurs after dropping a PK constraint
> if there exists a foreign key on the same columns.
> >
> ---------------------------------------------------------------------------------------------------------------------------
> >
> >                 Key: DERBY-3299
> >                 URL: https://issues.apache.org/jira/browse/DERBY-3299
> >             Project: Derby
> >          Issue Type: Bug
> >          Components: SQL
> >    Affects Versions: 10.1.3.1, 10.2.1.6, 10.2.2.0, 10.3.1.4, 10.3.2.1,
> 10.4.0.0
> >            Reporter: A B
> >            Assignee: A B
> >            Priority: Minor
> >         Attachments: case_2.sql, d3299_caUtilMethods_v1.patch,
> d3299_caUtilMethods_v2.patch, d3299_createIxAction_v1.patch,
> d3299_dropSharedConglom_v1.patch, d3299_dropSharedConglom_v2.patch,
> d3299_tests_v1.patch, d3299_tests_v2.patch, d3299_v1.patch
> >
> >
> > When there are multiple constraints on a single table and the
> constraints have the same set of columns (in the same order), Derby tries to
> optimize things by re-using a single backing index for all of the relevant
> constraints.  See the "executeConstantAction()" method of
> CreateIndexConstantAction.java (search for "duplicate").
> > But there is a bug in Derby where, if one of the constraints is unique
> and is dropped, the uniqueness "attribute" of the backing index is not
> updated accordingly.  This means that uniqueness may be incorrectly enforced
> where it is not required.
> > Take the following example ("Case 2" from DERBY-2204):
> >   ALTER TABLE NEWORDERS ADD CONSTRAINT
> >       NEWORDERS_PK PRIMARY KEY(NO_W_ID, NO_D_ID, NO_O_ID);
> >   ALTER TABLE NEWORDERS ADD CONSTRAINT
> >       NO_O_FK FOREIGN KEY (NO_W_ID, NO_D_ID, NO_O_ID) REFERENCES ORDERS;
> > For these statements Derby will use a single backing index for both the
> primary constraint NEWORDERS_PK and the foreign key constraint
> NO_O_FK.  That backing index will be unique because the primary key must
> itself be unique.
> > If later we drop the primary key:
> >   ALTER TABLE NEWORDERS DROP CONSTRAINT NEWORDERS_PK;
> > then the backing index needs to be converted from a unique index to a
> non-unique index (because a foreign key is not inherently unique).  But in
> Derby the uniqueness attribute remains unchanged, so attempts to insert a
> duplicate (NO_W_ID, NO_D_ID, NO_O_ID) row into NEWORDERS will fail with
> error 23505, when it should really succeed.
> > I tried this out on 10.1.3.1 and the same behavior occurs there, so
> marking "Affects" versions for everything back to that...
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>


-- 
! ! ! WACK ! ! !

Mime
View raw message