本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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");
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}