Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

I try to connect oracle cloud and eclipse but something wrong

User_RYYKBNov 25 2021

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"

Comments

SubOptimal

The link to Oracle Javamagazine is broken. It point to `oracle.com/java` instead of `oracle.com/javamagazine`.

user619767

No link to source on GitHub or Kenai?

Pradeep Y

Hi Annie,

I have developed source code based on this document using usb4java and it is working fine as a standalone class.

I integrated this code into another application as a signed applet jar along with other supporting files. Here weight from weighing scale is also reading as expected.

My problem is if weight on weighing scale is changed, to update this change it is taking 20-30 sec. So, a user has to wait for some time to get updated weight.

I verified code and found below code is reading same weight in this period.

     received = pipe.syncSubmit(data);

Here data size is 8 bytes and receiving 6 bytes.

When I looped this statement alone for 400 time it is retrieving update weight in 10 sec and also there are performance issues like browser is hanged for almost 10-15 sec and applet is also hanging.

Please suggest me on resolving this issue.

Thanks,

Y Pradeep

Fantazma

Thank You Annie.

User_I95HU

DSCN0010.jpg

1 - 5

Post Details

Added on Nov 25 2021
0 comments
186 views