Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: First parameter caused an ORA-00932 in java stored procedure of 8i

Re: First parameter caused an ORA-00932 in java stored procedure of 8i

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: Sat, 08 Sep 2001 01:43:35 GMT
Message-ID: <3B9977EB.B5B6B4BA@rationalconcepts.com>


Hi,

   this may be of little help because I haven't done what you are trying to do, but I did notice that you declared your java stored procedures with 5 parameters.

Your calling program is setting 4. Unfortunately, you are trying to call with the first parameter as a String type, where your stored procedure has defined a Connection type.

That should cause an error.

Now, alas, I haven't had the chance to write a java stored procedure, but why would a procedure in the database need a connection to the database?

cindy

Zhao wrote:

> Hi,
>
> I tried to use a java.sql.Connection as the first parameter of my
> procedure but
> got following error
>
> java.sql.SQLException: ORA-00932: inconsistent datatypes
> ORA-06512: at "COOLSHARE.CREATE_STUDENT2", line 0
> ORA-06512: at line 1
>
> Here is the procedure
>
> import java.sql.*;
>
> public class CreateStudent
> {
>
> public static void create(java.sql.Connection con, String
> studentId, String name, String age, String country)
> {
>
> }
> }
>
> I loaded the class by loadjava and published it with
>
> CREATE OR REPLACE PROCEDURE CREATE_STUDENT2(STUDENTID VARCHAR2, NAME
> VARCHAR2, AGE VARCHAR2, COUNTRY VARCHAR2)
> AS LANGUAGE JAVA NAME
> 'CreateStudent.create(java.sql.Connection,
> java.lang.String, java.lang.String, java.lang.String,
> java.lang.String)';
>
> and calling it with
>
> import java.sql.*;
>
> public class Client
> {
> public static void main(String[]args)
> {
> Client app = new Client();
> app.run();
> }
>
> public void run()
> {
> Connection con = getConnection();
> try
> {
> CallableStatement cs = con.prepareCall("{Call
> CREATE_STUDENT2(?, ?, ?, ?)}" );
> cs.setString(1, "14");
> cs.setString(2, "gggg");
> cs.setString(3, "24");
> cs.setString(4, "xxxx");
> cs.executeUpdate();
> con.close();
> }
> catch (Exception e)
> {
> System.err.println(e);
> try
> {
> con.close();
> }
> catch (Exception ee)
> {
> System.err.println(ee);
> }
> }
>
> }
>
> static java.sql.Connection getConnection()
> {
> try
> {
> //Class.forName("oracle.jdbc.driver.OracleDriver");
> DriverManager.registerDriver(new
> oracle.jdbc.driver.OracleDriver());
> java.sql.Connection connection =
> DriverManager.getConnection("jdbc:oracle:thin:@24.12.9.172:1521:coocoo",
> "aaaa", "xxxzzz");
> return connection;
>
> }
> catch (Exception e)
> {
> System.err.println("Failed to connect to DB:"+e);
>
> }
> return null;
> }
> }
>
> The reason I thought the problem caused by the first parameter,
> java.sql.Connection is that if I remove the first parameter, it worked
> fine.
>
> Any suggestion will be really appreciated.
>
> Zhao
Received on Fri Sep 07 2001 - 20:43:35 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US