Skip to Main Content

SQL & PL/SQL

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!

PL/SQL - calling java class in OracleDB and establish connection to that DB

Rado_mirJun 3 2013 — edited Jun 3 2013
Hello Oracle Users. I have a question. I`m trying to deploy java class into Oracle db. These class functionality is to establish connect to the same Oracle db. I know that is wrong but i really need to do that. Is that possible?? Maybe i will show some example and what i have done.

Java Class

public class test {

public static String say(String arg)
{
Connection connection = null;
try {

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

} catch (ClassNotFoundException e) {

System.out.println("error with driver");
e.printStackTrace();

}

try {

connection = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:OracleDB", "system",
"adminroot");
Statement stmt = connection.createStatement();
ResultSet rset = stmt.executeQuery("Create table test(a number)");

} catch (SQLException e) {

System.out.println("connection error");
e.printStackTrace();


}
return arg;

}
}
That test class i have compiled, tested and deployed on my Oracle DB with loadjava command.

Then i wrote a PL/SQL function to call java test class.

create or replace function trythis
(id VARCHAR2)
return VARCHAR2
as language java
name 'project1.test.say(java.lang.String)
return java.lang.String';

Then i get some GRANT errors ( i have handle with this )

When i`m trying to call --> Select trythis('test') from dual; function is returning text but i can`t find new table test. Could someone help me with that?? I was thinking problem is with ojdbc drivers and i have used loadjava to deploy that drivers into oracle but that won`t help.

Best regards
Radomir

PS. Sorry for my English.

Comments

karianna

I've pinged Geertjan who's the Netbeans product lead, hopefully he'll jump on here an answer your Q soon.

karianna

Geertjan has said to email him directly: geertjan DOT wielenga AT oracle DOT com

user4931850

Thank you, I have emailed Geertjan

Geertjan-Oracle

Thanks. Trying to find out where that NBM file is, sent you a mail in response. It is conceivable that NetBeans IDE 8.1 doesn't support that version anymore.

user4931850

This old plugin does work with NetBeans 8.1. My previous laptop has still got Netbeans 8.1 working with this plugin. I want to download the .nbm file again to install it on a new laptop.

Answer

You might try downloading the plugin here:

http://updates.netbeans.org/netbeans/updates/7.0/uc/final/certified/modules/extra/org-netbeans-modules-j2ee-sun-appsrv81…

It installs and works fine in NetBeans IDE 8.1.

Hope this helps,

--

Jiří Kovalský

NetBeans Community Manager

http://netbeans.org

Marked as Answer by user4931850 · Sep 27 2020
user4931850

Thank you

1 - 7
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 1 2013
Added on Jun 3 2013
4 comments
244 views