Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have the following code which calls a stored procedure from the Java database. Even though my class is public i get an error saying ....

The class 'WorkPlace_Seat_Allocation' does not exist or is inaccessible. This can happen if the class is not public.
BUILD SUCCESSFUL (total time: 0 seconds)




package workplace_seat_allocation;
import java.sql.*;
public class WorkPlace_Seat_Allocation {
    public static void main(String[] args) {
        View_All_Seats();
    }
    public static Connection getConnection(){
        Connection con=null;
        try{
            String host = "jdbc:derby://localhost:1527/SeatAllocation";
            String uName = "SeatAllocation";
            String Password = "sandy";
            con = DriverManager.getConnection(host, uName, Password);
        }
        catch(SQLException e){
            System.out.println(e.getMessage());
    }
        return con;
   }
    public static void View_All_Seats(){
        Connection con =getConnection();
        CallableStatement cs =null;
        ResultSet rs = null;
        try {
            cs = con.prepareCall("{call GetAllSeatS(?,?,?)}");
            cs.registerOutParameter(1,Types.VARCHAR); 
            cs.execute();
            rs = (ResultSet) cs.getObject(1);
         
                while(rs.next()){
                    System.out.println(rs.getString(1)+" "+ rs.getString(2)+ " "+ rs.getString(3));
                }
                con.close();
         }
         catch(SQLException e){
            System.out.println(e.getMessage());
         }
        
    }
}


and here is the stored procedure

SQL
CREATE PROCEDURE GetAllSeatS(OUT sid varchar(5), out loc varchar(15), OUT ext char(4))
PARAMETER STYLE JAVA READS SQL DATA LANGUAGE JAVA EXTERNAL NAME
--"SELECT SEATID, LOCATION, EXTENSION from seat"
'WorkPlace_Seat_Allocation.View_All_Seats';
Posted

I think you need to fully qualify the class name with it's package name.
Try changing
SQL
CREATE PROCEDURE GetAllSeatS(OUT sid varchar(5), out loc varchar(15), OUT ext char(4))
PARAMETER STYLE JAVA READS SQL DATA LANGUAGE JAVA EXTERNAL NAME
--"SELECT SEATID, LOCATION, EXTENSION from seat"
'WorkPlace_Seat_Allocation.View_All_Seats';

to
SQL
CREATE PROCEDURE GetAllSeatS(OUT sid varchar(5), out loc varchar(15), OUT ext char(4))
PARAMETER STYLE JAVA READS SQL DATA LANGUAGE JAVA EXTERNAL NAME
--"SELECT SEATID, LOCATION, EXTENSION from seat"
'workplace_seat_allocation.WorkPlace_Seat_Allocation.View_All_Seats';


Hope this helps,
Fredrik
 
Share this answer
 
Comments
SandraCy 30-Aug-13 7:36am    
Still no luck.

The class 'workplace_seat_allocation.WorkPlace_Seat_Allocation' does not exist or is inaccessible. This can happen if the class is not public.
BUILD SUCCESSFUL (total time: 0 seconds)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900