本文介绍了Java错误:类不存在或无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码从Java数据库调用存储过程。即使我的班级是公开的,我也会收到一个错误说明....
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
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';
推荐答案
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
to
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';
希望这会有所帮助,
Fredrik
Hope this helps,
Fredrik
这篇关于Java错误:类不存在或无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!