no method error
Date: 30 Aug 2001 01:57:50 -0700
Message-ID: <cea38d69.0108300057.683f230b_at_posting.google.com>
I tried to create a function, GetStudentInfo, with Oracle 8i as following
import java.sql.*;
import java.io.*;
public class GetStudentInfo {
public static String getStudentByCountry (Connection conn, String country) throws SQLException {
// Build SQL statement String sql = "select STUDENT.NAME from STUDENT, COUNTRY where STUDENT.COUNTRY = COUNTRY.NAME AND COUNTRY.NAME = '"+ country + "'"; try { Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); String res = rs.getString(1); stmt.close(); return res; } catch (SQLException e) { System.err.println(e.getMessage()); } return null;
} // dropIt
} // GenericDrop
I compiled it and load it with
loadjava -u system/manager_at_coo -f -resolve *.class
Then, I published it with
CREATE OR REPLACE FUNCTION get_student (country VARCHAR2) RETURN
VARCHAR2
AS LANGUAGE JAVA NAME
'GetStudentInfo.getStudentByCountry(ava.sql.Connection,
java.lang.String)
return java.lang.String';
I then create those two tables, STUDENT and COUNTRY, and added some
items
into them. I was able to see those created items with sqlp.
But I got following error when I invoked it with
SELECT get_student('China') FROM STUDENT;
- error ************
SELECT get_student('China') FROM STUDENT
*
ERROR at line 1:
ORA-29531: no method getStudentByCountry in class GetStudentInfo
I tried to verify if the java class was loaded by dropping the class with
loadjava -u system/manager_at_coo *.class
and load it again with
loadjava -u system/manager_at_coo -f -resolve *.class
I then run
SELECT get_student('China') FROM STUDENT;
again and got
ERROR at line 1:
ORA-29549: class SYSTEM.GetStudentInfo has changed, Java session state
cleared
It seems that the class was loaded....
Anyone has any idea about what was wrong?
Any response will be really appreciated.
Mark Received on Thu Aug 30 2001 - 10:57:50 CEST