Connect to a database and read from table

This example shows how to connect to a database, in this case a MS SQL Server database and read rows from a table.
It is assumed that the table has 3 columns and they all contain string-values (datatype char, varchar etc.).
To connect to another database type, just change the driver and url to match the specific type.

Note that you’ll have to change some of the values to match your own environment (database, table, userid and password),
and to make it work you will have to download the jdbc driver from Microsoft and put it in your classpath.

Search for more Java info on this site here:
Custom Search

Please type any questions here.