我正在尝试连接到oracle apex数据库。我的类路径中有ojdbc.jar。这是我的示例代码。
public class ConnectionDAO {
String database = "demo";
String user = "myusername";
String password = "somepwd";
String host = "https://apex.oracle.com/"; // By default
String port ="8086";
private Connection con;
public Connection connect() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con = DriverManager.getConnection("jdbc:oracle:thin:@//" + host + ":" + port +"/"+database+"?user="+user+"&password="+password);
//con = DriverManager.getConnection("jdbc:oracle://" + host + "/"
// + database + "?user=" + user + "&password=" + password);
// Set connectionStatus
System.out.println("Connected");
return con;
} catch (Exception E) {
System.out.println("Not Connected");
E.printStackTrace();
return null;
}
}
}
但是它给出了以下例外
java.sql.SQLException: invalid arguments in call
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:208)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:236)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T4CConnection.<init>(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(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:233)
at com.lister.dao.ConnectionDAO.connect(ConnectionDAO.java:19)
at com.lister.quiz.Test.main(Test.java:8)
我是oracle apex的新手。我浏览了一下,但没有得到满意的解决方案。任何帮助将不胜感激。
您是否找到了如何连接到在线顶点工作空间?
顶点应用程序存储在数据库中。您需要获取引用数据库的主机和端口以建立jdbc连接。通常默认的数据库端口是1521。