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;
}
}
- public void disconnect(Connection connection) throws ConnectionException {
- try {
- if (connection != null) {
- connection.close();
- }
- } catch (SQLException e) {
- throw new ConnectionException(e);
+ public void disconnect(Connection connection) throws SQLException {
+ if (connection != null) {
+ connection.close();
}
}
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) {
return connection;
} else {
throw new ConnectionException(Messages.getString(
- ConnectionException.class, "couldNotInstaniateDriver",
+ ConnectionException.class, "couldNotInstantiateDriver",
new Object[] { jdbcDriver.getClassName(), bookmark.getName() }));
}
} catch (SQLException e) {
}
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();
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;