CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Funny Problem

  1. #1
    Join Date
    Jul 1999
    Location
    India
    Posts
    3

    Funny Problem

    Subject
    JDBC Trouble
    Category
    Misc
    Posted by
    Prodi on 7/27/99 at 04:06 am

    Rating
    urgent

    Hi,

    We are using Oracle 8.0 and JDK 1.2.

    While retrieving data through JDBC, from a table, a cryptic General error message is coming.

    The table structure is :

    Student_Name varchar2(10)
    Student_id varchar2(5)
    Books_issued Books

    where Books is a nested table created from the Object Books_Type which has the following structure:

    Books_id varchar2(5)
    Author varchar2(10)
    Title varchar2(10)
    Issue_Date Date
    Return_Date Date


    The query :

    select * from student;

    works in SQL but not in JDBC.

    But, queries like
    select books_issued the(select books_issued from student )
    or
    select student_id from student

    is working through JDBC.

    The code in our java program is given below :

    import java.sql.*;
    import genins.dbconnect.*;

    public class ORDMS
    {
    public static void main(String ar[])
    {

    ResultSet res ;
    MDBConnect st = new MDBConnect();
    try
    {
    res = st.executeQuery("select * from student ");
    while(res.next())
    {
    System.out.println("inside next..");
    System.out.println("Integer"+res.getString(1));
    System.out.println(" "+res.getString(2));
    System.out.println(" "+res.getString(3));
    System.out.println(" "+res.getString(4));
    System.out.println(" "+res.getString(5));
    }
    }
    catch(SQLException e)
    {
    System.out.println("Exception ERROR"+e);
    }
    }
    }


    The Connectivity to the database is done through a java program in the package dbconnect.

    After executing the above piece of code, only this particular SQL query is not executing and gives the
    cryptic message : General Error.

    Please tell us whether it is possible to retrieve all the fields through a single SQL Query and how...

    Regards,

    JavaTeam.



  2. #2
    Join Date
    Jul 1999
    Location
    Metro DC
    Posts
    32

    Re: Funny Problem

    try printing out the SQL code and vendor error code to get a feel for what is happening. If you still have this problem let me know what the SQL state is.




  3. #3
    Join Date
    Jul 1999
    Location
    India
    Posts
    3

    Re: Funny Problem

    Actually the SQL itself is executing perfectly in Oracle. Hence, there is no Error Code in Oracle.However the same piece of SQL is returning the following error code in java :
    Accessing java.sql.SQLException General Error

    Hence we are not able to pinpoint exactly what is going wrong. If you so desire, we can mail our code for creating the nested table and our JDBC Connection Code to you.
    Thanx for taking interest,
    Regards,
    Prodi.



  4. #4
    Join Date
    Jul 1999
    Posts
    19

    Re: Funny Problem

    I seriously doubt that I can be of help here but it's worth the try.

    I've had unbelievable problems with SQL commands if they don't have the right syntax. Try adding a ";" at the end of your SQL statement. Believe it or not... it worked for me once... (oh.. an if the code you put up on your post was EXACTLY the same as the code you use.. make sure there's no space after the command... it should look like this:
    "select * from student;"

    I doubt this solves your problem but it's worth the try anyways.

    An elephant is a mouse with an operating system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured