Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-09-26 09:58:45 +0000
committerEike Stepper2013-09-26 09:58:45 +0000
commit4bc6f5ff208881583a71a84b4d42ee3a5583a1fc (patch)
tree7c4292bacebd071de891a7c68820ad3db26146da /plugins/org.eclipse.net4j.db.oracle/src/org/eclipse
parent8c0eef51dcd32ed54494d20eb57d3037c4126ba7 (diff)
downloadcdo-4bc6f5ff208881583a71a84b4d42ee3a5583a1fc.tar.gz
cdo-4bc6f5ff208881583a71a84b4d42ee3a5583a1fc.tar.xz
cdo-4bc6f5ff208881583a71a84b4d42ee3a5583a1fc.zip
[418076] [DB] Add OracleConfig for execution of DBStore tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418076
Diffstat (limited to 'plugins/org.eclipse.net4j.db.oracle/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.net4j.db.oracle/src/org/eclipse/net4j/db/oracle/OracleAdapter.java100
1 files changed, 99 insertions, 1 deletions
diff --git a/plugins/org.eclipse.net4j.db.oracle/src/org/eclipse/net4j/db/oracle/OracleAdapter.java b/plugins/org.eclipse.net4j.db.oracle/src/org/eclipse/net4j/db/oracle/OracleAdapter.java
index d39289ae33..89d752e4b3 100644
--- a/plugins/org.eclipse.net4j.db.oracle/src/org/eclipse/net4j/db/oracle/OracleAdapter.java
+++ b/plugins/org.eclipse.net4j.db.oracle/src/org/eclipse/net4j/db/oracle/OracleAdapter.java
@@ -11,10 +11,21 @@
*/
package org.eclipse.net4j.db.oracle;
+import oracle.jdbc.pool.OracleDataSource;
+
import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnectionProvider;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.spi.db.DBAdapter;
+import org.eclipse.net4j.util.security.IUserAware;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,6 +42,17 @@ public class OracleAdapter extends DBAdapter
super(NAME, VERSION);
}
+ @Override
+ public IDBConnectionProvider createConnectionProvider(DataSource dataSource)
+ {
+ if (dataSource instanceof OracleDataSource)
+ {
+ return DBUtil.createConnectionProvider(dataSource, ((OracleDataSource)dataSource).getUser());
+ }
+
+ return super.createConnectionProvider(dataSource);
+ }
+
public String[] getReservedWords()
{
List<String> list = new ArrayList<String>(Arrays.asList(getSQL92ReservedWords()));
@@ -70,6 +92,7 @@ public class OracleAdapter extends DBAdapter
return "NUMBER(5)";
case SMALLINT:
case BOOLEAN:
+ case BIT:
return "NUMBER(7)";
case INTEGER:
return "NUMBER(12)";
@@ -78,7 +101,13 @@ public class OracleAdapter extends DBAdapter
return "DATE";
case CHAR:
case VARCHAR:
- return "VARCHAR2(" + field.getPrecision() + ")";
+ return "VARCHAR2(" + field.getPrecision() + " CHAR)";
+ case LONGVARCHAR:
+ return "LONG";
+ case BINARY:
+ case VARBINARY:
+ case LONGVARBINARY:
+ return "LONG RAW";
default:
return super.getTypeName(field);
}
@@ -144,4 +173,73 @@ public class OracleAdapter extends DBAdapter
{
return "ALTER TABLE " + tableName + " MODIFY " + fieldName + " " + definition;
}
+
+ @Override
+ protected ResultSet readTables(Connection connection, DatabaseMetaData metaData, String schemaName)
+ throws SQLException
+ {
+ if (schemaName == null && connection instanceof IUserAware)
+ {
+ schemaName = ((IUserAware)connection).getUserID();
+ }
+
+ return metaData.getTables(null, schemaName, null, new String[] { "TABLE" });
+ }
+
+ @Override
+ public String convertString(PreparedStatement preparedStatement, int parameterIndex, String value)
+ {
+ if (value != null && value.length() == 0)
+ {
+ String replacement = getEmptyStringReplacement();
+ if (replacement != null)
+ {
+ value = replacement;
+ }
+ }
+
+ return super.convertString(preparedStatement, parameterIndex, value);
+ }
+
+ @Override
+ public String convertString(ResultSet resultSet, int columnIndex, String value)
+ {
+ value = super.convertString(resultSet, columnIndex, value);
+
+ if (value != null)
+ {
+ String replacement = getEmptyStringReplacement();
+ if (replacement != null && replacement.equals(value))
+ {
+ value = "";
+ }
+ }
+
+ return value;
+ }
+
+ @Override
+ public String convertString(ResultSet resultSet, String columnLabel, String value)
+ {
+ value = super.convertString(resultSet, columnLabel, value);
+
+ if (value != null)
+ {
+ String replacement = getEmptyStringReplacement();
+ if (replacement != null && replacement.equals(value))
+ {
+ value = null;
+ }
+ }
+
+ return value;
+ }
+
+ /**
+ * @since 1.1
+ */
+ protected String getEmptyStringReplacement()
+ {
+ return "<empty>";
+ }
}

Back to the top