Send byte array argeument from pl/sql to java stored procedure?
I have a java method that accepts an argument of type byte[].
I want to define a call specification so that it can invoked from a sql statement.
The Java Developer's Guide show how to map SQL data types to java types and classes, but it is unclear if I can map a SQL data type to an array.
Does anyone know which SQL type to use to map to a byte array?
I'm using Oracle 10.2, thus jvm 1.4.2.
As soon as I posted this question, I saw the RAW to byte[] mapping listed in the documentation. How did I overlook it? Anyway, that what I needed.
Similar Messages
-
Issue with sending mail through java stored procedure in Oracle
Hello
I am using Oracle 9i DB. I created a java stored procedure to send mail using the code given below. The java class works fine standalone. When its run from Java, mail is sent as desired. But when the java stored procedure is called from pl/sql "Must issue a STARTTLS command first" error is thrown. Please let me know if am missing something. Tried the same code in 11.2.0.2 DB and got the same error
Error:
javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first. va6sm31201010igc.6
Code for creating java stored procedure: (T1 is the table created for debugging)
==================================================
create or replace and compile java source named "MailUtil1" AS
import java.util.Enumeration;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class MailUtil1 {
public static void sendMailwithSTARTTLS(String host, //smtp.projectp.com
String from, //sender mail id
String fromPwd,//sender mail pwd
String port,//587
String to,//recepient email ids
String cc,
String subject,
String messageBody) {
try{
Properties props = System.getProperties();
props.put("mail.smtp.starttls.enable", "True"); // added this line
props.put("mail.smtp.host", host);
props.put("mail.smtp.user", from);
props.put("mail.smtp.password", fromPwd);
props.put("mail.smtp.port", port);
props.put("mail.smtp.auth", "true");
#sql { insert into t1 (c1) values ('1'||:host)};
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
#sql { insert into t1 (c1) values ('2')};
InternetAddress[] toAddress = new InternetAddress[1];
// To get the array of addresses
for( int i=0; i < toAddress.length; i++ ) { // changed from a while loop
toAddress[i] = new InternetAddress(to);
//System.out.println(Message.RecipientType.TO);
for( int i=0; i < toAddress.length; i++) { // changed from a while loop
message.addRecipient(Message.RecipientType.TO, toAddress);
if (cc!=null) {
InternetAddress [] ccAddress = new InternetAddress[1];
for(int j=0;j<ccAddress.length;j++){
ccAddress[j] = new InternetAddress(cc);
for (int j=0;j<ccAddress.length;j++){
message.addRecipient(Message.RecipientType.CC, ccAddress[j]);
message.setSubject(subject);
message.setText(messageBody);
message.saveChanges();
#sql { insert into t1 (c1) values ('3')};
Enumeration en = message.getAllHeaderLines();
String token;
while(en.hasMoreElements()){
token ="E:"+en.nextElement().toString();
#sql { insert into t1 (c1) values (:token)};
token ="ConTyp:"+message.getContentType();
#sql { insert into t1 (c1) values (:token)};
token = "Encod:"+message.getEncoding();
#sql { insert into t1 (c1) values (:token)};
token = "Con:"+message.getContent();
#sql { insert into t1 (c1) values (:token)};
Transport transport = session.getTransport("smtp");
#sql { insert into t1 (c1) values ('3.1')};
transport.connect(host, from, fromPwd);
#sql { insert into t1 (c1) values ('3.2')};
transport.sendMessage(message, message.getAllRecipients());
#sql { insert into t1 (c1) values ('3.3')};
transport.close();
#sql { insert into t1 (c1) values ('4')};
catch(Exception e){
e.printStackTrace();
String ex= e.toString();
try{
#sql { insert into t1 (c1) values (:ex)};
catch(Exception e1)
Edited by: user12050615 on Jan 16, 2012 12:18 AMHello,
Thanks for the reply. Actually I have seen that post before creating this thread. I thought that I could make use of java mail to work around this problem. I created a java class that succesfully sends mail to SSL host. I tried to call this java class from pl-sql through java stored procedure. That did not work
So, is this not supported in Oracle ? Please note that I have tested this in both 9i and 11g , in both the versions I got the error. You can refer to the code in the above post.
Thanks
Srikanth
Edited by: user12050615 on Jan 16, 2012 12:17 AM -
How to send SMS thru SMPP from PL/SQL
How to send SMS thru SMPP from PL/SQl or forms application. SMPP interface setuped in the SMSC. Requirement is send to SMS's to custoemrs thru our forms application.
How to send SMS thru SMPP from PL/SQl or forms application. SMPP interface setuped in the SMSC. Requirement is send to SMS's to custoemrs thru our forms application.
-
Passing array from java stored procedure to plsql
I have a java store procedure that is parsing an xml document and returning element values to my plsql application(8.1.7). I'm mapping a java.lang.String return type to VARCHAR2. However I'm running into the 4k limit when trying to return a string from java that is over 4k. Truncation of varchar returning over 4k is a known issue in 8i.
So my next idea was to split that value of the element into 2000char and put in an array then pass that back to the plsql procedure. I know that oracle.sql.ARRAY can be converted into a plsql TABLE. But I believe you can only use the oracle.sql.ARRAY type when you are doing jdbc programming and are working with a connection.
SO FINALLY MY QUESTION IS...
Can anyone think of a solution that will allow me to pass over 4k of character data from my java stored procedure (not jdbc), back to my plsql app?
Thanks.My understanding is that oracle 8 has a 4k limitation on any plsql function return data. A varchar can hold 32k within a function/package, but it cannot return more than 4k outside it's scope.
Do you have an example you could share where you use the clob as a return type?
Thanks! -
Calling Operating System Commands from PL/SQL using java
Calling Operating System Commands from PL/SQL - The Java Way
wlth help of given thread link,
Calling OS Commands from Plsql
but i had user privilege problem
Declare
x Varchar2(2000);
Begin
x := OSCommand_Run('/tmp/sri/GROUP_ho.sh');
DBMS_OUTPUT.Put_Line(x);
End;
o/p;
can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
i done the grant privillage also
part
dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
dbms_java.grant_permission('abcd', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
dbms_java.grant_permission('
abcd', 'SYS:java.io.FilePermission','<<ALL FILES>>', 'execute');
again
get
can't exec: /tmp/sri/GROUP_ho.sh lacks user privilege
same error;Process management at the OS level should prevent execution continuing in the calling code until the command has completed (either successfully or with error).
If the low level java code were to spawn child process threads then execution could continue, but I'm guessing the Java function your talking about doesn't do that and just calls the operating system to execute the command and waits for the returning code to come back. -
From PL/SQL call java class present in Application server
Hi,
I need to call a java class file which is present on the application server. the call has to be made from pl/sql.
I do not want to make use of the java stored procedures for this.
Is there a way to call a class file residing on the application server from a pl/sql.
Please help me out.
Thanks & Regards
KamleshNew idea. DDL isn`t working but if i would make some DQL ? Like select??
I`m trying to deploy java class like this:
public class test {
public static String say()
throws SQLException{
Connection conn = new OracleDriver().defaultConnection();
String sql = "Select names from pdb_proteins where numbers=61";
try {
// Load the Oracle JDBC driver
Class.forName("oracle.jdbc.OracleDriver") ;
System.out.println("Oracle JDBC driver loaded ok.");
} catch (Exception e) {
System.err.println("Exception: "+e.getMessage());
try {
ResultSet rset = null;
PreparedStatement pstmt = conn.prepareStatement(sql);
rset=pstmt.executeQuery(sql);
String wynik = null;
wynik = rset.getString(1);
return wynik;
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return "nope";
Then invoke with PL/SQL function
and i`m getting error ORA-29534: object SYSTEM.oracle/jdbc/OracleDriver
Could someone help me with this? How i could register jdbc driver inside Oracle db??
Edited by: Rado_mir on 2013-06-03 02:42 -
Connecting to SQL Server and MYSQL from a Java stored procedure
hope someone can help with this. i'm trying to connect to different databases (My SQL, SQL Server) from a java stored procedure. when invoking from within an oracle 9i database, i get the java exception error -
"Cannot connect to MySQL server on 135.177.196.75:3306. Is there a MySQL server running on the machine/port you are trying to connect to?java.security.AccessControlException)".
this store procedure works fine when invoked from outside of oracle. any replies would be greatly appreciated. thanks!the correct drivers have been loaded. it works when called from outside of oracle. only when invoking from within oracle do we get the error message "Cannot connect to MySQL server on 135.177.196.75:3306. Is there a MySQL server running on the machine/port you are trying to connect to?(java.security.AccessControlException)". it sounds like a permissions/security/configuration issue - oracle is not allowing access to the machine/port for the MySQL or SQL Server database. appreciate the responses so far.
-
Passing Tables back from Java Stored Procedures
Thomas Kyte has written (in reference to
trying to pass an array back from a stored
function call):
You can do one of two things (and both require the use of
objects). You cannot use PLSQL table types as JDBC cannot bind to
this type -- we must use OBJECT Types.
[snip]
Another way is to use a result set and "select * from
plsql_function". It could look like this:
ops$tkyte@8i> create or replace type myTableType as table of
varchar2 (64);
2 /
Type created.
ops$tkyte@8i>
ops$tkyte@8i>
ops$tkyte@8i> create or replace
2 function demo_proc2( p_rows_to_make_up in number )
3 return myTableType
4 as
5 l_data myTableType := myTableType();
6 begin
7 for i in 1 .. p_rows_to_make_up
8 loop
9 l_data.extend;
10 l_data(i) := 'Made up row ' | | i;
11 end loop;
12 return l_data;
13 end;
14 /
Function created.
ops$tkyte@8i>
ops$tkyte@8i> select *
2 from the ( select cast( demo_proc2(5) as mytableType )
3 from dual );
COLUMN_VALUE
Made up row 1
Made up row 2
Made up row 3
Made up row 4 [Image]
Made up row 5
So, your JDBC program would just run the query to get the data.
If the function "demo_proc2" cannot be called from SQL for
whatever reason (eg: it calls an impure function in another piece
of code or it itself tries to modify the database via an insert
or whatever), you'll just make a package like:
ops$tkyte@8i> create or replace package my_pkg
2 as
3
4 procedure Make_up_the_data( p_rows_to_make_up in
number ); 5 function Get_The_Data return myTableType;
6 end;
7 /
Package created.
ops$tkyte@8i>
ops$tkyte@8i> create or replace package body my_pkg
2 as
3
4 g_data myTableType;
5
6 procedure Make_up_the_data( p_rows_to_make_up in number )
7 as
8 begin
9 g_data := myTableType();
10 for i in 1 .. p_rows_to_make_up
11 loop
12 g_data.extend;
13 g_data(i) := 'Made up row ' | | i;
14 end loop;
15 end;
16
17
18 function get_the_data return myTableType
19 is
20 begin
21 return g_data;
22 end;
23
24 end;
25 /
Package body created.
ops$tkyte@8i>
ops$tkyte@8i> exec my_pkg.make_up_the_data( 3 );
PL/SQL procedure successfully completed.
ops$tkyte@8i>
ops$tkyte@8i> select *
2 from the ( select cast( my_pkg.get_the_data as mytableType
) 3 from dual );
COLUMN_VALUE
Made up row 1
Made up row 2
Made up row 3
And you'll call the procedure followed by a query to get the
data...
I have tried this, and it works perfectly.
My question, is what does the wrapper look
like if the stored function is written
in java instead of PL/SQL? My experiments
with putting the function in java have been
dismal failures. (I supposed I should also
ask how the java stored procedure might
look also, as I suppose that could be where
I have been having a problem)
nullThanks for the response Avi, but I think I need to clarify my question. The articles referenced in your link tended to describe using PL/SQL ref cursors in Java stored procedures and also the desire to pass ref cursors from Java to PL/SQL programs. Unfortunately, what I am looking to do is the opposite.
We currently have several Java stored procedures that are accessed via select statements that have become a performance bottleneck in our system. Originally the business requirements were such that only a small number of rows were ever selected and passed into the Java stored procedures. Well, business requirements have changed and now thousands and potentially tens of thousands of rows can be passed in. We benchmarked Java stored procedures vs. PL/SQL stored procedures being accessed via a select statement and PL/SQL had far better performance and scaleable. So, our thought is by decouple the persistence logic into PL/SQL and keeping the business logic in Java stored procedures we can increase performance without having to do a major rewrite of the existing code. This leads to the current problem.
What we currently do is select into a Java stored procedure which has many database access calls. What we would like to do is select against a PL/SQL stored procedure to aggregate the data and then pass that data via a ref cursor (or whatever structure is acceptable) to a Java stored procedure. This would save us a significant amount of work since the current Java stored procedures would simple need to be changed to not make database calls since the data would be handed to them.
Is there a way to send a ref cursor from PL/SQL as an input parameter to a Java stored procedure? My call would potentially look like this:
SELECT java_stored_proc(pl/sql_stored_proc(col_id))
FROM table_of_5000_rows;
Sorry for the lengthy post. -
ResultSet from Java Stored Procedures
Hi,
How do I obtain a resultset from a Java Stored Procedure?
My stored procedure, deployed in Oracle8i, has Database package as sample.Have published setConnection() and getDept() methods.
Code for Java Stored Procedure:
package SPPackage;
import java.sql.*;
public class StoredProcApplication {
protected static Connection connection = null;
protected static Statement stmt = null;
protected static ResultSet res = null;
public static void setConnection() throws SQLException {
connection = new oracle.jdbc.driver.OracleDriver().defaultConnection();
public static void getDept(Object[] obj) throws SQLException {
if (connection == null) {
setConnection();
if (stmt == null) {
stmt = connection.createStatement();
if (res == null) {
res = stmt.executeQuery("select * from DEPT");
obj[0] = res;
Code for TesterApplication :
package SPPackage;
import java.sql.*;
public class TesterApplication {
private static final String URL = "jdbc:oracle:thin:@sandeep:1521:oracle8i";
private static final String userId = "sandeep";
private static final String password = "sandeep";
private Connection connection;
private CallableStatement stmt;
private ResultSet res;
public void setConnection() throws ClassNotFoundException,SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection(URL,userId,password);
public void getResultFromSP() throws SQLException {
//prepare to call the stored procedure
stmt = connection.prepareCall("{call sample.getDept(?)}");
//register the OUT parameters
stmt.registerOutParameter(1,Types.OTHER);
//execute the query
stmt.execute();
ResultSet res = (ResultSet)stmt.getObject(1);
while (res.next()) {
System.out.print(res.getInt(1) + " | " );
System.out.print(res.getString(2) + " | " );
System.out.print(res.getString(3) + " \n " );
public TesterApplication() throws SQLException,ClassNotFoundException {
try {
setConnection();
getResultFromSP();
} finally {
if (res != null) { res.close(); res = null; }
if (stmt != null) { stmt.close(); stmt = null; }
if (connection != null) { connection.close(); connection = null; }
public static void main(String[] args) {
try {
TesterApplication ta = new TesterApplication();
} catch (Exception e) {
System.err.println("Error while executing stored procedure " + e.getMessage());
e.printStackTrace();
When I run the TesterApplication, I get the following exception :
java.sql.SQLException: Invalid column type: get_internal_type
at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
at oracle.jdbc.driver.OracleStatement.get_internal_type(Compiled Code)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(Compiled Code)
Also, if I want to execute the ResultSet in the stored proc itself, and return the values as Arrays of int[], and String[], how do I do it?By default the you can populate only int[0], String[0] , i.e. only one value!!!
if my statement is unknown, i.e, it might return a combination of updates and resultsets, how do I go about processing the result?
Please advise!!
TIA
Sandeep
nullHi kkirk,
I found the post you mentioned.Well it dates back to November 1999 - "Problem returning resultset or ARRAY from java stored proc" by Stuart Popejoy ([email protected]).Too bad, it is still not solved!!
I am not very good at PL/SQL.However, it would still be helpful, if you could post the code here, or at my email address.
Meanwhile, I was trying this during the week-end.There seems to be a glimmer of hope!!
Let me know, if this makes sense :
CallableStatement cs = connection.prepareCall("begin open ? for select * from dept; end");
try {
cs.registerOutParameter(1,OracleTypes.CURSOR);
ResultSet res = ((OracleCallableStatement)cs).getCursor(1);
while (res.next()) {
//get the values
} catch (Exception e) {
e.printStacktrace();
However, I am getting an exception trace
Error while executing stored procedure Invalid column type: getLong
java.sql.SQLException: Invalid column type: getLong
at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
at oracle.jdbc.driver.OracleStatement.getLongValue(Compiled Code)
Not quite sure why this is happening!!
TIA,
Sandeep
null -
Unable to access Custom UDTs returned from a Java Stored Procedure
Hi,
I have a UDT in the DB :-
create type contactrecord as object (
CN_ID NUMBER(8),
CN_TITLE VARCHAR2(40),
CN_FIRST_NAME VARCHAR2(25)
and this is the corresponding java class ContactDetails.java that maps to this UDT, that I loaded in the Aurora VM.
package package1;
mport java.sql.SQLData;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.SQLOutput;
public class ContactDetails implements SQLData
private String sql_type;
private long CN_ID;
private String CN_TITLE;
private String CN_FIRST_NAME;
public String getSQLTypeName() throws SQLException
return this.sql_type;
//implementation of readSql
public void readSQL(SQLInput stream, String typeName) throws SQLException
sql_type = typeName;
CN_ID = stream.readLong();
CN_TITLE = stream.readString();
CN_FIRST_NAME = stream.readString();
public void writeSQL(SQLOutput stream) throws SQLException
stream.writeLong(CN_ID);
stream.writeString(CN_TITLE);
stream.writeString(CN_FIRST_NAME);
//getters and setters for the class vars go here.....
There is another class A.java that has a java stored procedure/function, which I loaded into the Aurora VM
Here is the class.
package package1;
public class A
public static ContactDetails returnObject(String name )
ContactDetails cd = new ContactDetails();
cd.setCN_ID(1);
cd.setCN_FIRST_NAME(name);
return cd;
Then I declared the call spec for A.returnObject() as
FUNCTION returnObject(name varchar2) return contactrecord
AS LANGUAGE JAVA
NAME 'package1.A.returnObject(java.lang.String) return package1.ContactDetails';
Then I tried to call the function returnObject through JDBC calls from a class in another VM.
When I access the object returned by the function, I get a null object.
Here is the Client code:
CallableStatement cs = null;
ResultSet rs = null;
try
cs = conn.prepareCall("{ ? = call returnObject(?) }");
java.util.Map map = conn.getTypeMap();
map.put("ADMIN.CONTACTRECORD", Class.forName("package1.ContactDetails"));
conn.setTypeMap(map);
cs.registerOutParameter(1, OracleTypes.STRUCT, "ADMIN.CONTACTRECORD");
cs.setString(2, "John Doe" );
cs.execute();
ContactDetails cd = (ContactDetails)cs.getObject(1);
System.out.println("contact first name is:-"+cd.getCN_FIRST_NAME()); //Null Pointer here..cd is null....:(
if (cs != null) cs.close();
catch(Exception e)
e.printStackTrace();
Although If I try to access the same function from a pl/sql block, I am able
to access the contactrecord fields.
What could be wrong ..???
I could not find any error with the object mapping, as it works perfectly when I interact directly from my VM to the DB,
without going thru the aurora VM.
I am using a OCI driver to connect to the DB via JDBC.
Thanx in advance for any help at all.
-skShahid,
I too have had bad luck in many cases with the automatic translation of Java types to PL/SQL and back. I think the SYS package on the PL/SQL side which handles some of the conversion is DBMS_PICKLER (there are equivalent Java classes which do the same in that world and seem to execute automagically when a conversion is needed). You might want to double-check the data type mappings against the DOC on OTN to make sure they map 1-1. Also make sure the permissions are granted against your objects to whoever is executing them, etc. Very often, I've resorted to passing simple scalar types between the two languages as in some cases the results with complex types are inconsistent.
Sorry this isn't much help,
-Dan
http://www.compuware.com/products/devpartner/db/oracle_debug.htm
Debug PL/SQL and Java in the Oracle Database -
Speed test: PL/SQL vs. Java Stored Procedures
I performed tests on these two procedures:
===========================================
// Create a Statement
Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
// Query the table
ResultSet rset = stmt.executeQuery ("select SIFOB, SIFRA_GU from sezko");
while (rset.next ()) {
salary = rset.getInt(1);
rset.updateInt (1, salary + 1);
salary = rset.getInt(2);
rset.updateInt (2, salary + 1);
rset.updateRow();
} // while
conn.commit();
// Close the RseultSet
rset.close();
// Close the Statement
stmt.close();
===========================================
procedure updateTable is
cursor c_updateTable is select rowid, SIFOB, SIFRA_GU from sezko;
begin
for r_updateTable in c_updateTable loop
update sezko set SIFOB = SIFOB + 1, SIFRA_GU = SIFRA_GU + 1 where rowid = r_updateTable.rowid;
end loop;
commit;
end;
===========================================
First procedure is written in Java (as Java Stored procedure) and second is PL/SQL.
Java is about 10x slower than PL/SQL code.
Can you explain bad performance results?
thank you
Matic & AlesHi,
I suppose the problem is not with the connection object,but with make connection to the database for every executeupdate or executeupdaterow called .Similarly for fetching the data from the database you
can use the fetch size technique.Please check the 8.1.6 Java Developers guide for using this.
Update Batching(For Batch updates and commits)
Fetch Size(For Batch fetching)
Oracle Row Pre-Fetching
Regards
Anand
null -
How to execute a procedure or function from Java Stored procedure
Hi,
I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?
Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.
Thanks in advance.
PS. The variable passed in function is just a dummy variable.
-----Begin Java code-------
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
//Oracle Extensions to JDBC
import oracle.jdbc.driver.OracleDriver;
public class Test2{
public static String Testing(String d) {
Connection connection = null; // Database connection object
try {
// Get a Default Database Connection using Server Side JDBC Driver.
// Note : This class will be loaded on the Database Server and hence use a
// Se[i]Long postings are being truncated to ~1 kB at this time.what your after is
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci:@<hoststring>", "scott", "tiger");
CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;");
cs.registerOutParameter(1,Types.CHAR);
cs.setString(2, "aa");
cs.executeUpdate();
String result = cs.getString(1);
a more complete description can be found in the documentation at
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1001934
Dom -
Returning a serializable object from a java stored procedure
[Server : Oracle 8.1.6 on WinNT4 server. Client : java 1.2.2 on WinNT4 workstation.]
I am attempting to use a java stored procedure to build a complex serializable java object on the database (to minimise number of requests/queries on the network) and then return this object in response to the original query.
I have it writing a BLOB by means of
OutputStream os = retval.getBinaryOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(v);
return retval;
where retval is a blob selected from a dummy table (created for this purpose) and v is a vector containing only serializable objects.
However, on the client side when I attempt to recover the object by
OracleResultSet rs = (OracleResultSet)stmt.executeQuery("SELECT javatest FROM DUAL");
oracle.sql.BLOB blob=rs.getBLOB(1);
InputStream inp = blob.getBinaryStream();
ObjectInputStream oinp = new ObjectInputStream(inp);
Vector retval = (Vector)oinp.readObject();
I get an exception telling me that the input stream does not contain an object at the line containing new ObjectInputStream(inp);
The full exception is :
java.io.StreamCorruptedException: InputStream does not contain a serialized object
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:731)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:165)
at eRespond.DBLayer.JavaStoredProcedures.testdbobj.test2(testdbobj.java:143)
at eRespond.DBLayer.JavaStoredProcedures.testdbobj.main(testdbobj.java, Compiled Code)
I've checked that the returned blob is non-null, and that oracle.sql.BLOB is used throughout.
Any thoughts?
Thanks,
mark.Firstly I guess to be able to new B() as a Thread, B
should extends Thread.
Secondly the constructor should not have any return
type:
public B(String cmd)
instead of
public void B(String cmd)
Lastly there is no need to override the start() method
if all it does is to call the superclass. The subclass
automatically inherits the method.
Hope this helps.thanks for replying so soon...
yes, you are right, it should extends Thread and it is, i forgot to out in this example... my mistake!
i'll try the construnctor thing to see if it works. bare in mind that i working with java stored procedures, it should work even so, right?
thanks -
Sending mail in a Java Stored Procedure
Question: What is the best way to have a Java Stored Procedure connect to our mailhost and send an email? I have been trying to use URL and URLConnection, but I found out URL somehow does not support the "mailto" protocol in the Java Stored Procedure. Funny enough the "mailto" protocol is definetely supported by URL when I test it in the JDK virtual machine.
Maybe this is the reason: I read in the 8i docs that the 8i Virtual Machine is only JDK1.1.6 compliant.
Unfortunately I can't find the 1.1.6 docs anywhere. So I cannot do any research on what protocals are supported in JDK1.1.6 .
Conclusion: Is it possible to send an email in a Java Stored Procedure, and how?
Thanks in advance :-) JohanThe Java mail API was a set of extension libraries for the 1.1 JDK. I have heard of folks who succeeded in loading these intot he database and then using them from within a Java stored procedure.
-
Java Stored Procedures + oralce.xdb.XMLType + initxdbj.sql
In order to use XMLType object in java stored procedures, I need to import oralce.xdb.XMLType package. I got compiler error saying "Class oracle.xdb.XMLType not found" (See List1).
I check my installed package, sure enough these is no "oracle/xdb/XMLType" or any xdb related one. (See list2) This surprises me since my 9i/Solaris installation was successful and spotless one.
The 9i App Dev - XML doc states that script $ORACLE_HOME/rdbms/admin/initxdbj.sql could install that package. (See List3) The fact is no way this script could be found from Oracle901/Solaris8 or Oracle901/NT installations.
If java program moved to client and included xdb_g.jar in CLASSPATH, then it is fine as Doc declares. It just failed to compile in server as stored procedures.
Please help, Thanks.
Andy Ting DBA (301)240-2223, [email protected](now include Listings)
In order to use XMLType object in java stored procedures, I need to import oralce.xdb.XMLType package. I got compiler error saying "Class oracle.xdb.XMLType not found" (See List1).
I check my installed package, sure enough these is no "oracle/xdb/XMLType" or any xdb related one. (See list2) This surprises me since my 9i/Solaris installation was successful and spotless one.
The 9i App Dev - XML doc states that script $ORACLE_HOME/rdbms/admin/initxdbj.sql could install that package. (See List3) The fact is no way this script could be found from Oracle901/Solaris8 or Oracle901/NT installations.
If java program moved to client and included xdb_g.jar in CLASSPATH, then it is fine as Doc declares. It just failed to compile in server as stored procedures.
Please help, Thanks.
Andy Ting DBA (301)240-2223, [email protected]
====================================================================
List 1:
sql> select NAME,TYPE,SEQUENCE,LINE,substr(text,1,80) TEXT from user_errors order BY 1,2,3,4
NAME TYPE SEQUENCE LINE
TEXT
proto4a/database/XMLTypeTest JAVA CLASS 1 0
ORA-29535: source requires recompilation
proto4a/database/XMLTypeTest JAVA SOURCE 1 0
proto4a/database/XMLTypeTest:11: Class oracle.xdb.XMLType not found in import.
proto4a/database/XMLTypeTest JAVA SOURCE 2 0
proto4a/database/XMLTypeTest:12: Class XMLTYPE not found in import.
proto4a/database/XMLTypeTest JAVA SOURCE 3 0
Info: 2 errors
==============================================================
List 2:
sql> select OWNER,OBJECT_NAME,OBJECT_TYPE from all_objects
where upper(object_name) like '%XMLTYPE%';
OWNER OBJECT_NAME OBJECT_TYP
SYS /219cdace_AQxmlTypeInfoRespons JAVA CLASS
/a341e963_AQxmlTypeInfoRequest
XMLTYPE TYPE
XMLTYPE TYPE BODY
XMLTYPE_LIB LIBRARY
PUBLIC /219cdace_AQxmlTypeInfoRespons SYNONYM
/a341e963_AQxmlTypeInfoRequest
sql> select OWNER,OBJECT_NAME,OBJECT_TYPE from all_objects
where upper(object_name) like '%XDB%';
no rows selected
====================================================================
List 3:
Installing and using oracle.xdb.XMLType class
The oracle.xdb.XMLType is available in the xdb_g.jar file in the ORACLE_
HOME/rdbms/jlib where ORACLE_HOME refers to the Oracle home directory.
Using oracle.xdb.XMLType inside JServer:
This class is pre-loaded in to the JServer and is available in the SYS schema.
It is not loaded however, if you have upgraded your database from an earlier
version. If you need to upload the class into the JServer, you would need to run the
initxdbj.sql file located in the ORACLE_HOME/rdbms/admin directory, while
connected as SYS.
Using oracle.xdb.XMLType on the client:
If you need to use the oracle.xdb.XMLType class on the client side, then ensure that
the xdb_g.jar file is listed in your CLASSPATH environment variable.
=====================================================================
Maybe you are looking for
-
IPod touch 4th gen wont show up in iTunes, but my old iPod nano does.
So I've looked up this issue on multiple forums and here, but it seems like everyone is having a simmilar issue, but not the same. I've gone through just about everything here: http://support.apple.com/kb/ts1369 and I've tried all the trouble shootin
-
Skips Camera Raw when opening image from PSE organizer to CS
I have PSE7 from before and recently purchased CS6. I want to keep using PSE as an organizer and edit in CS6. When opening a raw file (CR2) from the organizer to CS using Ctrl-h the image opens directly in CS without opening in Camera Raw first. If I
-
Question about viewing folders
Guys, I was wondering how to view a folder in list view and make all the other windows open the same way. I recently came from Windows and I know there was a setting that would "apply to all folders". Does OS X have something like that? Also, if I ha
-
Steps to Process standard EDI ANSI X12 997 file from AS2 Server
Hi All, I have a scenario where we are receiving PO files from an EDI third party via AS2 adapter. In return, we are sending PO Acknowledgement and Invoice files to the third party via AS2 adapter. The fomat of the incoming and outgoing files are ANS
-
How can i open a raw nikon D300s file in photoshop 7.0.1?