当前位置: 首页>>代码示例>>Java>>正文


Java Types类代码示例

本文整理汇总了Java中java.sql.Types的典型用法代码示例。如果您正苦于以下问题:Java Types类的具体用法?Java Types怎么用?Java Types使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Types类属于java.sql包,在下文中一共展示了Types类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SQLServerDialect

import java.sql.Types; //导入依赖的package包/类
/**
 * Constructs a SQLServerDialect
 */
public SQLServerDialect() {
	registerColumnType( Types.VARBINARY, "image" );
	registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );
	registerColumnType( Types.LONGVARBINARY, "image" );
	registerColumnType( Types.LONGVARCHAR, "text" );
	registerColumnType( Types.BOOLEAN, "bit" );

	registerFunction( "second", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(second, ?1)" ) );
	registerFunction( "minute", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(minute, ?1)" ) );
	registerFunction( "hour", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(hour, ?1)" ) );
	registerFunction( "locate", new StandardSQLFunction( "charindex", StandardBasicTypes.INTEGER ) );

	registerFunction( "extract", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datepart(?1, ?3)" ) );
	registerFunction( "mod", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "?1 % ?2" ) );
	registerFunction( "bit_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "datalength(?1) * 8" ) );

	registerFunction( "trim", new AnsiTrimEmulationFunction() );

	registerKeyword( "top" );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SQLServerDialect.java

示例2: testBug35199

import java.sql.Types; //导入依赖的package包/类
public void testBug35199() throws Exception {
    if (!versionMeetsMinimum(5, 0)) {
        return;
    }

    createFunction("test_function", "(a varchar(40), b bigint(20), c varchar(80)) RETURNS bigint(20) LANGUAGE SQL DETERMINISTIC "
            + "MODIFIES SQL DATA COMMENT 'bbb' BEGIN RETURN 1; END; ");

    CallableStatement callable = null;
    try {
        callable = this.conn.prepareCall("{? = call test_function(?,101,?)}");
        callable.registerOutParameter(1, Types.BIGINT);

        callable.setString(2, "FOO");
        callable.setString(3, "BAR");
        callable.executeUpdate();
    } finally {
        if (callable != null) {
            callable.close();
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:23,代码来源:CallableStatementRegressionTest.java

示例3: setBinaryStream

import java.sql.Types; //导入依赖的package包/类
/**
 * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream, int)
 */
@Override
public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {

        if (x == null) {
            setNull(parameterIndex, java.sql.Types.BINARY);
        } else {
            BindValue binding = getBinding(parameterIndex, true);
            resetToType(binding, MysqlDefs.FIELD_TYPE_BLOB);

            binding.value = x;
            binding.isLongData = true;

            if (this.connection.getUseStreamLengthsInPrepStmts()) {
                binding.bindLength = length;
            } else {
                binding.bindLength = -1;
            }
        }
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:25,代码来源:ServerPreparedStatement.java

示例4: setCharacterStream

import java.sql.Types; //导入依赖的package包/类
/**
 * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader, int)
 */
@Override
public void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {

        if (reader == null) {
            setNull(parameterIndex, java.sql.Types.BINARY);
        } else {
            BindValue binding = getBinding(parameterIndex, true);
            setType(binding, MysqlDefs.FIELD_TYPE_BLOB);

            binding.value = reader;
            binding.isNull = false;
            binding.isLongData = true;

            if (this.connection.getUseStreamLengthsInPrepStmts()) {
                binding.bindLength = length;
            } else {
                binding.bindLength = -1;
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ServerPreparedStatement.java

示例5: sqlCreateStrings

import java.sql.Types; //导入依赖的package包/类
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
	return new String[] {
		new StringBuilder( dialect.getCreateTableString() )
				.append( ' ' )
				.append( tableName )
				.append( " ( " )
				.append( pkColumnName )
				.append( ' ' )
				.append( dialect.getTypeName( Types.VARCHAR, keySize, 0, 0 ) )
				.append( ",  " )
				.append( valueColumnName )
				.append( ' ' )
				.append( dialect.getTypeName( Types.INTEGER ) )
				.append( " )" )
				.append( dialect.getTableTypeString() )
				.toString()
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:MultipleHiLoPerTableGenerator.java

示例6: testSequenceFile

import java.sql.Types; //导入依赖的package包/类
/**
 * Test other file formats.
 */
public void testSequenceFile() throws Exception {
  final int TOTAL_RECORDS = 1 * 10;
  String table = getTableName().toUpperCase();
  ColumnGenerator[] cols = new ColumnGenerator[] {
      HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
          "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 0, 0,
          "1", "1", KeyType.STATIC_KEY),
      HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
          "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 0, 0,
          "2", "2", KeyType.DYNAMIC_KEY), };

  List<String> addlArgsArray = new ArrayList<String>();
  addlArgsArray.add("--hive-partition-key");
  addlArgsArray.add("col0");
  addlArgsArray.add("--hive-partition-value");
  addlArgsArray.add("1");
  utils.setStorageInfo(HCatalogTestUtils.STORED_AS_SEQFILE);
  runHCatExport(addlArgsArray, TOTAL_RECORDS, table, cols);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:23,代码来源:HCatalogExportTest.java

示例7: setTimeInternal

import java.sql.Types; //导入依赖的package包/类
/**
 * Set a parameter to a java.sql.Time value. The driver converts this to a
 * SQL TIME value when it sends it to the database, using the given
 * timezone.
 * 
 * @param parameterIndex
 *            the first parameter is 1...));
 * @param x
 *            the parameter value
 * @param tz
 *            the timezone to use
 * 
 * @throws java.sql.SQLException
 *             if a database access error occurs
 */
private void setTimeInternal(int parameterIndex, Time x, Calendar targetCalendar, TimeZone tz, boolean rollForward) throws java.sql.SQLException {
    if (x == null) {
        setNull(parameterIndex, java.sql.Types.TIME);
    } else {
        checkClosed();

        if (!this.useLegacyDatetimeCode) {
            newSetTimeInternal(parameterIndex, x, targetCalendar);
        } else {
            Calendar sessionCalendar = getCalendarInstanceForSessionOrNew();

            x = TimeUtil.changeTimezone(this.connection, sessionCalendar, targetCalendar, x, tz, this.connection.getServerTimezoneTZ(), rollForward);

            setInternal(parameterIndex, "'" + x.toString() + "'");
        }

        this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.TIME;
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:35,代码来源:PreparedStatement.java

示例8: isDecimalType

import java.sql.Types; //导入依赖的package包/类
/**
 * Checks if the SQL Type is a Decimal/Number Type
 * 
 * @param type
 *            SQL Type
 */
private static final boolean isDecimalType(int type) {
    switch (type) {
        case Types.BIT:
        case Types.TINYINT:
        case Types.SMALLINT:
        case Types.INTEGER:
        case Types.BIGINT:
        case Types.FLOAT:
        case Types.REAL:
        case Types.DOUBLE:
        case Types.NUMERIC:
        case Types.DECIMAL:
            return true;
    }

    return false;
}
 
开发者ID:Jugendhackt,项目名称:OpenVertretung,代码行数:24,代码来源:ResultSetMetaData.java

示例9: CustomJavaTypeResolver

import java.sql.Types; //导入依赖的package包/类
public CustomJavaTypeResolver() {
    super();
    typeMap.put(Types.ARRAY, new JdbcTypeInformation("ARRAY", new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.BIGINT, new JdbcTypeInformation("BIGINT", new FullyQualifiedJavaType(Long.class.getName())));
    typeMap.put(Types.BINARY, new JdbcTypeInformation("BINARY", new FullyQualifiedJavaType("byte[]")));
    typeMap.put(Types.BIT, new JdbcTypeInformation("BIT", new FullyQualifiedJavaType(Boolean.class.getName())));
    typeMap.put(Types.BLOB, new JdbcTypeInformation("BLOB", new FullyQualifiedJavaType("byte[]")));
    typeMap.put(Types.BOOLEAN, new JdbcTypeInformation("BOOLEAN", new FullyQualifiedJavaType(Boolean.class.getName())));
    typeMap.put(Types.CHAR, new JdbcTypeInformation("CHAR", new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.CLOB, new JdbcTypeInformation("CLOB", new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.DATALINK, new JdbcTypeInformation("DATALINK", new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.DATE, new JdbcTypeInformation("DATE", new FullyQualifiedJavaType(Date.class.getName())));
    typeMap.put(Types.DECIMAL, new JdbcTypeInformation("DECIMAL", new FullyQualifiedJavaType(BigDecimal.class.getName())));
    typeMap.put(Types.DISTINCT, new JdbcTypeInformation("DISTINCT", new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.DOUBLE, new JdbcTypeInformation("DOUBLE", new FullyQualifiedJavaType(Double.class.getName())));
    typeMap.put(Types.FLOAT, new JdbcTypeInformation("FLOAT", new FullyQualifiedJavaType(Double.class.getName())));
    typeMap.put(Types.INTEGER, new JdbcTypeInformation("INTEGER", new FullyQualifiedJavaType(Integer.class.getName())));
    typeMap.put(Types.JAVA_OBJECT, new JdbcTypeInformation("JAVA_OBJECT", new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.LONGNVARCHAR, new JdbcTypeInformation("LONGNVARCHAR", new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.LONGVARBINARY, new JdbcTypeInformation("LONGVARBINARY", new FullyQualifiedJavaType("byte[]")));
    typeMap.put(Types.LONGVARCHAR, new JdbcTypeInformation("LONGVARCHAR", new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.NCHAR, new JdbcTypeInformation("NCHAR", new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.NCLOB, new JdbcTypeInformation("NCLOB", new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.NVARCHAR, new JdbcTypeInformation("NVARCHAR", new FullyQualifiedJavaType(String.class.getName())));
    typeMap.put(Types.NULL, new JdbcTypeInformation("NULL", new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.NUMERIC, new JdbcTypeInformation("NUMERIC", new FullyQualifiedJavaType(BigDecimal.class.getName())));
    typeMap.put(Types.OTHER, new JdbcTypeInformation("OTHER", new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.REAL, new JdbcTypeInformation("REAL", new FullyQualifiedJavaType(Float.class.getName())));
    typeMap.put(Types.REF, new JdbcTypeInformation("REF", new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.SMALLINT, new JdbcTypeInformation("SMALLINT", new FullyQualifiedJavaType(Short.class.getName())));
    typeMap.put(Types.STRUCT, new JdbcTypeInformation("STRUCT", new FullyQualifiedJavaType(Object.class.getName())));
    typeMap.put(Types.TIME, new JdbcTypeInformation("TIME", new FullyQualifiedJavaType(Date.class.getName())));
    typeMap.put(Types.TIMESTAMP, new JdbcTypeInformation("TIMESTAMP", new FullyQualifiedJavaType(Date.class.getName())));
    // 更改默认的 Byte 为 Integer
    typeMap.put(Types.TINYINT, new JdbcTypeInformation("TINYINT", new FullyQualifiedJavaType(Integer.class.getName())));
    typeMap.put(Types.VARBINARY, new JdbcTypeInformation("VARBINARY", new FullyQualifiedJavaType("byte[]")));
    typeMap.put(Types.VARCHAR, new JdbcTypeInformation("VARCHAR", new FullyQualifiedJavaType(String.class.getName())));
}
 
开发者ID:drtrang,项目名称:mybatis-generator-extension,代码行数:39,代码来源:CustomJavaTypeResolver.java

示例10: setDate

import java.sql.Types; //导入依赖的package包/类
public QueryBuilder setDate(String name, Date value) throws SQLException {
    for (int i : indexes(name)) {
        try {
            if (value == null) {
                statement.setNull(i, Types.TIMESTAMP);
            } else {
                statement.setTimestamp(i, new Timestamp(value.getTime()));
            }
        } catch (SQLException error) {
            statement.close();
            connection.close();
            throw error;
        }
    }
    return this;
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:17,代码来源:QueryBuilder.java

示例11: Field

import java.sql.Types; //导入依赖的package包/类
/**
 * Used by prepared statements to re-use result set data conversion methods
 * when generating bound parmeter retrieval instance for statement
 * interceptors.
 * 
 * @param tableName
 *            not used
 * @param columnName
 *            not used
 * @param charsetIndex
 *            the MySQL collation/character set index
 * @param jdbcType
 *            from java.sql.Types
 * @param length
 *            length in characters or bytes (for BINARY data).
 */
Field(String tableName, String columnName, int charsetIndex, int jdbcType, int length) {
    this.tableName = tableName;
    this.name = columnName;
    this.length = length;
    this.sqlType = jdbcType;
    this.colFlag = 0;
    this.colDecimals = 0;
    this.collationIndex = charsetIndex;
    this.valueNeedsQuoting = determineNeedsQuoting();

    switch (this.sqlType) {
        case Types.BINARY:
        case Types.VARBINARY:
            this.colFlag |= 128;
            this.colFlag |= 16;
            break;
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:35,代码来源:Field.java

示例12: calculateJdbcTypeName

import java.sql.Types; //导入依赖的package包/类
public String calculateJdbcTypeName(IntrospectedColumn introspectedColumn) {
	String answer;
	JdbcTypeInformation jdbcTypeInformation = typeMap
			.get(introspectedColumn.getJdbcType());

	if (jdbcTypeInformation == null) {
		switch (introspectedColumn.getJdbcType()) {
		case Types.DECIMAL:
			answer = "DECIMAL"; //$NON-NLS-1$
			break;
		case Types.NUMERIC:
			answer = "NUMERIC"; //$NON-NLS-1$
			break;
		default:
			answer = null;
			break;
		}
	} else {
		answer = jdbcTypeInformation.getJdbcTypeName();
	}

	return answer;
}
 
开发者ID:ling49043171,项目名称:mark-mybatis-generator,代码行数:24,代码来源:DB2JavaTypeResolver.java

示例13: setDate

import java.sql.Types; //导入依赖的package包/类
/**
 * Set a parameter to a java.sql.Date value. The driver converts this to a
 * SQL DATE value when it sends it to the database.
 * 
 * @param parameterIndex
 *            the first parameter is 1, the second is 2, ...
 * @param x
 *            the parameter value
 * @param cal
 *            the calendar to interpret the date with
 * 
 * @exception SQLException
 *                if a database-access error occurs.
 */
public void setDate(int parameterIndex, java.sql.Date x, Calendar cal) throws SQLException {
    if (x == null) {
        setNull(parameterIndex, java.sql.Types.DATE);
    } else {
        if (!this.useLegacyDatetimeCode) {
            newSetDateInternal(parameterIndex, x, cal);
        } else {
            synchronized (checkClosed().getConnectionMutex()) {
                if (this.ddf == null) {
                    this.ddf = new SimpleDateFormat("''yyyy-MM-dd''", Locale.US);
                }
                if (cal != null) {
                    this.ddf.setTimeZone(cal.getTimeZone());
                }

                setInternal(parameterIndex, this.ddf.format(x));

                this.parameterTypes[parameterIndex - 1 + getParameterIndexOffset()] = Types.DATE;
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:PreparedStatement.java

示例14: testExecuteUpdate

import java.sql.Types; //导入依赖的package包/类
/**
 * DB更新処理のテストケース。
 */
@Test
public void testExecuteUpdate() throws Exception {
	// 事前条件
	cleanInsert(Paths.get("src/test/resources/data/setup", "testExecuteUpdate.ltsv"));

	SqlContext ctx = agent.contextFrom("example/selectinsert_product")
			.param("product_id", new BigDecimal("0"), JDBCType.DECIMAL)
			.param("jan_code", "1234567890123", Types.CHAR);

	int updateCount = agent.update(ctx);
	assertEquals("データの登録に失敗しました。", 1, updateCount);

	// 検証処理
	List<Map<String, Object>> expectedDataList = getDataFromFile(Paths.get(
			"src/test/resources/data/expected/SqlAgent", "testExecuteUpdate.ltsv"));
	List<Map<String, Object>> actualDataList = agent.query("example/select_product")
			.paramList("product_id", 0, 1).stream(new MapResultSetConverter(CaseFormat.LOWER_SNAKE_CASE))
			.collect(Collectors.toList());

	assertEquals(expectedDataList.toString(), actualDataList.toString());
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:25,代码来源:SqlAgentTest.java

示例15: testBug17898

import java.sql.Types; //导入依赖的package包/类
/**
 * Tests fix for BUG#17898 - registerOutParameter not working when some
 * parameters pre-populated. Still waiting for feedback from JDBC experts
 * group to determine what correct parameter count from getMetaData() should
 * be, however.
 * 
 * @throws Exception
 *             if the test fails
 */
public void testBug17898() throws Exception {
    if (!serverSupportsStoredProcedures()) {
        return;
    }

    createProcedure("testBug17898", "(param1 VARCHAR(50), OUT param2 INT)\nBEGIN\nDECLARE rtn INT;\n" + "SELECT 1 INTO rtn;\nSET param2=rtn;\nEND");

    CallableStatement cstmt = this.conn.prepareCall("{CALL testBug17898('foo', ?)}");
    cstmt.registerOutParameter(1, Types.INTEGER);
    cstmt.execute();
    assertEquals(1, cstmt.getInt(1));

    cstmt.clearParameters();
    cstmt.registerOutParameter("param2", Types.INTEGER);
    cstmt.execute();
    assertEquals(1, cstmt.getInt(1));
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:27,代码来源:CallableStatementRegressionTest.java


注:本文中的java.sql.Types类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。