Hello Ashwin,
Is this a local database? If not can you please try entering the DB URL instead of localhost in the connection parms, or the IP address of the database
TEST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IP of the database>)(PORT = 1599))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = Test)
)
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@<IP/URL of database>:1599:TEST",USERNAME,PASSWORD);