Oracle Java存储的过程可通过JDBC访问Postgres和SQL Server
我正在开发以下Java类,该类与Oracle,PostgreSQL和SQL Server建立连接。
Here's the source:
import java.sql.*;
public class test {
public static void main (String[] args) {
try {
Connection connORA = DriverManager.getConnection("jdbc:oracle:thin:@myoracleserver:1521/myschema", "user", "password");
if (connORA != null) {
System.out.println("Connected to ORACLE");
}
Connection connPGS = DriverManager.getConnection("jdbc:postgresql://IP.of.my.server:5432/mydbname","user","password");
if (connPGS != null) {
System.out.println("Connected to POSTGRES");
}
Connection connSQS = DriverManager.getConnection("jdbc:sqlserver://IP.of.my.server;databaseName=mydbname" ,"user" ,"password");
if (connSQS != null) {
System.out.println("Connected to SQLSERVER");
}
}
catch (SQLException e) {
System.err.println(e.getMessage());
}
}
}
I successfully compile the class with (In $ORACLE_HOME/jdbc/lib/ I have added postgresql-42.3.3.jar and sqljdbc4-2.0.jar)
javac -cp :$ORACLE_HOME/jdbc/lib/* test.java
:
java -cp :$ORACLE_HOME/jdbc/lib/* test
Connected to ORACLE
Connected to POSTGRES
Connected to SQLSERVER
现在,我想知道是否可以将类加载到Oracle DB中以通过存储的过程调用Java,因此我想知道是否可以将类加载为JDBC:default:Connection:Connection:Connection:Connection :
做以下操作:
loadjava -user myoracleuser/muoraclepassword@myoracleschema $ORACLE_HOME/jdbc/lib/postgresql-42.3.3.jar
loadjava -user myoracleuser/muoraclepassword@myoracleschema $ORACLE_HOME/jdbc/lib/sqljdbc4-2.0.jar
loadjava -user myoracleuser/muoraclepassword@myoracleschema test.java
存储过程的执行返回以下消息:
Connected to ORACLE
No suitable driver found for jdbc:postgresql://IP.of.my.server:5432/mydbname
我已经开发了一些我通过Oracle商店过程正确加载和执行程序的类尝试不允许的东西。任何指向我正确道路上的建议都将受到赞赏
I am developing the below java class that makes connections to Oracle, PostgreSQL and SQL Server.
Here's the source:
import java.sql.*;
public class test {
public static void main (String[] args) {
try {
Connection connORA = DriverManager.getConnection("jdbc:oracle:thin:@myoracleserver:1521/myschema", "user", "password");
if (connORA != null) {
System.out.println("Connected to ORACLE");
}
Connection connPGS = DriverManager.getConnection("jdbc:postgresql://IP.of.my.server:5432/mydbname","user","password");
if (connPGS != null) {
System.out.println("Connected to POSTGRES");
}
Connection connSQS = DriverManager.getConnection("jdbc:sqlserver://IP.of.my.server;databaseName=mydbname" ,"user" ,"password");
if (connSQS != null) {
System.out.println("Connected to SQLSERVER");
}
}
catch (SQLException e) {
System.err.println(e.getMessage());
}
}
}
I successfully compile the class with (In $ORACLE_HOME/jdbc/lib/ I have added postgresql-42.3.3.jar and sqljdbc4-2.0.jar)
javac -cp :$ORACLE_HOME/jdbc/lib/* test.java
The execution of the class end with the expected output
java -cp :$ORACLE_HOME/jdbc/lib/* test
Connected to ORACLE
Connected to POSTGRES
Connected to SQLSERVER
Now I am wondering if it is possible to load the class in Oracle DB in order to call the Java via stored procedure so I change the Oracle connection string in jdbc:default:connection:
and do as follows:
loadjava -user myoracleuser/muoraclepassword@myoracleschema $ORACLE_HOME/jdbc/lib/postgresql-42.3.3.jar
loadjava -user myoracleuser/muoraclepassword@myoracleschema $ORACLE_HOME/jdbc/lib/sqljdbc4-2.0.jar
loadjava -user myoracleuser/muoraclepassword@myoracleschema test.java
The execution of the stored procedure returns these messages:
Connected to ORACLE
No suitable driver found for jdbc:postgresql://IP.of.my.server:5432/mydbname
I already develop some class that I correctly load and exec via Oracle store procedure but I am quite new with Java and probably I am missing something obvious or trying something not allowed. Any suggestion that point me in the right path will be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论