项目:NICON
文件:Call.java
/**
* Essa funcoa serve para invocar uma funcao da base de dados que retorna um
* Tipo costumisada e que esta mapeado com java
* @param functionName
* @param sqlType
* @param javaClass
* @param parans
* @return
*/
@SuppressWarnings("CallToprintstacktrace")
public static sqlData callMapFunction (String functionName,String sqlType,Class javaClass,Object ... parans)
{
if(!EstadoConnexao.isValid) return null;
try
{
Connection con = new Conexao().getCon();
Object result;
// Criar as interoganocoes necessaria para a invocacao da funcao ex (?,?,...) || nada
String interogations = (parans != null && parans.length>0)? createInterogation(parans.length): "";
//Associa ao call e o nome da funcao
String sql = "{? = call "+functionName+interogations+"}";
con.getTypeMap().put(sqlType,javaClass);
try (CallableStatement call = mapParamsType(con,sql,2,parans))
{
call.registerOutParameter(1,Types.STRUCT,sqlType);
call.execute();
result = Call.treatReturn(call.getobject(1),VARCHAR);
}
return (sqlData) result;
}catch(Exception ex)
{
ex.printstacktrace();
}
return null;
}
项目:pljava
文件:Commands.java
/**
* Defines the mapping between an sql type and a Java class.
*
* @param sqlTypeName The name of the sql type. The name can be
* qualified with a schema (namespace). If the schema is omitted,* it will be resolved according to the current setting of the
* {@code search_path}.
* @param javaClassName The name of the class. The class must be found in
* the classpath in effect for the current schema
* @throws sqlException if the type or class cannot be found,or if the
* invoking user does not own the type.
*/
@Function(schema="sqlj",name="add_type_mapping",security=DEFINER)
public static void addTypeMapping(String sqlTypeName,String javaClassName)
throws sqlException
{
PreparedStatement stmt = null;
try
{
ClassLoader loader = Loader.getCurrentLoader();
Class cls = loader.loadClass(javaClassName);
if(!sqlData.class.isAssignableFrom(cls))
throw new sqlException("Class " + javaClassName
+ " does not implement java.sql.sqlData");
sqlTypeName = getFullsqlNameOwned(sqlTypeName);
stmt = sqlUtils
.getDefaultConnection()
.prepareStatement(
"INSERT INTO sqlj.typemap_entry(javaName,sqlName) VALUES(?,?)");
stmt.setString(1,javaClassName);
stmt.setString(2,sqlTypeName);
stmt.executeUpdate();
}
catch(ClassNotFoundException e)
{
throw new sqlException(
"No such class: " + javaClassName,"46103",e);
}
finally
{
sqlUtils.close(stmt);
}
Loader.clearSchemaLoaders();
}
项目:SimpleFlatMapper
文件:PreparedStatementIndexedSetterFactory.java
@SuppressWarnings("unchecked")
protected <T> IndexedSetter<PreparedStatement,T> getIndexedSetter(Type propertyType,PropertyMapping<?,JdbcColumnKey,? extends ColumnDeFinition<JdbcColumnKey,?>> arg) {
IndexedSetter<PreparedStatement,T> setter = null;
if (TypeHelper.isEnum(propertyType)) {
switch (arg.getColumnKey().getsqlType()) {
case Types.NUMERIC:
case Types.BIGINT:
case Types.INTEGER:
case Types.DECIMAL:
case Types.DOUBLE:
case Types.FLOAT:
case Types.SMALLINT:
case Types.REAL:
case Types.tinyint:
setter = (IndexedSetter<PreparedStatement,T>) new OrdinalEnumPreparedStatementIndexSetter();
break;
default:
setter = (IndexedSetter<PreparedStatement,T>) new StringEnumPreparedStatementIndexSetter();
}
}
if (setter == null) {
Factory setterFactory = this.factoryPerClass.get(TypeHelper.toClass(propertyType));
if (setterFactory != null) {
setter = setterFactory.<T>getIndexedSetter(arg.getColumnKey());
}
}
if (setter == null && TypeHelper.isAssignable(sqlData.class,propertyType)) {
setter = (IndexedSetter<PreparedStatement,T>) new ObjectPreparedStatementIndexSetter();
}
return setter;
}
/**
* {@inheritDoc}
*
* @see java.sql.sqlOutput#writeObject(sqlData)
*/
@SuppressWarnings("unchecked")
public void writeObject(sqlData theObject) throws sqlException {
if (theObject == null) {
attributes.addElement(null);
} else {
attributes
.addElement(new SerialStruct(theObject,new HashMap(map)));
}
}
/**
* {@inheritDoc}
*
* @see java.sql.sqlOutput#writeObject(sqlData)
*/
@SuppressWarnings("unchecked")
public void writeObject(sqlData theObject) throws sqlException {
if (theObject == null) {
attributes.addElement(null);
} else {
attributes
.addElement(new SerialStruct(theObject,new HashMap(map)));
}
}
项目:pljava
文件:DDRProcessor.java
DDRProcessorImpl( ProcessingEnvironment processingEnv)
{
elmu = processingEnv.getElementUtils();
filr = processingEnv.getFiler();
loca = processingEnv.getLocale();
msgr = processingEnv.getMessager();
opts = processingEnv.getoptions();
srcv = processingEnv.getSourceVersion();
typu = processingEnv.getTypeUtils();
tmpr = new TypeMapper();
String optv;
optv = opts.get( "ddr.name.trusted");
if ( null != optv )
nameTrusted = optv;
else
nameTrusted = "java";
optv = opts.get( "ddr.name.untrusted");
if ( null != optv )
nameUntrusted = optv;
else
nameUntrusted = "javaU";
optv = opts.get( "ddr.implementor");
if ( null != optv )
defaultImplementor = "-".equals( optv) ? null : optv;
else
defaultImplementor = "Postgresql";
optv = opts.get( "ddr.output");
if ( null != optv )
output = optv;
else
output = "pljava.ddr";
TY_IteraTOR = typu.getDeclaredType(
elmu.getTypeElement( java.util.Iterator.class.getName()));
TY_OBJECT = typu.getDeclaredType(
elmu.getTypeElement( Object.class.getName()));
TY_RESULTSET = typu.getDeclaredType(
elmu.getTypeElement( java.sql.ResultSet.class.getName()));
TY_RESULTSETPROVIDER = typu.getDeclaredType(
elmu.getTypeElement( ResultSetProvider.class.getName()));
TY_RESULTSETHANDLE = typu.getDeclaredType(
elmu.getTypeElement( ResultSetHandle.class.getName()));
TY_sqlDATA = typu.getDeclaredType(
elmu.getTypeElement( sqlData.class.getName()));
TY_sqlINPUT = typu.getDeclaredType(
elmu.getTypeElement( sqlInput.class.getName()));
TY_sqlOUTPUT = typu.getDeclaredType(
elmu.getTypeElement( sqlOutput.class.getName()));
TY_STRING = typu.getDeclaredType(
elmu.getTypeElement( String.class.getName()));
TY_TRIGGERDATA = typu.getDeclaredType(
elmu.getTypeElement( TriggerData.class.getName()));
TY_VOID = typu.getNoType( TypeKind.VOID);
AN_FUNCTION = elmu.getTypeElement( Function.class.getName());
AN_sqlACTION = elmu.getTypeElement( sqlAction.class.getName());
AN_sqlACTIONS = elmu.getTypeElement( sqlActions.class.getName());
AN_sqlTYPE = elmu.getTypeElement( sqlType.class.getName());
AN_TRIGGER = elmu.getTypeElement( Trigger.class.getName());
AN_BASEUDT = elmu.getTypeElement( BaseUDT.class.getName());
AN_MAPPEDUDT = elmu.getTypeElement( MappedUDT.class.getName());
}
项目:freeVM
文件:SerialStruct.java
public SerialStruct(sqlData in,Map<String,Class<?>> map)
throws SerialException,NotImplementedException {
throw new NotImplementedException();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。