Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
try
		{
			Class.forName("oracle.jdbc.driver.OracleDriver");
		}catch(Exception ex)
		{
			System.out.println("Where is your Oracle Driver");
			ex.printStackTrace();
			return;
		}
		
		System.out.println("Oracle JDBC driver registered");
		try
		{
			con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl" , "scott" , "ahsan");
		}catch(Exception ex)
		{
			System.out.println("Your connection is faild Plz check database");
			ex.printStackTrace();
			return;
		}

<pre lang="xml">java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
    at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:414)
    at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:165)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at database.main(database.java:30)</pre>
Posted
Comments
Pandu Rang 4-Feb-15 7:32am    
Are you able to connect to oracle DB using sql plus by giving these credentials?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900