[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

java.sql exception error: connection refused.

Posted on 1998-11-23
3
Medium Priority
?
550 Views
Last Modified: 2010-08-05
Hi
I'm trying to develop a JDBC application for the 1st time.
I have an oracle server running on another machine and when
I run the following code, I get a "No suitable driver" sql exception error. Does this mean a proper JDBC driver is NOT
installed? what is wrong?
-------
String url = "jdbc:oracle:thin:@skmst1:1525:MODC";
        Connection con;
        String createString;
Statement stmt;

        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
        } catch(java.lang.ClassNotFoundException e) {
            System.err.print("ClassNotFoundException: ");
            System.out.println("ClassNotFoundException: ");
            System.err.println(e.getMessage());
        }
try {
            con = DriverManager.getConnection(url,"intcuser", "intcmilp");
} catch(SQLException ex) {
            System.err.println("SQLException: " + ex.getMessage());

}
-----

Thanks

JJ
0
Comment
Question by:jinjool
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 1228119
this code
>>  try {
>>            Class.forName("oracle.jdbc.driver.OracleDriver");
>>     } catch(java.lang.ClassNotFoundException e) {

should load the appropriate JDBC driver. since you don't receive exceptions, the driver should have been properly installed ...

this line
>>   String url = "jdbc:oracle:thin:@skmst1:1525:MODC";
is the URL you're going to connect to
and this line
>>   con = DriverManager.getConnection(url,"intcuser", "intcmilp");
ask DriverManager to find suitable driver for this url and give you a connection.
DriverManager looks at the url and choses the appripriate driver, so if you have installed the driver and DriverManager can't find it, most probably this is misspelled URL. so, check the url string (and maybe take a look at oracle documentation / examples)

hope this helps
  heyhey
0
 
LVL 1

Accepted Solution

by:
GregL earned 120 total points
ID: 1228120
The connection refused usually means that the connect string is wrong.  It should be:
jdbc:oracle:thin:@<server name>:port:sid
I made the mistake of using the tnsnames entry instead of the sid and got the same error.

GregL
0
 

Author Comment

by:jinjool
ID: 1228121
NO,..I'm positive I have the right SID name.
I think it's because the driver was not installed properly
since after upgrading (reinstalling) oracle, it now seems to
work. Thanks for your input though - GregL and heyhey.. :)



0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question