connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
                          |    3 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
                            |    6 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
                           |    3 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
                     |    4 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
                           |  135 ++++------
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
                               |    5 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
                |    3 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
                      |    5 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
                                 |    5 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
                  |    3 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
                        |    6 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
                       |    6 
 
connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
 |    4 
 13 files changed, 92 insertions(+), 96 deletions(-)

New commits:
commit 827782b060326fd43080d610dd43025f9dc71d90
Author: Damjan Jovanovic <dam...@apache.org>
Date:   Wed Sep 6 18:55:30 2017 +0000

    Simplify the Java OContainer by requiring unique names, something C++
    
    should probably also do as append and co check uniqueness explicitly.
    This does however complicate the client code, as we have to throw
    exceptions when we dedect duplication on the initial names we are
    initialized with.
    
    Patch by: me

diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
index 638b8f31c947..d9f400192494 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlCatalog.java
@@ -24,6 +24,7 @@ package com.sun.star.sdbcx.comp.postgresql;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.sun.star.container.ElementExistException;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbc.XResultSet;
 import com.sun.star.sdbc.XRow;
@@ -52,6 +53,7 @@ public class PostgresqlCatalog extends OCatalog {
                 names.add(name);
             }
             return new PostgresqlTables(lock, metadata, this, names);
+        } catch (ElementExistException elementExistException) {
         } catch (SQLException sqlException) {
         } finally {
             CompHelper.disposeComponent(results);
@@ -71,6 +73,7 @@ public class PostgresqlCatalog extends OCatalog {
                 names.add(name);
             }
             return new PostgresqlTables(lock, metadata, this, names);
+        } catch (ElementExistException elementExistException) {
         } catch (SQLException sqlException) {
         } finally {
             CompHelper.disposeComponent(results);
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
index 426bded92625..c5a285c7514e 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTable.java
@@ -95,6 +95,8 @@ public class PostgresqlTable extends OTable {
         try {
             List<ColumnDescription> columns = new 
SqlTableHelper().readColumns(getConnection().getMetaData(), catalogName, 
schemaName, getName());
             return new OColumnContainer(lock, isCaseSensitive(), columns, 
this, getConnection().getMetaData());
+        } catch (ElementExistException elementExistException) {
+            return null;
         } catch (SQLException sqlException) {
             return null;
         }
@@ -105,6 +107,8 @@ public class PostgresqlTable extends OTable {
         try {
             List<String> indexes = new 
SqlTableHelper().readIndexes(getConnection().getMetaData(), catalogName, 
schemaName, getName(), this);
             return new OIndexContainer(lock, indexes, isCaseSensitive(), this);
+        } catch (ElementExistException elementExistException) {
+            return null;
         } catch (SQLException sqlException) {
             return null;
         }
@@ -116,6 +120,8 @@ public class PostgresqlTable extends OTable {
             Map<String, OKey> keys = new SqlTableHelper().readKeys(
                     getConnection().getMetaData(), catalogName, schemaName, 
getName(), isCaseSensitive(), this);
             return OKeyContainer.create(isCaseSensitive(), keys, this);
+        } catch (ElementExistException elementExistException) {
+            return null;
         } catch (SQLException sqlException) {
             return null;
         }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
index bcdbba001eda..2126de7eaa41 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/PostgresqlTables.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.WrappedTargetException;
 import com.sun.star.sdbc.SQLException;
@@ -48,7 +49,7 @@ public class PostgresqlTables extends OContainer {
     private XDatabaseMetaData metadata;
     private PostgresqlCatalog catalog;
 
-    public PostgresqlTables(Object lock, XDatabaseMetaData metadata, 
PostgresqlCatalog catalog, List<String> names) {
+    public PostgresqlTables(Object lock, XDatabaseMetaData metadata, 
PostgresqlCatalog catalog, List<String> names) throws ElementExistException {
         super(lock, true, names);
         this.metadata = metadata;
         this.catalog = catalog;
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
index 327aa39e3829..9cf2b012b6db 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OColumnContainer.java
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XNameAccess;
 import com.sun.star.sdbc.ColumnValue;
 import com.sun.star.sdbc.DataType;
@@ -50,7 +51,8 @@ public class OColumnContainer extends OContainer {
         public int dataType;
     }
 
-    public OColumnContainer(Object lock, boolean isCaseSensitive, 
List<ColumnDescription> columnDescriptions, OTable table, XDatabaseMetaData 
metadata) {
+    public OColumnContainer(Object lock, boolean isCaseSensitive, 
List<ColumnDescription> columnDescriptions, OTable table, XDatabaseMetaData 
metadata)
+            throws ElementExistException {
         super(lock, isCaseSensitive, toColumnNames(columnDescriptions));
         this.table = table;
         this.metadata = metadata;
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
index 50d1d48f7623..4776146950e7 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OContainer.java
@@ -23,10 +23,8 @@ package com.sun.star.sdbcx.comp.postgresql.sdbcx;
 
 import java.util.ArrayList;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.TreeMap;
 
 import com.sun.star.beans.UnknownPropertyException;
@@ -63,34 +61,25 @@ import com.sun.star.uno.Type;
 import com.sun.star.util.XRefreshListener;
 import com.sun.star.util.XRefreshable;
 
+/**
+ * Base class for a lazy-loaded collection of database objects.
+ */
 public abstract class OContainer extends WeakBase implements
         XNameAccess, XIndexAccess, XEnumerationAccess,
         XContainer, XColumnLocate, XRefreshable, XDataDescriptorFactory,
         XAppend, XDrop, XServiceInfo {
 
-    private static String[] services = new String[] {
+    private static final String[] services = new String[] {
             "com.sun.star.sdbcx.Container"
     };
 
     protected final Object lock;
     private final boolean isCaseSensitive;
-    private TreeMap<String,HashMap<Long,XPropertySet>> entriesByNameAndId;
-    private ArrayList<PropertyInfo> entriesByIndex;
-    private long nextId;
+    private TreeMap<String,XPropertySet> entriesByName;
+    private ArrayList<String> namesByIndex;
     private InterfaceContainer containerListeners = new InterfaceContainer();
     private InterfaceContainer refreshListeners = new InterfaceContainer();
 
-    /// Names aren't necessarily unique, we have to de-duplicate by id.
-    private static class PropertyInfo {
-        String name;
-        long id;
-
-        PropertyInfo(String name, long id) {
-            this.name = name;
-            this.id = id;
-        }
-    }
-
     private Comparator<String> caseSensitiveComparator = new 
Comparator<String>() {
         @Override
         public int compare(String x, String y) {
@@ -102,21 +91,21 @@ public abstract class OContainer extends WeakBase 
implements
         }
     };
 
-    public OContainer(Object lock, boolean isCaseSensitive, List<String> 
names) {
+    public OContainer(Object lock, boolean isCaseSensitive) {
         this.lock = lock;
         this.isCaseSensitive = isCaseSensitive;
-        this.entriesByNameAndId = new 
TreeMap<String,HashMap<Long,XPropertySet>>(caseSensitiveComparator);
-        this.entriesByIndex = new ArrayList<>(names.size());
+        this.entriesByName = new TreeMap<>(caseSensitiveComparator);
+        this.namesByIndex = new ArrayList<>();
+    }
+
+    public OContainer(Object lock, boolean isCaseSensitive, List<String> 
names) throws ElementExistException {
+        this(lock, isCaseSensitive);
         for (String name : names) {
-            HashMap<Long,XPropertySet> entriesById = 
entriesByNameAndId.get(name);
-            if (entriesById == null) {
-                entriesById = new HashMap<>();
-                entriesByNameAndId.put(name, entriesById);
+            if (entriesByName.containsKey(name)) {
+                throw new ElementExistException(name, this);
             }
-            entriesById.put(nextId, null);
-
-            entriesByIndex.add(new PropertyInfo(name, nextId));
-            ++nextId;
+            entriesByName.put(name, null);
+            namesByIndex.add(name);
         }
     }
 
@@ -128,13 +117,11 @@ public abstract class OContainer extends WeakBase 
implements
         refreshListeners.disposeAndClear(event);
 
         synchronized (lock) {
-            for (Map<Long,XPropertySet> entriesById : 
entriesByNameAndId.values()) {
-                for (XPropertySet propertySet : entriesById.values()) {
-                    CompHelper.disposeComponent(propertySet);
-                }
+            for (XPropertySet value : entriesByName.values()) {
+                CompHelper.disposeComponent(value);
             }
-            entriesByNameAndId.clear();
-            entriesByIndex.clear();
+            entriesByName.clear();
+            namesByIndex.clear();
         }
     }
 
@@ -164,7 +151,7 @@ public abstract class OContainer extends WeakBase implements
     @Override
     public Object getByIndex(int index) throws IndexOutOfBoundsException, 
WrappedTargetException {
         synchronized (lock) {
-            if (index < 0 || index >= entriesByIndex.size()) {
+            if (index < 0 || index >= namesByIndex.size()) {
                 throw new IndexOutOfBoundsException(Integer.toString(index), 
this);
             }
             return getObject(index);
@@ -174,7 +161,7 @@ public abstract class OContainer extends WeakBase implements
     @Override
     public int getCount() {
         synchronized (lock) {
-            return entriesByIndex.size();
+            return namesByIndex.size();
         }
     }
 
@@ -183,14 +170,14 @@ public abstract class OContainer extends WeakBase 
implements
     @Override
     public boolean hasByName(String name) {
         synchronized (lock) {
-            return entriesByNameAndId.containsKey(name);
+            return entriesByName.containsKey(name);
         }
     }
 
     @Override
     public Object getByName(String name) throws NoSuchElementException, 
WrappedTargetException {
         synchronized (lock) {
-            if (!entriesByNameAndId.containsKey(name)) {
+            if (!entriesByName.containsKey(name)) {
                 String error = 
SharedResources.getInstance().getResourceStringWithSubstitution(
                         Resources.STR_NO_ELEMENT_NAME, "$name$", name);
                 throw new NoSuchElementException(error, this);
@@ -202,12 +189,8 @@ public abstract class OContainer extends WeakBase 
implements
     @Override
     public String[] getElementNames() {
         synchronized (lock) {
-            String[] names = new String[entriesByIndex.size()];
-            int next = 0;
-            for (PropertyInfo propertyInfo : entriesByIndex) {
-                names[next++] = propertyInfo.name;
-            }
-            return names;
+            String[] names = new String[namesByIndex.size()];
+            return namesByIndex.toArray(names);
         }
     }
 
@@ -215,15 +198,13 @@ public abstract class OContainer extends WeakBase 
implements
 
     @Override
     public void refresh() {
-        Iterator iterator;
+        Iterator<?> iterator;
         synchronized (lock) {
-            for (Map<Long,XPropertySet> entriesById : 
entriesByNameAndId.values()) {
-                for (XPropertySet propertySet : entriesById.values()) {
-                    CompHelper.disposeComponent(propertySet);
-                }
+            for (XPropertySet value : entriesByName.values()) {
+                CompHelper.disposeComponent(value);
             }
-            entriesByNameAndId.clear();
-            entriesByIndex.clear();
+            entriesByName.clear();
+            namesByIndex.clear();
 
             impl_refresh();
 
@@ -249,12 +230,12 @@ public abstract class OContainer extends WeakBase 
implements
 
     @Override
     public void appendByDescriptor(XPropertySet descriptor) throws 
SQLException, ElementExistException {
-        Iterator iterator;
+        Iterator<?> iterator;
         ContainerEvent event;
         synchronized (lock) {
             String name = getNameForObject(descriptor);
 
-            if (entriesByNameAndId.containsKey(name)) {
+            if (entriesByName.containsKey(name)) {
                 throw new ElementExistException(name, this);
             }
 
@@ -264,13 +245,10 @@ public abstract class OContainer extends WeakBase 
implements
             }
 
             name = getNameForObject(newlyCreated);
-            HashMap<Long,XPropertySet> entriesById = 
entriesByNameAndId.get(name);
-            if (entriesById == null) { // this may happen when the derived 
class included it itself
-                entriesById = new HashMap<>();
-                entriesById.put(nextId, newlyCreated);
-                entriesByNameAndId.put(name, entriesById);
-                entriesByIndex.add(new PropertyInfo(name, nextId));
-                nextId++;
+            XPropertySet value = entriesByName.get(name);
+            if (value == null) { // this may happen when the derived class 
included it itself
+                entriesByName.put(name, newlyCreated);
+                namesByIndex.add(name);
             }
 
             // notify our container listeners
@@ -289,7 +267,7 @@ public abstract class OContainer extends WeakBase implements
     @Override
     public void dropByName(String name) throws SQLException, 
NoSuchElementException {
         synchronized (lock) {
-            if (!entriesByNameAndId.containsKey(name)) {
+            if (!entriesByName.containsKey(name)) {
                 throw new NoSuchElementException(name, this);
             }
             dropImpl(indexOf(name));
@@ -299,7 +277,7 @@ public abstract class OContainer extends WeakBase implements
     @Override
     public void dropByIndex(int index) throws SQLException, 
IndexOutOfBoundsException {
         synchronized (lock) {
-            if (index < 0 || index >= entriesByIndex.size()) {
+            if (index < 0 || index >= namesByIndex.size()) {
                 throw new IndexOutOfBoundsException(Integer.toString(index), 
this);
             }
             dropImpl(index);
@@ -312,20 +290,16 @@ public abstract class OContainer extends WeakBase 
implements
     }
 
     private void dropImpl(int index, boolean reallyDrop) throws SQLException {
-        PropertyInfo propertyInfo = entriesByIndex.get(index);
+        String name = namesByIndex.get(index);
         if (reallyDrop) {
-            dropObject(index, propertyInfo.name);
-        }
-        HashMap<Long,XPropertySet> entriesById = 
entriesByNameAndId.get(propertyInfo.name);
-        XPropertySet propertySet = entriesById.remove(propertyInfo.id);
-        if (entriesById.isEmpty()) {
-            entriesByNameAndId.remove(propertyInfo.name);
+            dropObject(index, name);
         }
+        namesByIndex.remove(index);
+        XPropertySet propertySet = entriesByName.remove(name);
         CompHelper.disposeComponent(propertySet);
-        entriesByIndex.remove(index);
 
-        ContainerEvent event = new ContainerEvent(this, propertyInfo.name, 
null, null);
-        for (Iterator iterator = containerListeners.iterator(); 
iterator.hasNext(); ) {
+        ContainerEvent event = new ContainerEvent(this, name, null, null);
+        for (Iterator<?> iterator = containerListeners.iterator(); 
iterator.hasNext(); ) {
             XContainerListener listener = (XContainerListener) iterator.next();
             listener.elementRemoved(event);
         }
@@ -335,7 +309,7 @@ public abstract class OContainer extends WeakBase implements
 
     @Override
     public int findColumn(String name) throws SQLException {
-        if (!entriesByNameAndId.containsKey(name)) {
+        if (!entriesByName.containsKey(name)) {
             String error = 
SharedResources.getInstance().getResourceStringWithSubstitution(
                     Resources.STR_UNKNOWN_COLUMN_NAME, "$columnname$", name);
             throw new SQLException(error, this, 
StandardSQLState.SQL_COLUMN_NOT_FOUND.text(), 0, null);
@@ -369,7 +343,7 @@ public abstract class OContainer extends WeakBase implements
     @Override
     public boolean hasElements() {
         synchronized (lock) {
-            return !entriesByNameAndId.isEmpty();
+            return !entriesByName.isEmpty();
         }
     }
 
@@ -388,8 +362,8 @@ public abstract class OContainer extends WeakBase implements
     }
 
     protected int indexOf(String name) {
-        for (int i = 0; i < entriesByIndex.size(); i++) {
-            if (entriesByIndex.get(i).name.equals(name)) {
+        for (int i = 0; i < namesByIndex.size(); i++) {
+            if (namesByIndex.get(i).equals(name)) {
                 return i;
             }
         }
@@ -402,12 +376,11 @@ public abstract class OContainer extends WeakBase 
implements
      * @return ObjectType
      */
     protected Object getObject(int index) throws WrappedTargetException {
-        PropertyInfo propertyInfo = entriesByIndex.get(index);
-        HashMap<Long,XPropertySet> entriesById = 
entriesByNameAndId.get(propertyInfo.name);
-        XPropertySet propertySet = entriesById.get(propertyInfo.id);
+        String name = namesByIndex.get(index);
+        XPropertySet propertySet = entriesByName.get(name);
         if (propertySet == null) {
             try {
-                propertySet = createObject(propertyInfo.name);
+                propertySet = createObject(name);
             } catch (SQLException e) {
                 try {
                     dropImpl(index, false);
@@ -415,7 +388,7 @@ public abstract class OContainer extends WeakBase implements
                 }
                 throw new WrappedTargetException(e.getMessage(), this, e);
             }
-            entriesById.put(propertyInfo.id, propertySet);
+            entriesByName.put(name, propertySet);
         }
         return propertySet;
     }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
index e2d2c2df2a02..8a0c081935f8 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndex.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.PropertyAttribute;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XNameAccess;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbcx.XColumnsSupplier;
@@ -45,7 +46,7 @@ public class OIndex extends ODescriptor implements 
XColumnsSupplier, XDataDescri
     private OContainer columns;
 
     protected OIndex(Object lock, String name, boolean isCaseSensitive, String 
catalogName,
-            boolean isUnique, boolean isPrimaryKeyIndex, boolean isClustered, 
List<String> columnNames, OTable table) {
+            boolean isUnique, boolean isPrimaryKeyIndex, boolean isClustered, 
List<String> columnNames, OTable table) throws ElementExistException {
         super(lock, name, isCaseSensitive);
         this.catalogName = catalogName;
         this.isUnique = isUnique;
@@ -57,7 +58,7 @@ public class OIndex extends ODescriptor implements 
XColumnsSupplier, XDataDescri
     }
 
     public static OIndex create(String name, boolean isCaseSensitive, String 
catalogName,
-            boolean isUnique, boolean isPrimaryKeyIndex, boolean isClustered, 
List<String> columnNames, OTable table) {
+            boolean isUnique, boolean isPrimaryKeyIndex, boolean isClustered, 
List<String> columnNames, OTable table) throws ElementExistException {
         final Object lock = new Object();
         return new OIndex(lock, name, isCaseSensitive, catalogName, isUnique, 
isPrimaryKeyIndex, isClustered, columnNames, table);
     }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
index ecfdaa719abe..a107751d3fe5 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexColumnContainer.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.WrappedTargetException;
 import com.sun.star.sdbc.SQLException;
@@ -40,7 +41,7 @@ import com.sun.star.uno.UnoRuntime;
 public class OIndexColumnContainer extends OContainer {
     private OIndex index;
 
-    public OIndexColumnContainer(Object lock, OIndex index, List<String> 
columnNames) {
+    public OIndexColumnContainer(Object lock, OIndex index, List<String> 
columnNames) throws ElementExistException {
         super(lock, true, columnNames);
         this.index = index;
     }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
index 0aafd730406b..b6ad94bdfb16 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OIndexContainer.java
@@ -26,6 +26,7 @@ import java.util.List;
 
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XIndexAccess;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.IndexOutOfBoundsException;
@@ -50,7 +51,7 @@ import com.sun.star.uno.UnoRuntime;
 public class OIndexContainer extends OContainer {
     protected OTable table;
 
-    public OIndexContainer(Object lock, List<String> names, boolean 
isCaseSensitive, OTable table) {
+    public OIndexContainer(Object lock, List<String> names, boolean 
isCaseSensitive, OTable table) throws ElementExistException {
         super(lock, isCaseSensitive, names);
         this.table = table;
     }
@@ -113,7 +114,7 @@ public class OIndexContainer extends OContainer {
                 CompHelper.disposeComponent(results);
             }
             return ret;
-        } catch (WrappedTargetException | UnknownPropertyException | 
IllegalArgumentException exception) {
+        } catch (WrappedTargetException | UnknownPropertyException | 
IllegalArgumentException | ElementExistException exception) {
             throw new SQLException("Error", this, 
StandardSQLState.SQL_GENERAL_ERROR.text(), 0, exception);
         }
     }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
index 6ebae316be41..64581d154e26 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKey.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.PropertyAttribute;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XNameAccess;
 import com.sun.star.lang.DisposedException;
 import com.sun.star.sdbc.SQLException;
@@ -54,7 +55,7 @@ public class OKey extends ODescriptor
     }
 
     protected OKey(Object lock, String name, boolean isCaseSensitive, String 
referencedTable, int type,
-            int updateRule, int deleteRule, List<String> columnNames, OTable 
table) {
+            int updateRule, int deleteRule, List<String> columnNames, OTable 
table) throws ElementExistException {
         super(lock, name, isCaseSensitive);
         this.referencedTable = referencedTable;
         this.type = type;
@@ -66,7 +67,7 @@ public class OKey extends ODescriptor
     }
 
     public static OKey create(String name, boolean isCaseSensitive, String 
referencedTable, int type,
-            int updateRule, int deleteRule, List<String> columnNames, OTable 
table) {
+            int updateRule, int deleteRule, List<String> columnNames, OTable 
table) throws ElementExistException {
         final Object lock = new Object();
         return new OKey(lock, name, isCaseSensitive, referencedTable, type, 
updateRule, deleteRule, columnNames, table);
     }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
index e5c48944f5e7..06dadde82fab 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyColumnContainer.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.lang.IllegalArgumentException;
 import com.sun.star.lang.WrappedTargetException;
 import com.sun.star.sdbc.SQLException;
@@ -39,7 +40,7 @@ import com.sun.star.uno.UnoRuntime;
 public class OKeyColumnContainer extends OContainer {
     private OKey key;
 
-    public OKeyColumnContainer(Object lock, OKey key, List<String> 
columnNames) {
+    public OKeyColumnContainer(Object lock, OKey key, List<String> 
columnNames) throws ElementExistException {
         super(lock, true, columnNames);
         this.key = key;
     }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
index b8bab1d5b55c..78369a7c1aec 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/OKeyContainer.java
@@ -29,6 +29,7 @@ import java.util.Map;
 import com.sun.star.beans.PropertyVetoException;
 import com.sun.star.beans.UnknownPropertyException;
 import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ElementExistException;
 import com.sun.star.container.XIndexAccess;
 import com.sun.star.container.XNamed;
 import com.sun.star.lang.IllegalArgumentException;
@@ -54,7 +55,7 @@ public class OKeyContainer extends OContainer {
     private OTable table;
     private Map<String,OKey> keys;
 
-    protected OKeyContainer(Object lock, boolean isCaseSensitive, List<String> 
names, Map<String,OKey> keys, OTable table) {
+    protected OKeyContainer(Object lock, boolean isCaseSensitive, List<String> 
names, Map<String,OKey> keys, OTable table) throws ElementExistException {
         super(lock, isCaseSensitive, names);
         System.out.println("Keys.size()=" + keys.size());
         for (Map.Entry<String,OKey> entry : keys.entrySet()) {
@@ -77,7 +78,7 @@ public class OKeyContainer extends OContainer {
         this.table = table;
     }
 
-    public static OKeyContainer create(boolean isCaseSensitive, 
Map<String,OKey> keys, OTable table) {
+    public static OKeyContainer create(boolean isCaseSensitive, 
Map<String,OKey> keys, OTable table) throws ElementExistException {
         final Object lock = new Object();
         String[] names = new String[keys.size()];
         keys.keySet().toArray(names);
@@ -211,6 +212,7 @@ public class OKeyContainer extends OContainer {
         } catch (IllegalArgumentException illegalArgumentException) {
         } catch (IndexOutOfBoundsException indexOutOfBoundsException) {
         } catch (PropertyVetoException propertyVetoException) {
+        } catch (ElementExistException elementExistException) {
         }
         return null;
     }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
index ba1db755947c..7307391317dd 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/SqlTableHelper.java
@@ -28,6 +28,7 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
 
+import com.sun.star.container.ElementExistException;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbc.XDatabaseMetaData;
 import com.sun.star.sdbc.XResultSet;
@@ -37,6 +38,7 @@ import 
com.sun.star.sdbcx.comp.postgresql.comphelper.CompHelper;
 import com.sun.star.sdbcx.comp.postgresql.util.ComposeRule;
 import com.sun.star.sdbcx.comp.postgresql.util.DbTools;
 import com.sun.star.sdbcx.comp.postgresql.util.Osl;
+import com.sun.star.sdbcx.comp.postgresql.util.StandardSQLState;
 import com.sun.star.uno.Any;
 import com.sun.star.uno.UnoRuntime;
 
@@ -165,6 +167,8 @@ public class SqlTableHelper {
                 key = OKey.create(pkName, isCaseSensitive, "", 
KeyType.PRIMARY, 0, 0, columns, table);
             }
             return key;
+        } catch (ElementExistException elementExistException) {
+            throw new SQLException("Error", this, 
StandardSQLState.SQL_GENERAL_ERROR.text(), 0, elementExistException);
         } finally {
             CompHelper.disposeComponent(results);
         }
@@ -221,6 +225,8 @@ public class SqlTableHelper {
                     keys.put(oldFkName, key);
                 }
             }
+        } catch (ElementExistException elementExistException) {
+            throw new SQLException("Error", this, 
StandardSQLState.SQL_GENERAL_ERROR.text(), 0, elementExistException);
         } finally {
             CompHelper.disposeComponent(results);
         }
diff --git 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
index 16baf4cf680b..03d8f487ca7c 100644
--- 
a/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
+++ 
b/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/sdbcx/descriptors/SdbcxDescriptorContainer.java
@@ -21,8 +21,6 @@
 
 package com.sun.star.sdbcx.comp.postgresql.sdbcx.descriptors;
 
-import java.util.Collections;
-
 import com.sun.star.beans.XPropertySet;
 import com.sun.star.sdbc.SQLException;
 import com.sun.star.sdbcx.comp.postgresql.sdbcx.OContainer;
@@ -32,7 +30,7 @@ import 
com.sun.star.sdbcx.comp.postgresql.util.StandardSQLState;
 
 public abstract class SdbcxDescriptorContainer extends OContainer {
     public SdbcxDescriptorContainer(Object lock, boolean isCaseSensitive) {
-        super(lock, isCaseSensitive, Collections.<String>emptyList());
+        super(lock, isCaseSensitive);
     }
 
     @Override
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to