PreparedStatement setDouble - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PreparedStatement setDouble method.

This code example shows how to use the following methods:executeUpdate, setDouble
      // test if the record exists already. 
      if (!rs.first()) {
        stmt2 = conn.prepareStatement(setPreferenceSQL);
        setLongParameter(stmt2, 1, userID);
        setLongParameter(stmt2, 2, itemID);
        stmt2.setDouble(3, value);
 
        log.debug("Executing SQL update: {}", setPreferenceSQL);
        stmt2.executeUpdate();
      } 
    } catch (SQLException sqle) {
      log.warn("Exception while setting preference", sqle);
      throw new TasteException(sqle);
    } finally { 
      IOUtils.quietClose(rs);
      IOUtils.quietClose(stmt1);
      IOUtils.quietClose(stmt2);
      IOUtils.quietClose(conn);
    } 
  } 

7
CodeRank
This code example shows how to use the following methods:setBoolean, setDate, setDouble, setFloat, setInt
	public static void insertJdbcTypeParameter( 
			PreparedStatement preparedStatement, int index, Object value)
			throws SQLException { 
		Class classType = value.getClass();
		if (classType.equals(int.class) || classType.equals(Integer.class))
			preparedStatement.setInt(index, (Integer) value);
		if (classType.equals(short.class) || classType.equals(Short.class))
			preparedStatement.setShort(index, (Short) value);
		else if (classType.equals(long.class) || classType.equals(Long.class))
			preparedStatement.setLong(index, (Long) value);
		else if (classType.equals(float.class) || classType.equals(Float.class))
			preparedStatement.setFloat(index, (Float) value);
		else if (classType.equals(double.class)
				|| classType.equals(Double.class))
			preparedStatement.setDouble(index, (Double) value);
		else if (classType.equals(String.class))
			preparedStatement.setString(index, (String) value);
		else if (classType.equals(Date.class))
			preparedStatement.setDate(index, new java.sql.Date(((Date) value)
					.getTime()));

7
CodeRank
This code example shows how to use the following methods:executeUpdate, setDouble, setLong
 
			ps = con.prepareStatement(
				"update RatingsEntry set score = ? where score = ? and " + 
					"classNameId = ?"); 
 
			ps.setDouble(1, 0);
			ps.setDouble(2, -1);
			ps.setLong(3, classNameId);
 
			ps.executeUpdate();
		} 
		finally { 
			DataAccess.cleanUp(con, ps);
		} 
	} 
 
	protected void upgradeRatingsStats() throws Exception {
		Connection con = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
7
CodeRank
This code example shows how to use the following methods:execute, setDouble, setString
		try { 
			Class.forName ("com.mysql.jdbc.Driver").newInstance ();
			conn = DriverManager.getConnection(url, username, password);	
			 
			PreparedStatement addStmt = conn.prepareStatement(insertquery, Statement.RETURN_GENERATED_KEYS);
			addStmt.setString(1, test.getName());
			addStmt.setDouble(2, test.getNormalValueMin());
			addStmt.setDouble(3, test.getNormalValueMax());
			addStmt.setString(4, test.getNotes());
			 
			result = addStmt.execute();
			 
			addStmt.close();
		} catch (Exception e) {
			e.printStackTrace();
		} 
		 
		return result;
	} 
 
6
CodeRank
This code example shows how to use the following methods:setDouble, setNull
            throws HibernateException, SQLException {
 
        BoundingBox box = (BoundingBox) value;
        if (box == null) {
            //set to null 
            st.setDouble(index, 1);
            st.setDouble(index + 1, 1);
            st.setDouble(index + 2, -1);
            st.setDouble(index + 3, -1);
            st.setNull(index + 4, Types.VARCHAR);
            //st.setBlob(index + 4, (Blob) null); 
            return; 
        } 
 
        //TODO: check for isNull() and set the minx,maxx accordingly 
        st.setDouble(index, box.getMinX());
        st.setDouble(index + 1, box.getMinY());
        st.setDouble(index + 2, box.getMaxX());
        st.setDouble(index + 3, box.getMaxY());
 

6
CodeRank
This code example shows how to use the following methods:executeUpdate, setDouble, setInt, setString
			 
	} 
	public void addTransactionDetail(TransactionDetail trndtl) throws SQLException
	{ 
			pst=conn.prepareStatement("insert into transactiondetail values(?,?,?,?,?)");
			pst.setString(1, trndtl.getUsername());
			pst.setInt(2,trndtl.getFromacct());
			pst.setInt(3,trndtl.getToacct());
			pst.setDouble(4, trndtl.getTransamount());
			pst.setString(5, trndtl.getShwdate());
			pst.executeUpdate();
	} 
	public List<TransactionDetail> getTrndtlfromaccno(int accno) throws SQLException
	{ 
		List<TransactionDetail> trndtls=new ArrayList<TransactionDetail>();
		pst=conn.prepareStatement("select * from transactiondetail where fromacct=?");
		pst.setInt(1, accno);
		rs=pst.executeQuery();
		while(rs.next())
		{ 
6
CodeRank
This code example shows how to use the following methods:setDouble, setNull
            throws HibernateException, SQLException {
 
        BoundingBox box = (BoundingBox) value;
        if (box == null) {
            //set to null 
            st.setDouble(index, 1);
            st.setDouble(index + 1, 1);
            st.setDouble(index + 2, -1);
            st.setDouble(index + 3, -1);
            st.setNull(index + 4, Types.VARCHAR);
            //st.setBlob(index + 4, (Blob) null); 
            return; 
        } 
 
        //TODO: check for isNull() and set the minx,maxx accordingly 
        st.setDouble(index, box.getMinX());
        st.setDouble(index + 1, box.getMinY());
        st.setDouble(index + 2, box.getMaxX());
        st.setDouble(index + 3, box.getMaxY());
 

6
CodeRank
This code example shows how to use the following methods:setDouble, setInt, setTimestamp
						try { 
							PreparedStatement	ps =conn.prepareStatement(
									"Insert into CON35.buyentrust " + "values(?,?,?,?,?,?,?)"); 
						//PreparedStatement	ps2 = conn.prepareStatement("Insert into CON35.ACCOUNT (ACCNAME,ACCNICHENG,ACCPSW,ACCEMAIL,ACCPHONE,ACCID)" + "values(?,?,?,?,?,?)" ); 
					 
											ps.setInt(1, buyentid);	
							ps.setInt(2, buyencon);
							ps.setInt(3, buystoid);
							ps.setDouble(4, buybpri);
							ps.setInt(5, buybnum);
							ps.setTimestamp(6, buyenttime);
							ps.setInt(7, 0);
	                       ps.executeUpdate(); 
							//rs.beforeFirst();  
				 
						} catch (SQLException e) {
							// TODO ×Ô¶¯Éú³É catch ¿é 
							e.printStackTrace();
						} 
		 
6
CodeRank
This code example shows how to use the following methods:executeUpdate, setDate, setDouble, setInt, setLong
 
	@Override 
	public Object executeDatabaseOperation(Connection conn) throws SQLException {
 
		PreparedStatement sta = conn.prepareStatement("INSERT INTO TRANSACTION (PARTICIPANTTOURID, PAYMENT, DATE, TYPEID, NUMBER, CURRENCYTYPEID) VALUES (?, ?, ?, ?, ?, ?)");
		sta.setLong(1, transaction.getParticipantTourId());
		sta.setDouble(2, transaction.getPayment());
		sta.setDate(3, transaction.getDate());
		sta.setInt(4, transaction.getTypeId());
		sta.setString(5, transaction.getNumber());
		sta.setInt(6, transaction.getCurrencyTypeId());
		int rows_updated = sta.executeUpdate();
		sta.close();
		 
		return new Integer(rows_updated);
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:execute, setDouble, setString
    	 
    	try {    		 
    		 
    		con = ConnectionFactory.getConnection();
    		ps = con.prepareStatement(sql);   		
    		ps.setDouble(0, local.getLatitude());
    		ps.setDouble(1, local.getLongitude());
    		ps.setString(2, local.getResource());
    		ps.execute();
    		 
    	} finally { 
    		DbUtil.close(ps);
    		DbUtil.close(con);
    	}     
    }	 
} 
6
CodeRank
setDouble Method Overview
Sets the designated parameter to the given Java double value.
See Code Examples for other Java 8 PreparedStatement Methods: