Zevachim 106

א וַיֹּאמֶר דָּוִיד--זֶה הוּא, בֵּית יְהוָה הָאֱלֹהִים; וְזֶה-מִּזְבֵּחַ לְעֹלָה, לְיִשְׂרָאֵל. 1 Then David said: 'This is the house of the LORD God, and this is the altar of burnt-offering for Israel.'
ב וַיֹּאמֶר דָּוִיד--לִכְנוֹס אֶת-הַגֵּרִים, אֲשֶׁר בְּאֶרֶץ יִשְׂרָאֵל; וַיַּעֲמֵד חֹצְבִים, לַחְצוֹב אַבְנֵי גָזִית, לִבְנוֹת, בֵּית הָאֱלֹהִים.2 And David commanded to gather together the strangers that were in the land of Israel; and he set masons to hew wrought stones to build the house of God.
ג וּבַרְזֶל לָרֹב לַמִּסְמְרִים לְדַלְתוֹת הַשְּׁעָרִים, וְלַמְחַבְּרוֹת--הֵכִין דָּוִיד; וּנְחֹשֶׁת לָרֹב, אֵין מִשְׁקָל.3 And David prepared iron in abundance for the nails for the doors of the gates, and for the couplings; and brass in abundance without weight;
ד וַעֲצֵי אֲרָזִים, לְאֵין מִסְפָּר: כִּי-הֵבִיאוּ הַצִּידֹנִים וְהַצֹּרִים עֲצֵי אֲרָזִים, לָרֹב--לְדָוִיד. 4 and cedar-trees without number; for the Zidonians and they of Tyre brought cedar-trees in abundance to David.
ה וַיֹּאמֶר דָּוִיד, שְׁלֹמֹה בְנִי נַעַר וָרָךְ, וְהַבַּיִת לִבְנוֹת לַיהוָה לְהַגְדִּיל לְמַעְלָה לְשֵׁם וּלְתִפְאֶרֶת לְכָל-הָאֲרָצוֹת, אָכִינָה נָּא לוֹ; וַיָּכֶן דָּוִיד לָרֹב, לִפְנֵי מוֹתוֹ.5 And David said: 'Solomon my son is young and tender, and the house that is to be builded for the LORD must be exceeding magnificent, of fame and of glory throughout all countries; I will therefore make preparation for him.' So David prepared abundantly before his death.
ו וַיִּקְרָא, לִשְׁלֹמֹה בְנוֹ; וַיְצַוֵּהוּ לִבְנוֹת בַּיִת, לַיהוָה אֱלֹהֵי יִשְׂרָאֵל. 6 Then He called for Solomon his son, and charged him to build a house for the LORD, the God of Israel.
ז וַיֹּאמֶר דָּוִיד, לִשְׁלֹמֹה: בנו בְּנִי--אֲנִי הָיָה עִם-לְבָבִי, לִבְנוֹת בַּיִת לְשֵׁם יְהוָה אֱלֹהָי.7 And David said to Solomon: 'My son, as for me, it was in my heart to build a house unto the name of the LORD my God.

for nails, copper, and lumber. David reasoned that Solomon, who would actually build the Temple, was very young. Since the Temple was to be great, David would stockpile materials for it before his death.

David called Solomon and told him how he had requested to build a Temple to G-d but been refused because he had been a warrior. (There are a variety of explanations for why this is. The simplest is that it is because the Temple is meant to be a place of mercy and David's military background went counter to that. One Midrash goes counter to what most people would assume by saying that David's wars were so holy that a Temple built by him could never be destroyed. That sounds like a good thing, except that then G-d would have to take His entire wrath out on the people, rather than on a building.) David continued by telling Solomon how G-d foretold his birth and how he would build the Temple. Solomon's reign would be a time of peace and his dynasty would endure forever. David prayed that G-d grant Solomon the wisdom to rule the nation well and to keep His laws. (We later see exactly how wise G-d made Solomon!)

David showed Solomon all the gold, silver, copper and other materials he had collected to be used in building the Temple. He told Solomon about the masons and craftsmen he would have to engage for the task. David charged his son with this awesome responsibility and he commanded his officers to assist Solomon with it when the time came.