Code example for PreparedStatement

Methods: executeUpdatesetDoublesetIntsetString

0
			 
	} 
	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())
		{ 
				trndtls.add(new TransactionDetail(rs.getString(1),rs.getInt(2),rs.getInt(3),rs.getDouble(4),rs.getString(5)));