0

Below is my code which I am trying to connect.

public Connection Connect() throws SQLException{
        try
          {
              DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
              OracleDataSource ods = new OracleDataSource();
              ods.setURL("jdbc:oracle:thin:TSOFT1/TSOFT1@10.184.132.130:1521/FCUTILS");
              con = ods.getConnection();
              return con;
          }catch(Exception ex){
            ex.printStackTrace();
            con.close();
            return null;
          }
   }

I tried to search an answer for this but nothing worked.

RajaRam
  • 13
  • 1
  • 3
  • Try doing a ping and tnsping to the IP address. – Jacob Mar 14 '17 at 04:53
  • Hi @user75ponic when I am doing ping its showing as connected when I am doing tns ping its showing error message as TNS-12541: TNS:no listener. – RajaRam Mar 14 '17 at 05:25
  • 1
    If it is showing `TNS:no listener`, then you need to start the listener. Google to find how to start the listener or inform the DBA. – Jacob Mar 14 '17 at 09:22

1 Answers1

0

I would suggest take this actions:

1.- Make sure your Etherneth cable is pugled on 2.- Try to ping the ip: 10.184.132.130 3.- Is The Data Base Server on? 4.- Change your OrcleDataSource to this:

 OracleDataSource dataSource = new OracleDataSource();
 dataSource.setDriverType(DRIVER_TYPE);
 dataSource.setServerName(SERVER_NAME);
 dataSource.setPortNumber(PORT_NUMBER);
 dataSource.setDatabaseName(DATABASE_NAME);
dataSource.setUser(userName);
dataSource.setPassword(PASSWORD);

This line you wrote:

ods.setURL("jdbc:oracle:thin:TSOFT1/TSOFT1@10.184.132.130:1521/FCUTILS");

Doesn't seems good I think your user name and password are TSOFT1, but don't you have to write it like this?

jdbc:oracle:thin:TSOFT1:TSOFT1@10.184.132.130:1521/FCUTILS"

Hope it can help you.

Here are some examples taht may help you.

http://www.programcreek.com/java-api-examples/index.php?api=oracle.jdbc.pool.OracleDataSource

Yussef
  • 610
  • 6
  • 11
  • Hi @Yussef I tried using this url dbc:oracle:thin:TSOFT1:TSOFT1@10.184.132.130:1521/FCUTILS". Its showing the error as Invalid URL specified – RajaRam Mar 14 '17 at 05:34
  • my bad i forgot to put a j at the first place it should be like this: jdbc:oracle:thin:TSOFT1:TSOFT1@10.184.132.130:1521/FCUTILS and if it doesn't work it could be like jdbc:oracle:thin:TSOFT1:TSOFT1@//10.184.132.130:1521/FCUTILS can you try please? – Yussef Mar 14 '17 at 23:36