java - Oracle JDBC and Views -
i trying select statement view executequery cant resultset, meta data intact (names , number of columns) tried change preparedstatement , callablestatement , same
here code
private statement stmt=null; private resultset rset=null; ........ rset = stmt.executequery("select student_id,first_name,last_name student_view"); columnnum=rset.getmetadata().getcolumncount(); toclient.writeint(columnnum); for(int i=1;i<=columnnum;i++) toclient.writeutf(rset.getmetadata().getcolumnname(i)); if (rset.last()) { toclient.writeint(rset.getrow()); rset.beforefirst(); } while (rset.next()) for(int i=1;i<=columnnum;i++){ if(rset.getstring(i)!=null) toclient.writeutf(rset.getstring(i)); else toclient.writeutf(" "); }
in debug mode java can't execute rset.last() command
but when
rset = stmt.executequery("select * student_view")
the code run perfectly. can 1 help?
the student_view
create or replace view student_view select s.student_id,s.first_name,s.last_name,s.phone,s.birth_date,s.street, s.zip_code,d.name department,d.credits_to_degree,s.credits,s.eligible,c.name college student s,department d,college c s.department=d.department_id , d.college_id=c.college_id;
the other tables
create table department ( department_id varchar(4) not null, name varchar(25) unique, department_head_id varchar(9), college_id varchar(4), credits_to_degree number(3), students number(3), faculty number(3),constraint pkdepartment primary key (department_id)); alter table department add foreign key (department_head_id) references faculty(faculty_id) deferred; alter table department add foreign key(college_id) references college(college_id) deferred; create table student ( student_id varchar(9) not null, first_name varchar(25), last_name varchar(25), phone char(11), birth_date date, street varchar(100), zip_code char(5), department varchar(4), credits integer, eligible char(4), constraint pkstudent primary key (student_id),constraint fkdeptid foreign key (department) references department(department_id)); create table college( college_id varchar(4) not null, name varchar(25), since date, dean_id varchar(9),constraint pkcollege primary key (college_id));
Comments
Post a Comment