how to catch "java.net.ConnectException: Connection refused: connect"

can someone help me how to try and catch this exception...
[65 byte] By [ryshi1264a] at [2007-11-27 6:17:57]
# 1

try

{

// Your code goes here

}

catch(java.net.ConnectException e)

{

System.out.print(e);

}

Jamwaa at 2007-7-12 17:31:26 > top of Java-index,Java Essentials,Java Programming...
# 2
thanks dude but what if that's not the only exception that I want to block ....say I also want to catch SQL exceptions
ryshi1264a at 2007-7-12 17:31:26 > top of Java-index,Java Essentials,Java Programming...
# 3

try {

// Your code goes here

} catch(java.net.ConnectException e) {

e.printStackTrace();

} catch(java.sql.SQLException e) {

e.printStackTrace();

}

Read up on exception handling before you go forward, dude.

-Kayaman-a at 2007-7-12 17:31:26 > top of Java-index,Java Essentials,Java Programming...
# 4

try

{

// Your code goes here

}

catch(java.net.ConnectException e)

{

System.out.print(e);

}

catch(another e)

{

System.out.print(e);

}

catch(yetAnother e)

{

System.out.print(e);

}

catch(stillAnother e)

{

System.out.print(e);

}

// And in general

catch(Exception e)

{

System.out.print(e);

}

Jamwaa at 2007-7-12 17:31:26 > top of Java-index,Java Essentials,Java Programming...
# 5
Read this for more info: http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html
Jamwaa at 2007-7-12 17:31:26 > top of Java-index,Java Essentials,Java Programming...
# 6
thanks..im learning a lot from you guys..I just started programming about 2 months ago though I don't have any programming background I was able to finish my project with the help of this forum.hope to hear from all of you again.
ryshi1264a at 2007-7-12 17:31:26 > top of Java-index,Java Essentials,Java Programming...