Forum Stats

  • 3,768,286 Users
  • 2,252,771 Discussions
  • 7,874,515 Comments

Discussions

I try to connect oracle cloud and eclipse but something wrong

I used oraclecloud wallet

public class DbTest {


  public static void main(String[] args) {

    try {

      Class.forName("oracle.jdbc.OracleDriver");

      System.out.println("Driver 등록");

    } catch (ClassNotFoundException e) {

      e.printStackTrace();

    }


    DbTest db = new DbTest();

    int result = db.searchTable();

    System.out.println("조회결과 : "+result);


  }



  public Connection getConnection() {

    Connection conn = null;

    try {

      conn = DriverManager.getConnection("jdbc:oracle:thin:@DB202111242136_high?TNS_ADMIN=C: \\dev\\wallet\\wallet\\Wallet_DB202111242136", "geverytime", "Semiproject1234");

      //

      conn.setAutoCommit(false);

    } catch (Exception e) {

      e.printStackTrace();

    }

    return conn;

  }


  public int searchTable() {

    PreparedStatement pstmt = null;

    Connection conn = getConnection();

    ResultSet rset = null;

    int result = 0;


    try {

      pstmt = conn.prepareStatement("select * from test");

      rset = pstmt.executeQuery();


      while(rset.next()) {

        result = rset.getInt(1);

      }


    } catch (SQLException e) {

      e.printStackTrace();

    } finally {

      try {

        conn.close();

      } catch (SQLException e) {

        e.printStackTrace();

      }

    }


    return result;

  }



}

//this is testcode for connection with oracle cloud

I using window and ojdbc.jar is added on WEB-INF-lib

and showing error like this what is the problem??

IO error : Invalid connection string format, a valid format is: "host:port:sid"