本文整理汇总了Java中java.sql.Struct类的典型用法代码示例。如果您正苦于以下问题:Java Struct类的具体用法?Java Struct怎么用?Java Struct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Struct类属于java.sql包,在下文中一共展示了Struct类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObject
import java.sql.Struct; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
if (type == null) {
throw SQLError.createSQLException("Type parameter can not be null", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
}
if (type.equals(Struct.class)) {
throw new SQLFeatureNotSupportedException();
} else if (type.equals(RowId.class)) {
return (T) getRowId(columnIndex);
} else if (type.equals(NClob.class)) {
return (T) getNClob(columnIndex);
} else if (type.equals(SQLXML.class)) {
return (T) getSQLXML(columnIndex);
}
return super.getObject(columnIndex, type);
}
示例2: buildJdbcJavaClassMappings
import java.sql.Struct; //导入依赖的package包/类
private static ConcurrentHashMap<Class, Integer> buildJdbcJavaClassMappings() {
ConcurrentHashMap<Class, Integer> jdbcJavaClassMappings = new ConcurrentHashMap<Class, Integer>();
// these mappings are the ones outlined specifically in the spec
jdbcJavaClassMappings.put( String.class, Types.VARCHAR );
jdbcJavaClassMappings.put( BigDecimal.class, Types.NUMERIC );
jdbcJavaClassMappings.put( Boolean.class, Types.BIT );
jdbcJavaClassMappings.put( Integer.class, Types.INTEGER );
jdbcJavaClassMappings.put( Long.class, Types.BIGINT );
jdbcJavaClassMappings.put( Float.class, Types.REAL );
jdbcJavaClassMappings.put( Double.class, Types.DOUBLE );
jdbcJavaClassMappings.put( byte[].class, Types.LONGVARBINARY );
jdbcJavaClassMappings.put( java.sql.Date.class, Types.DATE );
jdbcJavaClassMappings.put( Time.class, Types.TIME );
jdbcJavaClassMappings.put( Timestamp.class, Types.TIMESTAMP );
jdbcJavaClassMappings.put( Blob.class, Types.BLOB );
jdbcJavaClassMappings.put( Clob.class, Types.CLOB );
jdbcJavaClassMappings.put( Array.class, Types.ARRAY );
jdbcJavaClassMappings.put( Struct.class, Types.STRUCT );
jdbcJavaClassMappings.put( Ref.class, Types.REF );
jdbcJavaClassMappings.put( Class.class, Types.JAVA_OBJECT );
// additional "common sense" registrations
jdbcJavaClassMappings.put( Character.class, Types.CHAR );
jdbcJavaClassMappings.put( char[].class, Types.VARCHAR );
jdbcJavaClassMappings.put( Character[].class, Types.VARCHAR );
jdbcJavaClassMappings.put( Byte[].class, Types.LONGVARBINARY );
jdbcJavaClassMappings.put( java.util.Date.class, Types.TIMESTAMP );
jdbcJavaClassMappings.put( Calendar.class, Types.TIMESTAMP );
return jdbcJavaClassMappings;
}
示例3: getStruct
import java.sql.Struct; //导入依赖的package包/类
@Override public Struct getStruct() throws SQLException {
final Object o = super.getObject();
if (o == null) {
return null;
} else if (o instanceof StructImpl) {
return (StructImpl) o;
} else if (o instanceof List) {
return new StructImpl((List) o);
} else {
final List<Object> list = new ArrayList<>();
for (Accessor fieldAccessor : fieldAccessors) {
try {
list.add(fieldAccessor.getObject());
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
return new StructImpl(list);
}
}
示例4: treatReturn
import java.sql.Struct; //导入依赖的package包/类
/**
* Tratar o retorno vido do java
* @param result
* @param returnType
* @return
*/
@SuppressWarnings("CallToPrintStackTrace")
private static Object treatReturn (Object result, int returnType)
{
Object currectObject = result;
try
{
if (returnType == ARRAY && result instanceof Array)
{
Array r = (Array) result;
currectObject = new ArrayList<> (Arrays.asList((Object [])r.getArray()));
}
else if (Types.STRUCT == returnType)
{
System.out.println("dbdkj");
currectObject = ((Struct) result).getAttributes();
}
}catch(Exception ex)
{
ex.printStackTrace();
}
if(currectObject != null)
System.out.println("RETURN = class{"+currectObject.getClass().getName()+"} | toString = "+currectObject.toString()+"\n");
return currectObject;
}
示例5: createStruct
import java.sql.Struct; //导入依赖的package包/类
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
checkClosed();
try {
return ((java.sql.Connection) this.mc).createStruct(typeName, attributes);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
return null; // never reached, but compiler can't tell
}
示例6: createStruct
import java.sql.Struct; //导入依赖的package包/类
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
{
try
{
return realConnection.createStruct(typeName, attributes);
}
catch(SQLException s)
{
String methodCall = "createStruct(" + typeName + ", " + attributes + ")";
reportException(methodCall, s, null);
throw s;
}
}
示例7: test08
import java.sql.Struct; //导入依赖的package包/类
@Test(enabled = true)
public void test08() throws Exception {
Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};
Struct s = new StubStruct(sqlType, attributes);
outImpl.writeStruct(s);
SerialStruct ss = (SerialStruct) results.get(0);
assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes()));
assertTrue(sqlType.equals(ss.getSQLTypeName()));
}
示例8: test11
import java.sql.Struct; //导入依赖的package包/类
@Test()
public void test11() throws Exception {
Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};
map.put(sqlType, Class.forName("util.SuperHero"));
Struct struct = new StubStruct(sqlType, attributes);
Object[] values = {struct};
SQLInputImpl sqli = new SQLInputImpl(values, map);
Object o = sqli.readObject();
assertTrue(hero.equals(o));
}
示例9: getObject
import java.sql.Struct; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override public <T> T getObject(Class<T> clz) throws SQLException {
// getStruct() is not exposed on Accessor, only AccessorImpl. getObject(Class) is exposed,
// so we can make it do the right thing (call getStruct()).
if (clz.equals(Struct.class)) {
return (T) getStruct();
}
return super.getObject(clz);
}
示例10: createStruct
import java.sql.Struct; //导入依赖的package包/类
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
throwIfClosed();
try {
return super.createStruct(typeName, attributes);
}
catch (UnsupportedOperationException e) {
throw new SQLFeatureNotSupportedException(e.getMessage(), e);
}
}
示例11: createStruct
import java.sql.Struct; //导入依赖的package包/类
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
{
return checkClosedAndThrowUnsupportedException();
}
示例12: createStruct
import java.sql.Struct; //导入依赖的package包/类
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
{
checkClosed();
throw SQLError.noSupport();
}
示例13: createStruct
import java.sql.Struct; //导入依赖的package包/类
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
return con.createStruct(typeName, attributes);
}
示例14: createStruct
import java.sql.Struct; //导入依赖的package包/类
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
return conn.createStruct(typeName, attributes);
}
示例15: createStruct
import java.sql.Struct; //导入依赖的package包/类
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
return connection.createStruct(typeName, attributes);
}