Store procedure doesn't return resultset

hi guys
i m stuck in a prob.I am using "com.microsoft.jdbc.sqlserver.SQLServerDriver"
when i call a normal query it run fine but when i try to call a store procedure it gives no result set was produce, is it a problem with driver but if i use jdbsodbc driver it work fine.
code:-
pStmt= conn.prepareStatement("{call insertOpacResultsTemp(?,?,?,?,?)}");
pStmt.setString(1,sUserID);
//and other parameters
Resultset=pStmt.executeQuery();
plz guys help me out

Hello Amit,
Oracle Stored Procedure
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
create or replace package test_package as
type my_cursor is ref cursor;
procedure test_procedure (name in varchar2,sys_cursor out my_cursor);
end test_package;
create or replace package body test_package
as
procedure test_procedure (name in varchar2,sys_cursor out my_cursor)
as
l_sys_cursor my_cursor;
begin
     open l_sys_cursor
     for select * from krm_system
     where parameter_id = name;
     sys_cursor:= l_sys_cursor;
end test_procedure;
end test_package;     
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Java code for getting result set
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.*;
public class StoredProcTester{
     public static void main(String args[]){
          try{
               Class.forName("oracle.jdbc.driver.OracleDriver");
               Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:isorcl","user_id","password");
               CallableStatement cstmt = conn.prepareCall("{call test_package.test_procedure(?,?)}");
               cstmt.setString(1,"MAX_MEMORY");
               cstmt.registerOutParameter(2,OracleTypes.CURSOR);
               cstmt.execute();
               ResultSet rs = (ResultSet)cstmt.getObject(2);
               while(rs.next()){
                    System.out.println("ID\t" + rs.getString(1));
          }catch(Exception e){
               e.printStackTrace();
}

Similar Messages

  • Store procedure doesn't work

    I create a procedure in the schema, and I create a form manually with html whose action calls this procedure, such like this:
    <form action="!MYORACLE_DATA.IPORTAL_POLL.update_poll" method="post">
    When I click submit, such error comes out like this:
    ORA-06550: line 7, column 2:
    PLS-00201: identifier 'MYORACLE_DATA.IPORTAL_POLL' must be declared
    ORA-06550: line 7, column 2:
    PL/SQL: Statement ignored
    Actually, it was working before I tune the database. But I don't think it is the reason cause it doesn't work. Does anybody know solution, thanks in advance.
    null

    Hi,
    I tried creating 2 procedures :
    TEST1 as follows:
    create or replace procedure test1
    as
    begin
    htp.formOpen('portal30.test2');
    htp.formtext('ename');
    htp.formsubmit;
    htp.formclose;
    end;
    and another TEST2
    create or replace procedure TEST2(ename varchar)
    as
    begin
    htp.p('Hello '&#0124; &#0124;ename);
    end;
    I grant execute on both this to public and execute this it works fine.
    But if I include an '!' before portal30 as U have done "!MYORACLE_DATA.IPORTAL_POLL.update_poll" then it doesn't work.
    Please try removing the same .
    Hope this helps.
    Anu
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Xiaopeng Zhang ([email protected]):
    I create a procedure in the schema, and I create a form manually with html whose action calls this procedure, such like this:
    <form action=
    "!MYORACLE_DATA.IPORTAL_POLL.update_poll" method="post">
    When I click submit, such error comes out like this:
    ORA-06550: line 7, column 2:
    PLS-00201: identifier 'MYORACLE_DATA.IPORTAL_POLL' must be declared
    ORA-06550: line 7, column 2:
    PL/SQL: Statement ignored
    Actually, it was working before I tune the database. But I don't think it is the reason cause it doesn't work. Does anybody know solution, thanks in advance.<HR></BLOCKQUOTE>
    null

  • Procedure Doesn't return values

    Hello,
    I have a stored procedure which has varchar2 as IN and sys_recursor has OUT parameters.
    CREATE OR REPLACE PROCEDURE check_values (
         my_values            IN          emp.dept_no%TYPE,
         p_cursor        OUT sys_refcursor
    AS
         quoteValues     VARCHAR2 (256);
    BEGIN
         SELECT     '''' || REPLACE(my_values, ',', ''',''') || ''''
           INTO     quoteValues
           FROM     DUAL;
         OPEN p_cursor  FOR
              SELECT          emp_no,
                             emp_name,
                FROM     emp
               WHERE     dept_no IN (quoteValues);
    END check_values;
    /The problem I am facing is in where condition, if I give quoteValues it doesn't fetch me any records when I execute the procedure from sqlplus, but if I am giving
    my_values it does fetch me records. I am receiving IN parameters like 9856,9712,8723, so first I put single quote around the emp_no and pass that to where condition.
    How can I resolve this issue?
    Thanks

    user20090209 wrote:
    So why then it is not getting executed? if I hard code the above values in where condition it executes fine.Look at your WHERE clause:
    WHERE     dept_no IN (quoteValues);How many expressions there are in IN list? Right, only one. So no matter what the value of quoteValues is, that WHOLE value will be compared to dept_no. What you are trying to do can be done via dynamic SQL, LIKE operator or collection.
    Dynamic SQL:
    CREATE OR REPLACE PROCEDURE check_values (
         my_values            IN          emp.dept_no%TYPE,
         p_cursor        OUT sys_refcursor
    AS
         quoteValues     VARCHAR2 (256);
    BEGIN
         OPEN p_cursor  FOR
              'SELECT          emp_no,
                             emp_name,
                FROM     emp
               WHERE     dept_no IN (' || my_values || ')';
    END check_values;
    / LIKE operator:
    CREATE OR REPLACE PROCEDURE check_values (
         my_values            IN          emp.dept_no%TYPE,
         p_cursor        OUT sys_refcursor
    AS
         quoteValues     VARCHAR2 (256);
    BEGIN
         OPEN p_cursor  FOR
              SELECT          emp_no,
                             emp_name,
                FROM     emp
               WHERE     ',' || my_values || ',' LIKE '%,' || dept_no || ',%';
    END check_values;
    / Collection:
    CREATE OR REPLACE PROCEDURE check_values (
         my_values            IN          sys.OdciVarchar2List,
         p_cursor        OUT sys_refcursor
    AS
         quoteValues     VARCHAR2 (256);
    BEGIN
         OPEN p_cursor  FOR
              SELECT          emp_no,
                             emp_name,
                FROM     emp
               WHERE     dept_no IN (SELECT * FROM TABLE(my_values));
    END check_values;
    / and pass my_values as sys.OdciVarchar2List('2345','1245','9076').
    SY.

  • App Store 'Search' doesn't return anything

    Using an iPad 2 updated to iOS6 when accessing the App 'App Store' on entering a valid question such as YouTube into 'Search' a list is produced.
    Clicking on any of the options offered returns a white screen with just 'Cancel' in the top left and the 'Search' (including entered search data) in the top right.
    I have tried restarting the App, signing out and back into iStore, doing a hard reset (full power down and back up), have cleared and re entered wifi connection information (even though all other aspects on the iPad 2 fully function). I cleared Safari Cookies and History, I've even reset the wifi router all to no avail.
    With in the App, 'Featured', Purchased', Updates, etc. function normally.
    Anyone have other ideas? It's as if Apple is blocking any returned search information.

    I'm having a very similar (or maybe the same) problem. Let me explain in detail and maybe someone, somewhere can help me.
    1.) I created and exported to iTunes a podcast called Studio 60Cast (for the new show Studio 60) using GarageBand.
    2.) I created and published a website with iWeb, and published the first and so far only episode of Studio 60Cast to that site.
    3.) I submitted the RSS feed (which, yes, worked when I tested it), and it only shows up on the store when I search using the exact words: Studio 60Cast. It does not come up when I simply search for Studio 60 (meaning, in podcasts, a bunch of one's that AREN'T MINE show up).
    4.) What might be the problem is that the author is listed as "unknown." Can anyone give me a step-by-step set of instructions on how to fix this?

  • How to find what values were passed onto a store procedure at the last run

    my web application is calling a store procedure but not returning the desired results in the ASP.net page
    when i execute the store procedure in sql server by providing the same values i get the desired result
    is there any way i could tell what values were passed onto the store procedure when it was called by the web page
    i am using sql server 2012 express 

    To add to the Profiler suggestion, you can also capture this information using Extended Events.  Below is a script example to capture RPC and batch completed events.  This can be done from the SSMS Object Explorer as well:
    --create ExtendedEvent session
    CREATE EVENT SESSION [ParameterTrace] ON SERVER
    ADD EVENT sqlserver.rpc_completed(
    ACTION(sqlserver.sql_text)),
    ADD EVENT sqlserver.sql_batch_completed(
    ACTION(sqlserver.sql_text))
    ADD TARGET package0.event_file(SET filename=N'C:\Temp\ParameterTrace.xel')
    WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF)
    GO
    --start session
    ALTER EVENT SESSION [ParameterTrace] ON SERVER
    STATE = START;
    GO
    --stop session
    ALTER EVENT SESSION [ParameterTrace] ON SERVER
    STATE = STOP;
    --query trace data
    SELECT CAST(event_data AS XML) AS event_data
    FROM sys.fn_xe_file_target_read_file(N'C:\temp\ParameterTrace*', default, default, default);
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • HOW TO EXECUTE A STORE PROCEDURE THAT RETURN MULTIPLE ROWS FROM A QUERY

    I NEED TO CREATE AND USE A STORE PROCEDURE THAT IS GOING TO DO A SELECT STATEMENT AN THE RESULT OF THE SELECT STATEMENT IS RETURN IN SOME WAY TO THE REQUESTER.
    THIS CALL IS MADE BY AN EXTERNAL LANGUAGE, NOT PL/SQL OR FORMS APPLICATION. USING FOR EXAMPLE ODBC AND VISUAL BASIC. WHAT I NEED TO DO IS ADD A DATA ACCESS LAYER TO MY APPLICATION AND I ALREADY HAVE IT DONE FOR MS SQL SERVER, BUT I NEED THE SAME FUNCTIONALITY ACCESSING AN ORACLE DATABASE.
    FLOW:
    1. VB CREATE A ODBC CONNECTION TO A ORACLE DATABASE
    2. VB EXECUTE A STORE PROCEDURE
    3. THE STORE PROCEDURE RETURNS TO THE VB APPLICATION THE RESULT OF THE QUERY THAT IS INSIDE OF THE STORE PROCEDURE.(I.E. THE STORE PROCEDURE IS A BASIC SELECT, NOTHING COMPLEX)
    4. VB DISPLAY THE RESULT IN A GRID
    FOR SURE I CAN DO THE SELECT DIRECTLY TO ORACLE, BUT FOR PERFORMANCE REASONS AND SCALABILITY, I'LL LIKE IT TO DO IT USING A STORE PROCUDURES
    IS THIS POSIBLE?, HOW?
    THANKS

    Certainly, it's possible. First, define a stored procedure that includes an OUT parameter which is a REF CURSOR. Then, call the stored procedure via ODBC omitting the OUT parameter from the list of parameters. IT will automatically be returned as a result set. Syntax for both is below...
    CREATE PROCEDURE foo (inParam in varchar2, resultSet OUT REF CURSOR )
    In ODBC:
    {call foo( 'someData' )}
    Justin

  • Help! Need oracle help with constructing stored procedure that return resultsets

    Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
    CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
    ResultSet rs = cs.executeQuery();
    Thats if you build your stored procedure something like this ...
    String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
    We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
    (p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
    is
    begin
    open p_cursor for
    select * from suppliers
    In which case the above mentioned sun code doesn't work.
    We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
    Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them?

    Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
    CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
    ResultSet rs = cs.executeQuery();
    Thats if you build your stored procedure something like this ...
    String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
    We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
    (p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
    is
    begin
    open p_cursor for
    select * from suppliers
    In which case the above mentioned sun code doesn't work.
    We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
    Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them?

  • Return package cursor from another store procedure

    Hello
    I’m new in Oracle, and I have the following problem:
    I have an cursor in a package defined like that:
    create or replace
    PACKAGE "TestPACKAGE" AS
    cursor DOWNLOAD_CURSOR is select A.* from Table1 A, Table2 B
    END TestPACKAGE;
    In reality there is more than one package with different cursors. I want to use that DOWNLOAD_CURSOR in a store procedure, function or another package, to return it to the client as a ref cursor.
    Something likes that:
    create or replace
    procedure aa_test (retCURSOR OUT sys_refcursor) is
    begin
    retCURSOR := TestPACKAGE.DOWNLOAD_CURSOR;
    end;
    or to replace that procedure with another method to return data, and use them in a .NET application.

    961449 wrote:
    Hello
    I’m new in Oracle, and I have the following problem:
    I have an cursor in a package defined like that:
    create or replace
    PACKAGE "TestPACKAGE" AS
    cursor DOWNLOAD_CURSOR is select A.* from Table1 A, Table2 B
    END TestPACKAGE;
    In reality there is more than one package with different cursors. I want to use that DOWNLOAD_CURSOR in a store procedure, function or another package, to return it to the client as a ref cursor.
    Something likes that:
    create or replace
    procedure aa_test (retCURSOR OUT sys_refcursor) is
    begin
    retCURSOR := TestPACKAGE.DOWNLOAD_CURSOR;
    end;
    or to replace that procedure with another method to return data, and use them in a .NET application.Static PL/SQL cursor declarations and Ref Cursors are not interchangable. You cannot return the static cursor definition as a ref cursor.
    See...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_rc sys_refcursor;
      3    cursor cur_emp is select * from emp;
      4  begin
      5    open v_rc for cur_emp;
      6* end;
    SQL> /
      open v_rc for cur_emp;
    ERROR at line 5:
    ORA-06550: line 5, column 17:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 5, column 3:
    PL/SQL: Statement ignored

  • Oralce Store Procedure not returning values in out parameters

    I am goig to execute an oracle store procedure using C# through through ODP.NET. The store procedure executes succsfully but it does not return any value in the out parameter.
    When I execute the same store procedure with the same input parameteres from within SQL*Plus. It does return values.
    This is to be clearify here that in the oracle store procedure the data type for the out parameter is number and in the c# the variavle that will hold its value is Integer. I also tried using Long on the C# side but it is still not working. After the successfull execution of the store procedure the C# variable contains nulll value.

    I am goig to execute an oracle store procedure using C# through through ODP.NET. The store procedure executes succsfully but it does not return any value in the out parameter.
    When I execute the same store procedure with the same input parameteres from within SQL*Plus. It does return values.
    This is to be clearify here that in the oracle store procedure the data type for the out parameter is number and in the c# the variavle that will hold its value is Integer. I also tried using Long on the C# side but it is still not working. After the successfull execution of the store procedure the C# variable contains nulll value.

  • Error while executing store procedure

    we are using JSQLConnect jdbc driver 3.0 verson.
    When we trued to excute store procedures its giving error like
    com.jnetdirect.jsql.w: Stored procedures called with static parameters cannot return output parameter values, please use CallableStatement.setXXX() to set the values of all input parameters.
    we are using SQLServer2000.
    Could anybody tell me why this is error is coming and how to solve this.
    Thanks
    Hemanth

    Obviously it doesn't like the stored procedure. If you posted the signature for that it might help.
    You are using a CallableStatement right?

  • Oracle JBDC error while calling the store procedure

    HI All,
    I am get one strange error while calling a store procedure which has two parameter in and out.
    I am pass the correct XML file which reaches the RDB and then PI receives a exception error message saying:
    oracle.rdb.jdbc.common.RdbException: Closed Resultset
    where as no error log is availble in RBD for the same.
    Can anybody tell me what can be the cause of the error.
    Let me know if you requires more information on this.
    -adi

    Hi Kiran,
    Thanks..
    But I am not able to understand you. I am calling a store procedure not a table. and we not doing anything in the store procedure except return one constant value in Out parameter.
    -Adi

  • What is wrong in my store procedure

    Hi all,
    I confuse on in ,out inout in store procedure , I got eroor at
    Formal parameter '@AccessionNumber' was defined as OUTPUT but the actual parameter not declared OUTPUT
    I use sql server 2000 and ms type 4 driver,
    my test store procedure is
    drop  proc test_select
    go     
    create proc test_select
    (@AccessionNumber int,
    @NewNum varchar(20))
    AS
            begin
        begin transaction
    select FieldNumber, Name, HiTiter, SubType, Storage,SampleRegion, SampleYear
            from STData.dbo.ViruName00          
         where AccessionNumber=@AccessionNumber      
            and NewNum=@NewNum
    if @@error <>0 or @@rowcount !=1
               begin
                    rollback
                   return
              end
           commit transaction
    endand my test servlet is
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import javax.sql.*;
    * TryJdbc.java
    * This servlet demonstrates using JDBC
    public class displayT1 extends HttpServlet {
        CallableStatement cs =null;
        ResultSet rs = null;
        Connection conn = null;
       * We want to initialized the JDBC connections here
        public void init()
            try{
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            catch( Exception e )
                e.printStackTrace();
       * This responds to an HTTP GET request.
        public void doGet(
        HttpServletRequest request,
        HttpServletResponse response)
        throws IOException, ServletException {
            response.setContentType("text/html");
        PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<head>");        
            try{
              conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433","test","1234");
            conn.setCatalog("STData");   
           //we made it!
            out.println("connection established sucessfully!");
               // register int OUT parameter
                cs = conn.prepareCall("{call test_select(?,?)}");
                  cs.setInt(1, 1);
                   cs.setString(2, "00-1");
    cs.registerOutParameter(1, Types.INTEGER);
         cs.registerOutParameter(2, Types.VARCHAR);
                     ResultSet rs = cs.executeQuery(); 
          out.println("<html>");
                         out.println("<body bgcolor=\"#d2eeff\">");                  
                         out.print("<table border=\"1\"  width=\"37%\"> "); //create an html table
                         out.print("<tr>");
                         out.print("<h2> Customers on the flight</h2>");
                         out.print("</tr>");                    
                         out.println("<tr><td>Name</td>");
                         out.println("<td>SubTYpe</td></tr>");
                           while(rs.next()) {
                             out.print("<tr>");
                              out.print("<td>"+ rs.getInt(1) +"</td>");
                               out.print("<td>"+ rs.getString(2) +"</td>");
                               out.print("</tr>");                             
                                }// end while
                      out.print("</table>");
                       out.print("</body></html>");
                       out.close();
          while(rs.next()) {
           String Name=rs.getString("Name");        
            out.print(""+Name+"");
             out.print("</body></html>");
              out.close();
         }catch(SQLException e) {
                e.printStackTrace(out);
         finally {
          try {
            if(rs != null)
              rs.close();
              rs = null;
            if(cs != null)
              cs.close();
              cs = null;
            if(conn != null)
              conn.close();
              conn = null;
        catch (SQLException e) {}   
    public void doPost(HttpServletRequest Request, HttpServletResponse Response)
                    throws ServletException, IOException {
    public String getServletInfo()
        return "A Simple Servlet";
    }and my AccessionNumber is first column, and NewNum is second column.
    appreciate any help!
    Thank you!

    HI all,
    html + bean + jsp call store procedure still not work, I got empty output!!
    what is wrong ?
    public  String getString(){
        return string;
    public void setString( String string ) {
       this.string =string;    }
    public  String getMyType(){
        return myType;
    public void setMyType( String myType ) {
       this.myType =myType;    }
    try {
                  cs = db.prepareCall("{call select_all(?,?)}");            
                   cs.setString(1, myType);
                   cs.setString(2, string); 
                     ResultSet rs = cs.executeQuery();         
            fieldNumberList.clear();
            nameList.clear();
            hiTiterList.clear();
            subTypeList.clear();
            storageList.clear();
            sampleRegionList.clear();      
            rowCount = 0;
            while (rs.next()) {
               fieldNumberList.add(rs.getString("FieldNumber"));
               nameList.add(rs.getString("Name"));
               hiTiterList.add(rs.getString("HiTiter"));   
               subTypeList.add(rs.getString("SubType"));
               storageList.add(rs.getString("Storage"));
               sampleRegionList.add(rs.getString("SampleRegion"));
               rowCount++;
              anyRecords = true;
            }//end while
          }//end trythe following code work in servlet
    cs = conn.prepareCall("{call select_all(?,?)}");
                   cs.setString(1, myType);
                   cs.setString(2, string); 
                     ResultSet rs = cs.executeQuery(); 
             thank you!

  • Problem with Pie chart, Store Procedure and Category Axis

    Hi All,
    I'm having a problem when i try to use a Pie Chart with a store procedure
    when Category Axis - Field value is "none", the chart appears, but the description say Undefined
    but when i put any field from store procedure, the chart doesn't show.
    when I try the same with a normal SQL statement, all data was displayed
    my store procedure only have 2 columns
    n - numeric
    state - text
    The Store Procedure and the SQL, returns the same data in the same order
    Thanks in advance
    Cristian

    Hi guys,
    I need guide on creating a system using store procedure, referring to this thread: JDBC System Connection VS BI JDBC System Connection
    Hope you can help me out.
    Thanks a lot,
    Sarah

  • Call store procedure wich have parameter from html

    Hi all,
    I have search function, which will allow users to select all database.
    I want to use stor procedure to handle this part , if it is a sample select procedure than just using
    CallableStatement cs = conn.prepareCall("{call SHow_SubType}");
                     ResultSet rs = cs.executeQuery();but if the store procedure have parameter
    like
    union 
    select FieldNumber, Name, HiTiter, SubType, Storage,SampleRegion, SampleYear
            from yunnan.dbo.ViruName04    
         where SubType like'%@SubType%'        
            and Name like'%@Name%'How can I call this stored procedure in my bean
    I have
    public String getName() {
        return name;
      public void setName(String _name) {
        name = _name;
    .....thankyou

    Hi ram,
    I try every hard, but still can't got result.
    my code is
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import javax.sql.*;
    * TryJdbc.java
    * This servlet demonstrates using JDBC
    public class displayT extends HttpServlet {
       CallableStatement cs = null;
        ResultSet rs = null;
        Connection conn = null;
       * We want to initialized the JDBC connections here
        public void init()
            try{
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            catch( Exception e )
                e.printStackTrace();
       * This responds to an HTTP GET request.
        public void doGet(
        HttpServletRequest req,
        HttpServletResponse response)
        throws IOException, ServletException {
           String string= req.getParameter("string").trim();             
           String Type =req.getParameter("myType").trim();
            response.setContentType("text/html");
        PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<head>");        
            try{
                conn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;selectMethod=cursor","test","1234" );
                DatabaseMetaData md = conn.getMetaData();
                //select a database
                conn.setCatalog("HKData");
           //we made it!
            out.println("connection established sucessfully!");
                CallableStatement cs = conn.prepareCall("call SHow_SubType(?,?)}");
                  cs.setString(1, "Dk");
                   cs.setString(2,"H5");
              // register int OUT parameter
         cs.registerOutParameter( 1, java.sql.Types.VARCHAR);
         cs.registerOutParameter( 2, java.sql.Types.VARCHAR);
                     ResultSet rs = cs.executeQuery();       
                  rs = (ResultSet)cs.getObject(1);
          while(rs.next()) {
          // String Name=rs.getString(2);    
           // out.print(""+Name+"");
           // out.print("br");
           System.out.println(rs.getString(1));
            out.print("</body></html>");
              out.close();
         cs = null;
    conn.close();
    conn = null;
    catch(NullPointerException sqle)
    sqle.printStackTrace();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println("error in finding class "+ex);
    public void doPost(HttpServletRequest Request, HttpServletResponse Response)
                    throws ServletException, IOException {
    public String getServletInfo()
        return "A Simple Servlet";
    }what is the psooible mistake , I use SQL2000.
    Thank you

  • Procedure/Function to return resultselt

    Hi guys,
    I'm new to writing PL SQL so i need a bit of help. I want to create a PL/SQL procedure/function to return a resultselt i.e. it will only have a select statement. No modifications etc will be done to the date. I tried seeing the online documentations but it was so detailed that it confused me.
    Also, what is the difference between a procedure and function. In oracle both can accept parameters and both can return values.
    How do i execute a procedure/Function from SQL Plus?
    Thanks in advance guys!

    For the difference between a function and a procedure, just look up any programming textbook or wikipedia at http://en.wikipedia.org/wiki/Function_%28computer_science%29.
    Looking something up in Wikipedia is quite easy, and doesn't require much effort.
    To return a resultset one basically uses a REF CURSOR.
    I'm quite sure this is discussed in the documentation, on Usenet, on http://asktom.oracle.com, on http://otn.oracle.com.
    As for your last question, please try to avoid asking such basic questions.
    You executing a procedure by embedding it in an anonymous PL/SQL block:
    begin
    <procedure>;
    end;
    or by using the sqlplus shortcut
    exec[ute] <procedure>
    One would ask whether you actually did read the manual or only looked at it.
    Sybrand Bakker
    Senior Oracle DBA

Maybe you are looking for