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


Java ResultSet.getBigDecimal方法代码示例

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


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

示例1: getOutNum

import java.sql.ResultSet; //导入方法依赖的package包/类
public BigDecimal getOutNum()
{
	Connection connection;
	try {
		connection = JDBCTools.getConnection();
		String sql = "select sum(Salary) from Salesman where OnDuty = 1";
		PreparedStatement pstmt = connection.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
		rs.next();
		BigDecimal a = rs.getBigDecimal(1);
		JDBCTools.releaseConnection(connection, pstmt, rs);
		return a;
	} catch (SQLException e) {
		return new BigDecimal(0);
	}
}
 
开发者ID:yanhanwen,项目名称:DrugStoreManagement,代码行数:17,代码来源:SalesmanDao.java

示例2: initialize

import java.sql.ResultSet; //导入方法依赖的package包/类
public IntegralDataTypeHolder initialize(ResultSet resultSet, long defaultValue) throws SQLException {
	final BigDecimal rsValue = resultSet.getBigDecimal( 1 );
	if ( resultSet.wasNull() ) {
		return initialize( defaultValue );
	}
	this.value = rsValue.setScale( 0, BigDecimal.ROUND_UNNECESSARY );
	return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:IdentifierGeneratorHelper.java

示例3: getValuesInRange

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public Set<SensorValue<BigDecimal>> getValuesInRange(Date start, Date end) {
    NavigableSet<SensorValue<BigDecimal>> ret = new TreeSet<>();

    try (Connection conn = dbMan.getConnection()) {
        try (PreparedStatement stmt = conn.prepareStatement(SELECT_RANGE)) {
            stmt.setLong(1, dbId);
            stmt.setTimestamp(2, new Timestamp(start.getTime()));
            long endTime = end == null ? System.currentTimeMillis() : end.getTime();
            stmt.setTimestamp(3, new Timestamp(endTime));
            ResultSet rs = stmt.executeQuery();
            while (rs.next()) {
                SensorValue<BigDecimal> val = new SensorValue<>(rs.getTimestamp("CREATED"), rs.getBigDecimal("TEMPERATURE"));
                ret.add(val);
            }
        }
    } catch (SQLException ex) {
        LOG.error("Error querying temp values", ex);
    }
    return ret;
}
 
开发者ID:dainesch,项目名称:HueSense,代码行数:22,代码来源:TempSensor.java

示例4: getOutNum

import java.sql.ResultSet; //导入方法依赖的package包/类
public BigDecimal getOutNum()
{
	Connection connection;
	try {
		connection = JDBCTools.getConnection();
		String sql = "select sum(Salary) from Manager where OnDuty = 1";
		PreparedStatement pstmt = connection.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
		rs.next();
		BigDecimal a = rs.getBigDecimal(1);
		JDBCTools.releaseConnection(connection, pstmt, rs);
		return a;
	} catch (SQLException e) {
		return new BigDecimal(-1);
	}
}
 
开发者ID:yanhanwen,项目名称:DrugStoreManagement,代码行数:17,代码来源:ManagerDao.java

示例5: columnToValue

import java.sql.ResultSet; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private Comparable columnToValue(ResultSet resultSet, int columnIndex, int columnType) throws SQLException {
  if (columnTypeIsString(columnType)) {
    return resultSet.getString(columnIndex);
  } else if (columnTypeIsNumeric(columnType)) {
    BigDecimal bigDecimal = resultSet.getBigDecimal(columnIndex);
    return bigDecimal == null ? null : bigDecimal.stripTrailingZeros();
  } else if (columnTypeIsBoolean(columnType)) {
    return resultSet.getBoolean(columnIndex);
  } else if (columnTypeIsDate(columnType)) {
    return resultSet.getDate(columnIndex);
  } else {
    throw new IllegalArgumentException("Column type " + columnType + " not supported for comparison");
  }
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:16,代码来源:ResultSetComparer.java

示例6: transfer

import java.sql.ResultSet; //导入方法依赖的package包/类
public boolean transfer(int nColumnNumber1Based, ResultSet resultSetSource, PreparedStatement insertStatementInsert)
{
	try
	{			
		BigDecimal value = resultSetSource.getBigDecimal(m_nColSourceIndex);
		if (!resultSetSource.wasNull())
			insertStatementInsert.setBigDecimal(m_nColSourceIndex, value);
		else
			insertStatementInsert.setNull(m_nColSourceIndex, Types.DECIMAL);			
		return true;
	}
	catch (SQLException e)
	{
		e.printStackTrace();
	}
	return false;		
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:18,代码来源:RecordColTypeManagerDecimal.java

示例7: fillColValue

import java.sql.ResultSet; //导入方法依赖的package包/类
boolean fillColValue(ResultSet rs, VarBase varInto)
{
	try
	{		
		BigDecimal bdValue = rs.getBigDecimal(m_nColSourceIndex);
		if(bdValue != null)
		{
			varInto.m_varDef.write(varInto.m_bufferPos, bdValue);
			return false;
		}
	}
	catch (SQLException e)
	{
		LogSQLException.log(e);
		// Maybe should I set m_bNull = true; ?
	}
	varInto.m_varDef.write(varInto.m_bufferPos, 0);
	return true;
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:20,代码来源:RecordColTypeManagerDecimal.java

示例8: testBigDecimalPrecision

import java.sql.ResultSet; //导入方法依赖的package包/类
@Test public void testBigDecimalPrecision() throws Exception {
  final String tableName = "decimalPrecision";
  // DECIMAL(25,5), 20 before, 5 after
  BigDecimal decimal = new BigDecimal("12345123451234512345.09876");
  try (Connection conn = getLocalConnection();
      Statement stmt = conn.createStatement()) {
    assertFalse(stmt.execute("DROP TABLE IF EXISTS " + tableName));
    assertFalse(stmt.execute("CREATE TABLE " + tableName + " (col1 DECIMAL(25,5))"));

    // Insert a single decimal
    try (PreparedStatement pstmt = conn.prepareStatement("INSERT INTO " + tableName
        + " values (?)")) {
      pstmt.setBigDecimal(1, decimal);
      assertEquals(1, pstmt.executeUpdate());
    }

    ResultSet results = stmt.executeQuery("SELECT * FROM " + tableName);
    assertNotNull(results);
    assertTrue(results.next());
    BigDecimal actualDecimal = results.getBigDecimal(1);
    assertEquals(decimal, actualDecimal);
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:24,代码来源:RemoteDriverTest.java

示例9: getOutNum

import java.sql.ResultSet; //导入方法依赖的package包/类
public BigDecimal getOutNum()
{
	Connection connection;
	try {
		connection = JDBCTools.getConnection();
		String sql = "select sum(MonthlyCost) from Store";
		PreparedStatement pstmt = connection.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
		rs.next();
		BigDecimal a = rs.getBigDecimal(1);
		JDBCTools.releaseConnection(connection, pstmt, rs);
		return a;
	} catch (SQLException e) {
		return new BigDecimal(0);
	}
}
 
开发者ID:yanhanwen,项目名称:DrugStoreManagement,代码行数:17,代码来源:StoreDao.java

示例10: getOutNum

import java.sql.ResultSet; //导入方法依赖的package包/类
public BigDecimal getOutNum()
{
	Connection connection;
	try {
		connection = JDBCTools.getConnection();
		String sql = "select sum(Salary) from WarehouseManager where OnDuty = 1";
		PreparedStatement pstmt = connection.prepareStatement(sql);
		ResultSet rs = pstmt.executeQuery();
		rs.next();
		BigDecimal a = rs.getBigDecimal(1);
		JDBCTools.releaseConnection(connection, pstmt, rs);
		return a;
	} catch (SQLException e) {
		return new BigDecimal(0);
	}
}
 
开发者ID:yanhanwen,项目名称:DrugStoreManagement,代码行数:17,代码来源:WarehouseManagerDao.java

示例11: getByteValue

import java.sql.ResultSet; //导入方法依赖的package包/类
public byte[] getByteValue(ResultSet resultSet, int nCol1Based, boolean bEbcdicOutput)
{
	try
	{
		ResultSetMetaData rsMetaData = resultSet.getMetaData();

		int nNbDigits = rsMetaData.getPrecision(nCol1Based);
		int nNbDecimals = rsMetaData.getScale(nCol1Based);
		Asserter.assertIfFalse(nNbDigits == m_nNbDigits);
		Asserter.assertIfFalse(nNbDecimals == m_nNbDecimals);

		if((nNbDigits % 2) == 0)
			nNbDigits++;
		int nNbCharsInComp3 = (nNbDigits / 2) + 1;
		
		BigDecimal bd = resultSet.getBigDecimal(nCol1Based);
		DecBase decValue = DecBase.toDec(bd);
		
		byte [] aBytes = new byte[nNbCharsInComp3];
		
		boolean bPositive = !decValue.isNegative();
		String cs = Comp3Support.encodeDecComp3(decValue, m_nNbDigits-m_nNbDecimals, m_nNbDecimals);
		Comp3Support.internalWriteEncodeComp3(aBytes, cs, bPositive, true);
					
		//m_nPhysicalPosInRecordSet += nNbCharsInComp3;
		return aBytes;					
	}
	catch (SQLException e)
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:35,代码来源:DbColDefinitionDecimal.java

示例12: getNullableResult

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public BigInteger getNullableResult(ResultSet rs, String columnName) throws SQLException {
	BigDecimal bigDecimal = rs.getBigDecimal(columnName);
	return bigDecimal == null ? null : bigDecimal.toBigInteger();
}
 
开发者ID:xsonorg,项目名称:tangyuan2,代码行数:6,代码来源:BigIntegerTypeHandler.java

示例13: getOrderDataFromResultSet

import java.sql.ResultSet; //导入方法依赖的package包/类
private OrderDataBean getOrderDataFromResultSet(ResultSet rs)
		throws Exception {
	OrderDataBean orderData = null;

	orderData = new OrderDataBean(new Integer(rs.getInt("orderID")), rs
			.getString("orderType"), rs.getString("orderStatus"), rs
			.getTimestamp("openDate"), rs.getTimestamp("completionDate"),
			rs.getDouble("quantity"), rs.getBigDecimal("price"), rs
					.getBigDecimal("orderFee"), rs
					.getString("quote_symbol"));
	return orderData;
}
 
开发者ID:WASdev,项目名称:sample.daytrader3,代码行数:13,代码来源:TradeDirect.java

示例14: getResult

import java.sql.ResultSet; //导入方法依赖的package包/类
public Object getResult(ResultSet rs, String columnName) throws SQLException {

            Object bigdec = rs.getBigDecimal(columnName);
            if (rs.wasNull()) {
                return null;
            }
            else {
                return bigdec;
            }
        }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:11,代码来源:DAOFactory.java

示例15: getQuoteDataFromResultSet

import java.sql.ResultSet; //导入方法依赖的package包/类
private QuoteDataBean getQuoteDataFromResultSet(ResultSet rs)
		throws Exception {
	QuoteDataBean quoteData = null;

	quoteData = new QuoteDataBean(rs.getString("symbol"), rs
			.getString("companyName"), rs.getDouble("volume"), rs
			.getBigDecimal("price"), rs.getBigDecimal("open1"), rs
			.getBigDecimal("low"), rs.getBigDecimal("high"), rs
			.getDouble("change1"));
	return quoteData;
}
 
开发者ID:WASdev,项目名称:sample.daytrader3,代码行数:12,代码来源:TradeDirect.java


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