當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。