473,394 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Oracle JDBC Connection Problem

Please go through the JAVA code below:
Expand|Select|Wrap|Line Numbers
  1. class Main{
  2. public Connection getConnection(){
  3.         Connection l_con = null;
  4.         try {
  5.             String hostname = "172.10.23.1:1527";    //Host IP:port No
  6.             String dbsid = "TESTSID";            //SID Name or Service Name
  7.             String username = "TESTUSER";    //Database user
  8.             String password = "password";        //User password
  9.             String connectingString = "jdbc:oracle:thin:@" + hostname + ":" + dbsid; 
  10.  
  11.             DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
  12.             l_con = DriverManager.getConnection(connectingString,username,password);
  13.  
  14.         } catch (SQLException ex) {
  15.             Logger.getLogger(SQLUtil.class.getName()).log(Level.SEVERE, null, ex);
  16.         }
  17.         return l_con;
  18.     }
  19.  
  20.  
  21.             public static void main(String s[]){
  22.             Main main= new Main();
  23.            Connection l_con = sqlutil.getConnection();              
  24. }
  25.  
  26. }
  27.  
  28.  
When I run the following code we found some error like that:

<ERROR>
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
172.10.23.1:1527:TESTSID
</ERROR>


Please give me the solution. Thank you.
Feb 23 '09 #1
1 4538
JosAH
11,448 Expert 8TB
@Debabrata Jana
The error message says it all: it can't find the TESTSID service/database. Check the spelling, access rights etc.

kind regards,

Jos
Feb 23 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Paul | last post by:
hi, i'm getting the following error when i try to run the code below to connect to an oracle db: java.lang.ClassnotfoundException:oracle.jdbc.driver.OracleDriver java.sql.SQLException No...
3
by: David | last post by:
Hello all, I have been trying to use the OCI driver to connect to Oracle 9i, but have been getting the following error: java.sql.SQLException: Closed Connection at...
3
by: hilz | last post by:
Hi all: I have an oracle 9i server running behind a firewall. i set up the machine that has the oracle server as a DMZ zone. i can connect to the oracle server from the local network but not...
1
by: CM | last post by:
Hi, when i want connect me in my BD with a JSP (with this simple code), this exception is throw. Thank's for ur help Mathieu CODE of my JSP ---------------------
0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
3
by: owen | last post by:
Hi, I've been trying for ages to connect to my Oracle 9.2.0 database from Java. I am attempting to create a thin connection. The necessary drivers were installed with the database and I have...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
0
by: anuptosh | last post by:
Hi, I have been trying to run the below example to get a Oracle Array as an output from a Java code. This is an example I have found on the web. But, the expected result is that the code should...
0
by: Rauf Sarwar | last post by:
Originally posted by Nelson Broat Have you included Oracle jdbc driver in your classpath? Depending on your Oracle version, it would be ORACLE_HOME/jdbc/lib/classesXXX.zip or classesXXX.jar...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.