preparing new release
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / sql / MultiSQLServer.java
index 8875a1d..1572da0 100644 (file)
@@ -9,12 +9,14 @@ import java.sql.Statement;
 import java.util.Properties;
 
 import com.quantum.Messages;
+import com.quantum.adapters.AdapterFactory;
 import com.quantum.adapters.DatabaseAdapter;
 import com.quantum.model.Bookmark;
 import com.quantum.model.ConnectionException;
 import com.quantum.model.Entity;
 import com.quantum.model.JDBCDriver;
 import com.quantum.model.PasswordFinder;
+import com.quantum.util.sql.SQLInstructionBuilder;
 import com.quantum.view.LogProxy;
 
 
@@ -115,11 +117,26 @@ public class MultiSQLServer implements ConnectionEstablisher {
         log.addText(LogProxy.QUERY, "Connecting to: " + bookmark.getName()); //$NON-NLS-1$
         try {
                JDBCDriver jdbcDriver = bookmark.getJDBCDriver();
-            Driver driver = jdbcDriver.getDriver();
+               Driver driver = jdbcDriver.getDriver();
             if (driver != null) {
                    Properties props = new Properties();
                    props.put(USERNAME, bookmark.getUsername());
                    props.put(PASSWORD, password);
+                   // TODO: This kind of things should really be made general-purpose
+                   if (jdbcDriver.getType().equals(AdapterFactory.ORACLE)){ 
+                       // remarksReporting will make the JDBC driver return the remarks for the tables and
+                       // the columns. It'll make getting the tables and columns much slower, so it should
+                       // really be made into an option
+                       // TODO: Make remark reporting into an option
+                       props.put("remarksReporting", "true");
+                       // includeSynonyms will make the JDBC driver return the proper columns when querying
+                       // about a synonym. If not given, synonyms will appear with no columns, exports of data
+                       // containing synonyms will break, etc.n So it's needed from the moment you add the synonyms
+                       // with the getSynonymsList() in the Database.getEntities() function. That could also be
+                       // made into an option, but more logically when more databases are addedd
+                       // TODO: Make including synonyms into an option
+                       props.put("includeSynonyms", "true");
+                   }
                    Connection connection =
                        driver.connect(bookmark.getConnect(), props);
                    if (connection == null) {
@@ -134,7 +151,7 @@ public class MultiSQLServer implements ConnectionEstablisher {
                    return connection;
             } else {
                throw new ConnectionException(Messages.getString(
-                               ConnectionException.class, "couldNotInstaniateDriver", 
+                               ConnectionException.class, "couldNotInstantiateDriver", 
                                                new Object[] { jdbcDriver.getClassName(), bookmark.getName() }));
             }
         } catch (SQLException e) {
@@ -152,7 +169,7 @@ public class MultiSQLServer implements ConnectionEstablisher {
        }
        
        public SQLResultSetResults getMetaData(Entity entity, Connection connection) throws SQLException {
-               String query = "SELECT * FROM " + entity.getQuotedTableName() + " WHERE (1 = 0)"; //$NON-NLS-1$ //$NON-NLS-2$
+               String query = SQLInstructionBuilder.buildSelectAllColumnsNoRows(entity);
                SQLResultSetResults results = null;
                if (connection != null) {
                        Statement statement = connection.createStatement();
@@ -187,7 +204,7 @@ public class MultiSQLServer implements ConnectionEstablisher {
                long startTime = System.currentTimeMillis();
                System.out.println("Executing"); //$NON-NLS-1$
                LogProxy log = LogProxy.getInstance();
-               log.addText(LogProxy.QUERY, "Executing Request [" + sql + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+               log.addText(LogProxy.QUERY, "SQL (" + bookmark.getName() + ") [" + sql + "]"); //$NON-NLS-1$ //$NON-NLS-2$
                Statement statement = con.createStatement();
                try {
                        SQLResults results;