Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.j256.ormlite.db;
  
  import java.util.List;
  
Oracle database type information used to create the tables, etc..

WARNING: I have not tested this unfortunately because of a lack of access to a Oracle instance. Love to get 1-2 hours of access to an database to test/tweak this. Undoubtably is it wrong. Please contact Please contact us if you'd like to help with this class.

Author(s):
graywatson
 
 public class OracleDatabaseType extends BaseDatabaseType implements DatabaseType {
 
 	private final static String DATABASE_URL_PORTION = "oracle";
 	private final static String DRIVER_CLASS_NAME = "oracle.jdbc.driver.OracleDriver";
 	private final static String DATABASE_NAME = "Oracle";
 
 	public boolean isDatabaseUrlThisType(String urlString dbTypePart) {
 		return .equals(dbTypePart);
 	}
 
 	protected String getDriverClassName() {
 	}
 
 	public String getDatabaseName() {
 		return ;
 	}
 
 	protected void appendStringType(StringBuilder sbint fieldWidth) {
 		sb.append("VARCHAR2(").append(fieldWidth).append(")");
 	}
 
 	protected void appendLongStringType(StringBuilder sbint fieldWidth) {
 		sb.append("LONG");
 	}
 
 	protected void appendByteType(StringBuilder sbint fieldWidth) {
 		sb.append("SMALLINT");
 	}
 
 	protected void appendLongType(StringBuilder sbint fieldWidth) {
 		sb.append("NUMERIC");
 	}
 
 	protected void appendByteArrayType(StringBuilder sbint fieldWidth) {
 		sb.append("LONG RAW");
 	}
 
 	protected void appendSerializableType(StringBuilder sbint fieldWidth) {
 		sb.append("LONG RAW");
 	}
 
 	protected void configureGeneratedIdSequence(StringBuilder sbFieldType fieldTypeList<StringstatementsBefore,
 			List<StringadditionalArgsList<StringqueriesAfter) {
 		String seqName = fieldType.getGeneratedIdSequence();
 		// needs to match dropColumnArg()
 		StringBuilder seqSb = new StringBuilder(64);
 		seqSb.append("CREATE SEQUENCE ");
 		// when it is created, it needs to be escaped specially
 		appendEscapedEntityName(seqSbseqName);
 		statementsBefore.add(seqSb.toString());
 
 		configureId(sbfieldTypestatementsBeforeadditionalArgsqueriesAfter);
 	}
 
 	protected void configureId(StringBuilder sbFieldType fieldTypeList<StringstatementsBefore,
 			List<StringadditionalArgsList<StringqueriesAfter) {
 		sb.append("PRIMARY KEY ");
 	}
 
 	public void dropColumnArg(FieldType fieldTypeList<StringstatementsBeforeList<StringstatementsAfter) {
 		if (fieldType.isGeneratedIdSequence()) {
 			StringBuilder sb = new StringBuilder(64);
 			sb.append("DROP SEQUENCE ");
 			statementsAfter.add(sb.toString());
 		}
 	}
 
 	public void appendEscapedEntityName(StringBuilder sbString word) {
 		sb.append('\"').append(word).append('\"');
	}
	public boolean isIdSequenceNeeded() {
		return true;
	}
	public void appendSelectNextValFromSequence(StringBuilder sbString sequenceName) {
		sb.append("SELECT ");
		// this may not work -- may need to have no escape
		appendEscapedEntityName(sbsequenceName);
		// dual is some sort of special internal table I think
		sb.append(".nextval FROM dual");
	}
		return "SELECT 1 FROM DUAL";
	}
	public boolean isOffsetSqlSupported() {
		// there is no easy way to do this in this database type
		return false;
	}
New to GrepCode? Check out our FAQ X