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 08:16:55 GMT
Message-ID: <3B99D41A.FEFE60F0@rationalconcepts.com>


Aiiiii!
  Sorry for my last blurb, I need more sleep.

  Ok, went looking on the technet site.

  See http://otn.oracle.com/sample_code/tech/java/jsp/content.html   on how to write stored java procs and publish them in the database, and use them.

  It answered my questions and showed me where my thinking process took a left turn ;-)

  Instead of trying to pass in a con to your stored proc, just make the connection in that chunk of code.
  (Connection con = new OracleDriver().defaultConnection();).

  Then load it into the db following their examples.

hth (at least more than the last blather...) cindy

  "C. Ferguson" wrote:

> 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 Sat Sep 08 2001 - 03:16:55 CDT

Original text of this message

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