Adding something to the already good answer by JRE.
You must take into account also power dissipation in your design. The LM317 is a linear regulator IC, this means that it lowers the input voltage by dropping the excess voltage as a "automatic regulating resistor". In other words, by dissipating electrical power as heat.
The exact value of the dissipated power is given by the formula
\$P=(V_{input}-V_{output}) \cdot I_{load} \$.
If your load draws, say, \$500mA\$, your chip is going to dissipate
\$(9V-3V)\times 0.5A=3W\$ of power. This will turn your LM317 very hot if you don't add a suitable heat sink to it.
Assuming an (optimistic) thermal resistance of
\$ 20K/W \$
for a TO220 package, the chip will reach a temperature which is
\$20K/W \times 3W = 60 °C\$
hotter than ambient. Without an heat sink you will probably reach a point where the internal thermal protection of the chip will kick in and stop its operations.
I don't know what you are going to build, i.e. why you need such a circuit to lower that voltage. If you don't need a variable output, probably you'll better off by using one of those very cheap switching buck converter modules you find on Amazon or eBay.
Nowadays there are little reasons to use a linear regulator to lower a voltage from a fixed one if substantial load current is involved.
Principal reasons to use linear regulators instead of switching regulators are:
- you need lower output ripple/noise (linear regulators are quieter);
- the differential input/output voltage is tiny (say a 1-2V max), so you use a LDO (low drop-out) linear regulator;
- the current of the load is tiny and power dissipation is not an issue, so you choose a simpler circuit (no inductors; less critical design);
- you need a precise voltage reference, with very low drift and thermal variation (almost no current is delivered to the load in this case, and specialty linear regulators are built for the purpose).