Hi,

Just a guess:

Why dont u try the following:
String sqlQueries = "select count(*) from p1_upload_info ; select count(*) from p2_upload_info ";
and use the JDBC API to print the resultsets directly.  I am not too familair with the JDBC ResultSet API.

The code should look like:

public GetMoreResultSet()throws Exception
 {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn=DriverManager.getConnection("url");
  
String sqlQueries = "select count(*) from p1_upload_info; select count(*) from p2_upload_info ";
  
  PreparedStatement stmt = conn.prepareStatement(sqlQueries);
  
  boolean bool = stmt.execute();
  
  ResultSet rs1 = stmt.getResultSet();
  rs1.next();
  // int count1 = rs1.getInt("count1");
  // put the code here to get the resultset displayed
  rs1.close();
  // advance to the next ResultSet
  stmt.getMoreResults();
  ResultSet rs2 = stmt.getResultSet();
  rs2.next();
  // int count2 = rs2.getInt("count2");
  // put the code here to get the resultset displayed
  rs2.close();
  // output results
  System.out.println("table1 has a count of : " + count1);
  System.out.println("table2 has a count of : " + count2);
  // close remaining database objects
  stmt.close();
  conn.close();
 }

Regards,
Nitin

prashant samant wrote:
Hi,
    just go to this particular link
    http://www.javaworld.com/javaworld/jw-02-2000/jw-02-ssj-jdbc2.html
 
 
They have suggested the way to execute multiple queries.
 
T & R,
Prashant S.
 
IndiaIdeas.com Ltd.,
E-510, Crystal Plaza,
Andheri Link Road,
Andheri (W),Mumbai 400 053
INDIA
Tel:6920005/6
****************************************************************************
*************************************************************************
The information contained in this communication is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. It may contain confidential or legally privileged information. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by responding to this email and then delete it from your system. IndiaIdeas is neither liable for the proper and complete transmission of the information contained in this communication nor for any delay in its receipt.
----- Original Message -----
Sent: Wednesday, January 08, 2003 9:35 PM
Subject: Re: getMoreResultSet

Hi,
  I hope that is not the way to execute multiple queries.U have to execute multiple queries using addBatch method of Statement.Go through API. If you are having any more doubts u are most welcome.
 
Regards,
 

 M.Raghu Rama Sarma
 Virtusa India Pvt.Ltd.
 Hyderabad
 Phone : 91 40 2341 4200

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
an attempt may be failure,
but there should not be failure in an attempt

  - Albert Einstein

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

-----Original Message-----
From: prashant samant [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 10, 2003 12:41 AM
To: [EMAIL PROTECTED]
Subject: getMoreResultSet

Hello everybody,
 I am trying to execute multiple queries as follows.
 
public GetMoreResultSet()throws Exception
 {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn=DriverManager.getConnection("url");
  String sqlQueries = "select count(*) as count1 from p1_upload_info ; select count(*) as count2 from p2_upload_info ";
  
  PreparedStatement stmt = conn.prepareStatement(sqlQueries);
  
  boolean bool = stmt.execute();
  
  ResultSet rs1 = stmt.getResultSet();
  rs1.next();
  int count1 = rs1.getInt("count1");
  rs1.close();
  // advance to the next ResultSet
  stmt.getMoreResults();
  ResultSet rs2 = stmt.getResultSet();
  rs2.next();
  int count2 = rs2.getInt("count2");
  rs2.close();
  // output results
  System.out.println("table1 has a count of : " + count1);
  System.out.println("table2 has a count of : " + count2);
  // close remaining database objects
  stmt.close();
  conn.close();
 }
 
 
But the above code is giving me Invalid Character error.  If i remove the semi colon from sqlQueries variable than it gives me
error "SQL command not properly ended "
I am using jdbc 2.0 (classes 12.zip ).
can anybody help me to sort this problem.
 
Thanx & Regards,
Prashant S.
 
 
IndiaIdeas.com Ltd.,
E-510, Crystal Plaza,
Andheri Link Road,
Andheri (W),Mumbai 400 053
INDIA
Tel:6920005/6
****************************************************************************
*************************************************************************
The information contained in this communication is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. It may contain confidential or legally privileged information. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. If you have received this communication in error, please notify us immediately by responding to this email and then delete it from your system. IndiaIdeas is neither liable for the proper and complete transmission of the information contained in this communication nor for any delay in its receipt.

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to