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


Java PreparedStatement.setDouble方法代码示例

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


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

示例1: insertAvanceCosto

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static boolean insertAvanceCosto(AvanceCosto costo, String usuarioResponsable){
	try {
		Connection conn=ConnectionConfiguration.conectar();
	   	
		String query = " insert into avance_costo (monto,codigo_contratacionl,objeto_gasto,avance_id, producto_concat, usuario_responsable)"
	+ " values (?, ?, ?, ?, ?, ?)";
		
		PreparedStatement insert = conn.prepareStatement(query);
		
		
		insert.setDouble (1, costo.getMonto());
		insert.setString (2, costo.getCodigoContratacion());
		insert.setInt (3, costo.getObjetoGasto());
		insert.setInt (4, costo.getAvanceId());
		insert.setString(5, costo.getProductoConcat());
		insert.setString (6, usuarioResponsable);
		
		insert.execute();
		   
		conn.close();
		return true;
	} catch (SQLException e) {e.printStackTrace(); return false;}
	
}
 
开发者ID:stppy,项目名称:tcp,代码行数:25,代码来源:SqlInserts.java

示例2: inserirProduto

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void inserirProduto(Produto produto){
    System.out.println("Iniciando processo de inserção de produto...");
    String query = "insert into produtos (codigoempresa, nome, descricao, codigofornecedor, codigocategoria, precocompra, precovenda, estoque) values (?,?,?,?,?,?,?,?)";
    
    try {
        PreparedStatement preparedStatement = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
        
        preparedStatement.setInt(1, produto.getCodigoempresa());
        preparedStatement.setString(2, produto.getNome());
        preparedStatement.setString(3, produto.getDescricao());
        preparedStatement.setInt(4, produto.getCodigoFornecedor());
        preparedStatement.setInt(5, produto.getCategoria());
        preparedStatement.setDouble(6, produto.getPrecocompra());
        preparedStatement.setDouble(7, produto.getPrecovenda());
        preparedStatement.setInt(8, produto.getEstoque());
        
        preparedStatement.executeUpdate();
        preparedStatement.close();
        System.out.println("Produto inserido com sucesso.");
        
    } catch (SQLException ex) {
        System.out.println(ex);
        System.out.println("Erro ao salvar produto");
    }
}
 
开发者ID:Dinossaura,项目名称:LojaDeInstrumentosMusicais,代码行数:26,代码来源:ProdutoDAO.java

示例3: fillInWhereClause

import java.sql.PreparedStatement; //导入方法依赖的package包/类
/**
 * Fills in the given fields in the queue into the given prepared statement
 * @param ps
 * @param firstField
 * @return
 * @throws SQLException
 */
public int fillInWhereClause(PreparedStatement ps, int firstField) throws SQLException{
	//insert all values in the prepared statement in the order
    //in which the values had been put in the queue
    for (Map.Entry<String, FieldType> entry : searchValues){
        switch(entry.getValue()) {
            case STRING:
                ps.setString(firstField, entry.getKey());
                break;
            case DATE:
                ps.setTimestamp(firstField, new Timestamp(Long.parseLong(entry.getKey())));
                break;
            case LONG:
                ps.setLong(firstField, Long.parseLong(entry.getKey()));
                break;
            case DOUBLE:
                ps.setDouble(firstField, Double.parseDouble(entry.getKey()));
                break;
            case UUID:
                ps.setObject(firstField, UUID.fromString(entry.getKey()));
                break;
            case BOOLEAN:
            	ps.setBoolean(firstField, Boolean.valueOf(entry.getKey()));
            	break;
        }
        firstField++;
    }
    return firstField;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:36,代码来源:QueryParser.java

示例4: insertEstructuraFinanciera

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void insertEstructuraFinanciera(EstructuraFinanciera estructuraFinanciera, String usuarioResponsable){
	try {
		Connection conn=ConnectionConfiguration.conectar();
	   	
		String query = " insert into estructura_financiera (id,estructura,mes,producto,ejecutado,programado,usuario_responsable)"
		+ " values (?, ?, ?, ?, ?, ?, ?)";
		
		PreparedStatement insert = conn.prepareStatement(query);
		
		insert.setInt (1, estructuraFinanciera.getId());
		insert.setInt (2, estructuraFinanciera.getEstructura());
		insert.setInt (3, estructuraFinanciera.getMes());
		insert.setInt (4, estructuraFinanciera.getProducto());
		insert.setDouble (5, estructuraFinanciera.getEjecutado());
		insert.setDouble (6, estructuraFinanciera.getPlanificado());
		insert.setString (7, usuarioResponsable);
							
		insert.execute();
		   
		conn.close();
	} catch (SQLException e) {e.printStackTrace();}
		
}
 
开发者ID:stppy,项目名称:spr,代码行数:24,代码来源:SqlInserts.java

示例5: insertProyectoSnipAutorizado

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void insertProyectoSnipAutorizado(int id, int proyecto_snip_id, int anho, int entidad_nivel_id, int entidad_id, int fuente_financiamiento_id, int	organisimo_financiador_id, Double monto){
 	 Connection conect=conectar();
 String query = " insert into proyecto_snip_autorizado ( id, proyecto_snip_id, anho, entidad_nivel_id, entidad_id, fuente_financiamiento_id, organisimo_financiador_id, monto)"
	        + " values (?,?,?,?,?,?,?,?)";
try {
	
	PreparedStatement preparedStmt;
	preparedStmt = conect.prepareStatement(query);
	preparedStmt.setInt (1, id);
	preparedStmt.setInt (2, proyecto_snip_id);
	preparedStmt.setInt (3, anho);
	preparedStmt.setInt (4, entidad_nivel_id);
	preparedStmt.setInt (5, entidad_id);
	preparedStmt.setInt (6, fuente_financiamiento_id);
	preparedStmt.setInt (7, organisimo_financiador_id);
	preparedStmt.setDouble(8, monto);
    preparedStmt.execute();
    conect.close();
} catch (SQLException e) {e.printStackTrace();}
 }
 
开发者ID:stppy,项目名称:spr,代码行数:21,代码来源:SqlHelper.java

示例6: fillStatement

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
protected PreparedStatement fillStatement(final ObjectModel objectModel, final PreparedStatement statement, final QueryType queryType) throws SQLException {
    final RescueTeam rescueTeam = ((RescueTeam) objectModel);
    switch (queryType) {
        case INSERT:
            statement.setString(1, rescueTeam.getRescueTeamID());
            statement.setString(2, rescueTeam.getPassword());
            statement.setString(3, rescueTeam.getName());
            statement.setDouble(4, rescueTeam.getLatitude());
            statement.setDouble(5, rescueTeam.getLongitude());
            statement.setString(6, rescueTeam.getPhoneNumber());
            break;
        case FIND_ONE:
        case DELETE:
            statement.setString(1, rescueTeam.getRescueTeamID());
            break;
        case UPDATE:
            statement.setString(1, rescueTeam.getPassword());
            statement.setString(2, rescueTeam.getRescueTeamID());
            break;
        default:
            throw new SQLException(QUERY_NOT_FOUND_EXCEPTION);
    }
    return statement;
}
 
开发者ID:SofiaRosetti,项目名称:S3-16-d-rescue,代码行数:26,代码来源:RescueTeamDaoImpl.java

示例7: recordData

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void recordData(Connection conn, TrafficUnit tu, double speed) {
        String sql = "insert into data(vehicle_type, horse_power, weight_pounds, passengers_count, payload_pounds, speed_limit_mph, " +
                "temperature, road_condition, tire_condition, traction, speed) values(?,?,?,?,?,?,?,?,?,?,?)";
/*
        System.out.println("  " + sql + ", params=" + tu.getVehicleType() + ", " + tu.getHorsePower() + ", " + tu.getWeightPounds()
                + ", " + tu.getPassengersCount() + ", " + tu.getPayloadPounds() + ", " + tu.getSpeedLimitMph() + ", " + tu.getTemperature()
                + ", " + tu.getRoadCondition() + ", " + tu.getTireCondition()+ ", " + tu.getTraction() + ", " + speed);
*/
        try {
            int i = 1;
            PreparedStatement st = conn.prepareStatement(sql);
            st.setString(i++, tu.getVehicleType().name());
            st.setInt(i++, tu.getHorsePower());
            st.setInt(i++, tu.getWeightPounds());
            st.setInt(i++, tu.getPassengersCount());
            st.setInt(i++, tu.getPayloadPounds());
            st.setDouble(i++, tu.getSpeedLimitMph());
            st.setInt(i++, tu.getTemperature());
            st.setString(i++, tu.getRoadCondition().name());
            st.setString(i++, tu.getTireCondition().name());
            st.setDouble(i++, tu.getTraction());
            st.setDouble(i++, speed);
            int count = st.executeUpdate();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
 
开发者ID:PacktPublishing,项目名称:Java-9-Cookbook,代码行数:28,代码来源:DbUtil.java

示例8: insertAddress

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void insertAddress(Address address) throws Exception {		
		String sql = address.getType() == Address.ADDRESS_TYPE.TRANSPARENT ? sqlInsertPublicAddress : sqlInsertPrivateAddress;					
		PreparedStatement pstmt = conn.prepareStatement(sql);
		pstmt.setString(1, address.getPrivateKey());
        pstmt.setString(2, address.getAddress());
        pstmt.setDouble(3, Double.parseDouble(address.getBalance()));
        pstmt.setString(4, "");
		pstmt.execute();
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:11,代码来源:ArizenWallet.java

示例9: insertAvance

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static boolean insertAvance(Avance avance, String usuarioResponsable) throws ParseException{
	try {
		Connection conn=ConnectionConfiguration.conectar();
	   	
		String query = " insert into avance (departamento_id, distrito_avance, justificacion,cantidad,fecha_entrega,actividad_id,version, usuario_responsable)"
	+ " values (?, ?, ?, ?, ?, ?, ?, ?)";
		
		PreparedStatement insert = conn.prepareStatement(query);
		
		String inicio = avance.getFechaEntrega();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		java.util.Date date1 = sdf.parse(inicio);
		java.sql.Date sqlStart = new java.sql.Date(date1.getTime());
		
		insert.setInt (1, avance.getDepartamentoId());
		insert.setInt (2, avance.getDistritoAvance());
		insert.setString (3, avance.getJustificacion());
		insert.setDouble(4, avance.getCantidad());
		insert.setDate (5, sqlStart); 
		insert.setInt (6, avance.getActividadId());
		insert.setInt (7, avance.getVersion());
		insert.setString (8, usuarioResponsable);
		
		insert.execute();
		   
		conn.close();
		return true;
	} catch (SQLException e) {e.printStackTrace(); return false;}
	
}
 
开发者ID:stppy,项目名称:tcp,代码行数:31,代码来源:SqlInserts.java

示例10: insertFundamentacion

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void insertFundamentacion(Fundamentacion fundamentacion, String usuarioResponsable){
	try {
		Connection conn=ConnectionConfiguration.conectar();
	   	
		String query = " insert into fundamentacion (id, estructura_id, objeto_gasto, fuente_financiamiento, org_financiador, pais, depto, secuencia, precio, cantidad, cantidad_meses, descripcion, clgCodigo, usuarioResponsable)"
		+ " values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
		
		PreparedStatement insert = conn.prepareStatement(query);
		
		insert.setInt (1, fundamentacion.getId());
		insert.setInt (2, fundamentacion.getEstructura());
		insert.setInt (3, fundamentacion.getObjetoGasto());
		insert.setInt (4, fundamentacion.getFuenteFinanciamiento());
		insert.setInt (5, fundamentacion.getOrganismoFinanciador());
		insert.setInt (6, fundamentacion.getPais());
		insert.setInt (7, fundamentacion.getDepto());
		insert.setInt (8, fundamentacion.getSecuencia());
		insert.setDouble (9, fundamentacion.getPrecio());
		insert.setInt (10, fundamentacion.getCantidad());
		insert.setInt (11, fundamentacion.getCantidad_meses());
		insert.setString (12, fundamentacion.getDescripcion());
		insert.setInt (13, fundamentacion.getClgCodigo());
		insert.setString (14, usuarioResponsable);	
							
		insert.execute();
		   
		conn.close();
	} catch (SQLException e) {e.printStackTrace();}
		
}
 
开发者ID:stppy,项目名称:spr,代码行数:31,代码来源:SqlInserts.java

示例11: update

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public void update(Rota rota) throws Exception {
	PreparedStatement pstm = this.getConnectionFactory().getConnection()
			.prepareStatement(RotaQueries.UPDATE_ROTA.getConsulta());
	pstm.setInt(1, rota.getId());
	pstm.setString(2, rota.getNome());
	pstm.setObject(3, (rota.getOrigem() == null) ? null : rota.getOrigem().getId());
	pstm.setObject(4, (rota.getDestino() == null) ? null : rota.getDestino().getId());
	pstm.setDouble(7, rota.getCustoGrama());
	pstm.setInt(8, rota.getTempoEntrega());
	pstm.setInt(10, rota.getId());
	if (rota instanceof Direta) {
		Direta direta = (Direta) rota;
		pstm.setDouble(5, direta.getCapacidadeTotal());
		pstm.setDouble(6, direta.getCapacidadeAlocada());
		pstm.setString(9, "D");
	} else if (rota instanceof Fracional) {
		pstm.setObject(5, null);
		pstm.setObject(6, null);
		pstm.setString(9, "F");
	}
	try {
		pstm.executeUpdate();
		if (rota instanceof Fracional)
			this.updateTrechos((Fracional) rota);
	} catch (Exception ex) {
		throw new LogisticException("Erro durante a rotina de atualização de rotas.");
	}
}
 
开发者ID:cjlcarvalho,项目名称:LogisticApp,代码行数:30,代码来源:RotaDAOSQL.java

示例12: populateTable

import java.sql.PreparedStatement; //导入方法依赖的package包/类
static void populateTable(Connection con) throws SQLException {

        long      startTime = System.currentTimeMillis();
        Timestamp now       = new Timestamp(startTime);

        con.setAutoCommit(false);

        String            sql  = createInsertSQL(true, false);
        PreparedStatement prep = con.prepareStatement(sql);

        prep.clearParameters();
        prep.setString(1, "xxx");
        prep.setTimestamp(2, now);    // last_update

        for (int ii = 0; ii < DECIMAL_FIELDS_PER_DATASET; ii++) {
            prep.setDouble(ii + 3, 0.123456789);    // Wert
        }

        prep.addBatch();
        prep.setString(1, "yyy");
        prep.setTimestamp(2, now);    // last_update

        for (int ii = 0; ii < DECIMAL_FIELDS_PER_DATASET; ii++) {
            prep.setDouble(ii + 3, 0.123456789);    // Wert
        }

        prep.addBatch();

        int[] updateCounts = prep.executeBatch();

        con.setAutoCommit(true);
        prep.close();
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:34,代码来源:TestBatchBug.java

示例13: insertActividad

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public static void insertActividad(Cronograma actividad, String usuarioResponsable){
	try {
		Connection conn=ConnectionConfiguration.conectar();
	   	
		String query = " insert into actividad (nombre,descripcion,proporcion,peso,version,borrado,accion_id,unidad_medida_id,hito_tipo_id,acumulable, usuario_responsable, prod_concat)"
	+ " values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
		
		PreparedStatement insert = conn.prepareStatement(query);
		
		insert.setString (1, actividad.getNombre());
		insert.setString (2, actividad.getDescripcion());
		insert.setDouble (3, actividad.getProporcion());
		insert.setDouble (4, actividad.getPeso());
		insert.setInt (5, actividad.getVersion());
		insert.setBoolean (6, actividad.isBorrado());
		insert.setInt (7, actividad.getAccion_id());
		insert.setInt (8, actividad.getUnidad_medida_id());
		insert.setInt (9, actividad.getHito_tipo_id());	
		insert.setBoolean(10, actividad.isAcumulable());		
		insert.setString (11, usuarioResponsable);
		insert.setString(12, actividad.getProdConcat());
		
		insert.execute();
		   
		conn.close();
	} catch (SQLException e) {e.printStackTrace();}
	
}
 
开发者ID:stppy,项目名称:tcp,代码行数:29,代码来源:SqlInserts.java

示例14: getBinder

import java.sql.PreparedStatement; //导入方法依赖的package包/类
@Override
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
	return new BasicBinder<X>( javaTypeDescriptor, this ) {
		@Override
		protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
			st.setDouble( index, javaTypeDescriptor.unwrap( value, Double.class, options ) );
		}
	};
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DoubleTypeDescriptor.java

示例15: alterarValor

import java.sql.PreparedStatement; //导入方法依赖的package包/类
public void alterarValor(double valor) throws Exception{
    String query = "UPDATE carrinho SET valortotal= ?";

    try {
        PreparedStatement preparedStatement = conn.prepareStatement(query);
        preparedStatement.setDouble(1, valor);

        preparedStatement.execute();
        System.out.println("Valor Alterado");
    } catch (SQLException ex) {
        throw new Exception("Erro ao deletar o carrinho", ex);
    
    }
}
 
开发者ID:Dinossaura,项目名称:LojaDeInstrumentosMusicais,代码行数:15,代码来源:CarrinhoDAO.java


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