Reading a Properties File for a Java Application using NetBeans IDE - Adding a properties file
(Page 4 of 5 )
In this section, I shall add a "properties" file to our application using the NetBeans IDE. Please go through the following steps to achieve the same:
· Within the "Projects" view, right click on "MyDBPack" and go to New -> File/Folder (Fig03).

· Within the "new file" dialog window, select "Other" in "Categories" and select "Properties File" as "File type" (Fig04).

· Once you click "Next", you will be presented with "New Properties File" dialog.
· Give the filename as "dbconfig" and make sure that it is correctly placed within the "MyDBPack" folder (Fig05).

· Once you click on "finish," your "Projects" view should look something like the following (Fig 06):

· Double click on "dbconfig.properties" to open the file within IDE and copy following lines into the same:
url=jdbc:microsoft:sqlserver://serverjaghome:1433
driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
user=sa
password=
Please be aware that you need to modify the above with your own server name, port, username and password according to your existing SQL Server configuration.
Next: Reading the connection string from the properties file >>
More Java Articles
More By Jagadish Chaterjee