Oracle sequence from JSP

Hi,
I have to generate sequence numbers in Oracle and access it through my JSP page. For that i
created a sequnce in Oracle as:
create sequence trans_no increment by 1 start with 1 maxvalue 10000 minvalue 1;
and in my JSP page, the following code is given:
ResultSet resultSet=db.executeQuery("select trans_no.nextval from dual");
resultSet.next();
int transaction_no=resultSet.getInt("trans_no");
where db is my bean. But it is giving error. Is my code wrong? Please help.
Suman, Kochi

There is a mistake in mapping for ResultSet with the query you executed.
You have to modify either the query as
ResultSet resultSet=db.executeQuery("select trans_no trans_no.nextval from dual");
or have to change retreival from ResultSet to
int transaction_no=resultSet.getInt(1);
This should work now.
Try this and see...

Similar Messages

  • Unable to retrieve data from a nested table in Oracle 8i from JSP

    How do i retrieve data from a nested table in Oracle 8i from my JSP code?
    When i try to execute the query , a general error is thrown.
    Kindly advice as soon as possible.

    How do i retrieve data from a nested table in Oracle 8i from my JSP code?
    When i try to execute the query , a general error is thrown.
    Kindly advice as soon as possible.

  • Insert date time into oracle database from jsp

    pls tell me ,from jsp how can I insert datetime values into oracle database .I am using oracle 9i .here is codethat i have tried
    html--code
    <select name="date">
    <option selected>dd</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    </select>
    <select name="month">
    <option selected>dd</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    </select>
    <select name="year">
    <option selected>dd</option>
    <option>2004</option>
    <option>2005</option>
    <option>2006</option>
    <option>2007</option>
    </select>
    here the jsp code
    <% date= request.getParameter("date"); %>
    <% month= request.getParameter("month"); %>
    <% year= request.getParameter("year"); %>
    try
    { Class.forName("oracle.jdbc.driver.OracleDriver"); }
    catch (ClassNotFoundException exception)
    try
         Connection connection = null;
         out.println("connectiong the database");
    connection = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcsid","scott","tiger");
    out.println("connection getted");
         int rows = 0;
         String query_2 = "insert into mrdetails values(?)";
         String dob = date+month+year;
         prepstat = connection.prepareStatement(query_2);
         prepstat.setTimestamp(4,dob);
         rows = prepstat.executeUpdate();
         out.println("data updated");
    catch (Exception exception3)
    out.println("Exception raised"+exception3.toString());
    }

    To insert date values into a database, you should use java.sql.Date. If it also has a time component, then java.sql.TimeStamp.
    Your use of prepared statements is good.
    You just need to convert the parameters into a date.
    One way to do this is using java.text.SimpleDateFormat.
    int rows = 0;
    String query_2 = "insert into mrdetails values(?)";
    String dob = date+"/" + month+ "/" + year;
    SimpleDateFormat sdf = new SImpleDateFormat("dd/MM/yyyy");
    java.util.Date javaDate = sdf.parse(dob);
    java.sql.Date sqlDate = new java.sql.Date(javaDate .getTime);
    prepstat = connection.prepareStatement(query_2);
    prepstat.setTimestamp(4,sqlDate);
    rows = prepstat.executeUpdate();
    out.println("data updated");Cheers,
    evnafets

  • Calling oracle reports from jsp file

    how to pass parameters from jsp file oracle reports.i am getting reports wihtout passin parameters.
    pls help me
    urgent
    vasavadatta

    Karthik,
    You might want to repost this question to the reports forum - you'll be more likely to get a response from a reports expert.
    Thanks
    Blaise

  • Calling Oracle Reports from JSP/HTML

    Hi,
    We have a web application developed in JSP, I'd like to use Oracle Reports writer to generate reports (Since our back office application is developed using Oracle forms and Reports - 6i).
    I don't know how to place a request to Oracle Reports server and view the output. Can someone please help me with this.
    Thanks in advance.
    Best Regards,
    Karthik

    Karthik,
    You might want to repost this question to the reports forum - you'll be more likely to get a response from a reports expert.
    Thanks
    Blaise

  • How to invoke Oracle Reports from JSP ?

    Hi,
    I need to invoke Oracle Reports ( paper format ) from my JSP in different formats /PDF, RTF, HTML/ using rwservlet and then send the content to user browser.
    Please, someone to give me working example.
    Thanks in advance.
    Best regards.
    Peter.

    Peter,
    you can call it from a URL if you need:
    /reports/rwservlet?report=...&detype=cache&desformat=pdf...
    You can define a file called cgicmd.dat on teh server that takes key-value pairs of the most common parameters under an named entry.
    e.g.
    ReportsCommon: destype=cache server=myServer ... %*
    This way your URL is reduced to a minimum length because you don't have to list all parameters in teh URL.
    Second solution:
    Run a Reports from a browser URL and specify paramform=yes. This create a HTML based parameter form before executing teh Reports. Have a look at the HTML form code and see to what extend your Reports share same functionality so that you could create this HTML form in your JSP page. You could have a poplist with the name of "desformat" and list HTML, HTMLCSS,PDF,RTF,XML as valid entries so that the user can select the output format.
    The Reports documentation shipped with Oracle9iAS (also available online otn.oracle.com/products/reports) has all teh information you need.
    Frank

  • Launching a Discoverer report from jsp page

    Hi
    I have a discoverer workbook created using BI Discoverer (for relational). I want to accept some parameters for this workbook from a jsp page, which will also have a "View report" button. This button when pressed should open up the Discoverer workbook and all the parameters from the jsp should be passed to the workbook.
    Is it possible? If yes, any details on it?
    We do the same thing successfully to launch Oracle Reports from jsps, we simply build the url in the jsp, and from jsp we submit it to a new window, and it opens up the report. Similar functionality we are looking to launch Discoverer reports.
    Any help will be appreciated.
    Thanks
    Shalu

    You can open the workbook with URL parameters with Discoverer Viewer much like you would Oracle Reports. Setting anything form the username, password, workbook name, worksheet, and parameters. All the information can be found in the following document:
    http://download-east.oracle.com/docs/cd/B14099_11/bi.1012/b13918/urlstart.htm
    The specific question your asking is addressed under 13.5.2 Example 2. Let me know if you have any issues
    Matt Topper
    Technical Management Consultant
    TUSC, The Oracle Experts
    [email protected]

  • Conection from JSP

    Hi,
    I`m trying to connect to an oracle DB from JSP, i got the driver ojdbc14.zip, but i forced it to .jar, i`m using jdk 1.5 and Oracle9i Release 9.2.0.4.0 - Production, and my url connection string is: jdbc:oracle:thin:@//ALPHA21:1521/prod.
    the DB location is ALPHA21, the port is 1521 and the SID is prod but i got the following error:
    CONNECTION REFUSED(DESCRIPTION =(TMP=)(VSNNUM=153093120)(ERR=12514)(ERROR_STACK=( ERROR=(CODE=12514)(EMFI=4))))
    What can i do?
    i beg for help
    Thanks anyway

    Hello,
    double check the SID you are using. (tnsnames.ora)
    Check the listener if the prod instance is accepting connections.
    Issue the following command: lsnrctl status
    Regards, Marc

  • Calling Oracle JDBC Driver from JSP

    I have Apache Tomcat installed under Win2000 and can run simple JSP
    pages without any problems. I have installed Personal Oracle 9.0.1.0.1 on my win2000 PC and I can login using sqlplus as scott/tiger. The database is up.
    But when I try to access an Personal Oracle DB from a JSP page I get the following
    exception:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    root cause
    java.sql.SQLException: Io exception: Bad packet type
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    Here is my JSP program:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%@page language="java" import="java.sql.*"%>
    <%
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@<my host PC name>:8080:shark","scott","tiger");
    Statement stmt = conn.createStatement ();
    stmt.close();
    // Close the connection
    conn.close();
    %>
    Does anyone know why this error is showing up?
    Thanks

    Problem has been resolved. I did not have the Personal Oracle DB Listener running and the port needed to be changed to 1521 on the JSP program.

  • Calling custom OAF page from JSP page in Oracle apps

    Hi,
    I am working on a requirement to call a Custom OAF page from a JSP page in Oracle apps 11.5.10.
    I have registered the OAF page and defined a function for it. When we call this OAF page from JSP (without parameter), the page opens up
    URL: http://APPSURL:8020/OA_HTML/RF.jsp?function_id=27221&resp_id=50312&resp_appl_id=515&security_group_id=0&lang_code=US
    but as soon as I am trying to pass a parameter sr_id in the URL:
    http://APPSURL:8020/OA_HTML/RF.jsp?function_id=27221&resp_id=50312&resp_appl_id=515&security_group_id=0&lang_code=US&sr_id=106
    we are getting following error:
    You are trying to access a page that is no longer active.
    - The referring page may have come from a previous session. Please select Home to proceed.
    Please let me know if someone has faced the same problem...
    Thanks!!!

    Hi,
    Before calling a OAF page..from external JSP page...u need to set certain mandatory parameter like transaction Id and context.
    Regards,
    Gyan

  • Bulk Fetch From an Oracle Sequence

    I am trying to get a range of sequence values from an Oracle sequence.
    I am using the option as show below using query
    SELECT SEQUENCE_NAME.NEXTVAL FROM SYS.DUAL CONNECT BY LEVEL <= 10.
    The above SQL gets 10 sequence value.
    I just wanted to to check, if the implementation below is safe in a Multi User Environment?
    Is the statement show below atomic. i.e. Multi parallel execution of the same function; Would it cause any inconsistencies?
    EXECUTE IMMEDIATE 'SELECT SEQUENCE_NAME.NEXTVAL ' ||
      'FROM SYS.DUAL CONNECT BY LEVEL <= ' || TO_CHAR(i_quantity)
      BULK COLLECT INTO v_seq_list;
    FUNCTION select_sequence_nextval_range(
       i_quantity      IN  INTEGER)
    RETURN INTEGER IS
      o_nextval INTEGER;
      v_seq_list sequence_list;
    BEGIN
      EXECUTE IMMEDIATE 'SELECT SEQUENCE_NAME.NEXTVAL ' ||
      'FROM SYS.DUAL CONNECT BY LEVEL <= ' || TO_CHAR(i_quantity)
      BULK COLLECT INTO v_seq_list;
      -- Get the first poid value.
      o_nextval := v_seq_list(1);
      RETURN o_nextval;
    END select_sequence_nextval_range

    Acquire Lock
    You acquire a lock on a sequence? That's news to me - please post the code that does that. I certainly hope you don' t mean you are directly accessing the SYS.SEQ$ table to lock the row for that sequence - it isn't nice to mess with Oracle's tables!
    For couple of JAVA/C applications the usage of sequence number is pretty big. Could be 100,000 for one single application processing.
    How does that correlate with your previous statement that you get 10 at a time?
    Sequences aren't designed for use cases that require gap-free sets of numbers or for use cases that require consecutive sets of numbers.
    We wanted to implement the range get of sequence using a different mechanism.
    For few other applications; we just need one sequence number for the application processing. So we use the select seq.nextval to get the value. So the same sequence number needs to serve the role of giving a single value as well as a consecutive range of values.
    Then you may need to consider using your own table to track the chunks that need to be allocated. You would use a scheme similar to what Greg.Spall discussed except you would keep the 'chunk' data in your own table.
    I'm not talking about using your own table to control actual one-by-one sequence number generation - that is a very bad idea. But if you need to work with large ranges that are allocated infrequently there is nothing wrong with using your own function and your own table to keep track of those allocations.
    The 'one by one' number generation would be handled by an actual sequence. The generation of a 'start value' and an 'end value' would be handled by accessing your custom table. Each row in that table would have 'start_value' and 'available_numbers' colulmns.
    Your function would take a parameter for how many numbers you need. For just one number the function would call the sequence.nextval and return that along with a count of '1'.
    For a range the function would:
    1. find a row in the table with an 'available_numbers' value large enough to satisfy the request,
    2. lock the row for update
    3. capture the 'start_value' for return to the user
    4. adjust both the 'start_value' and 'available_numbers' values to account for the range being allocated
    5. update the table and commit
    6. return the 'start_value' and 'number_allocated' to the user (number_allocated might be LESS than requested perhaps)
    The above is a viable solution ONLY if the frequency of allocation and the size of allocation avoids the serialization issues associated with trying to allocate your own sequence numbers.
    Those issues can be somewhat mitigated by having the table store multiple rows with each row having a large chunk of values that can be allocated. Then your function query can get the first 'unlocked' row and avoid serializing just because one row is currently locked.

  • How to connect oracle database using DSN  from jsp

    hello, can any know how can i connect to[b] oracle database using DSN name from jsp .I am using oracle 9i and Tomcat 5
    Using odbc tool i have created the dsn name but ithe connection does not make .here is the code that i have tried
    Connection connection = null;
         try
              Class.forName("oracle.jdbc.driver.OracleDriver");
         catch(ClassNotFoundException Exception)
              out.println("error occoured during loading the driver ");
         try
              out.println("getting the connection");
              connection = DriverManager.getConnection("jdbc:oracle:deepak","scott","tiger");
              out.println("connection getted");
         catch(Exception exception1)
              out.println("error occoured ");
    pls help as soon as possible
    Sorry, for my english

    you are actually using JDBC so the DSN entry does not matter.
    2 things.
    Make sure that your oracle database driver is in your classpath on your tomcat server.
    I.E. copy the file classes12.jar into your common/lib folder of tomcat, or into your WEB-INF/lib folder of your application. and RESTART your server. classes12.jar can be found on the internet or more easily somewhere within your oracle installation. just search for it.
    Make sure your jdbc url is correct. I believe it goes like this.... fill in the blacks
    connection conn = DriverManager.getConnection("jdbc:oracle:thin:scott/tiger@MyOracleHost:1521:MyDB");Note how the username are passed in the first string there fore there is no need to pass additional parameters. This method may be depriciated, but if so, just take out the user and pass from the string and continue to pass them as 3 seperate strings.
    connection conn = DriverManager.getConnection("jdbc:oracle:thin:MyOracleHost:1521:MyDB","scott","tiger");That should get your connection. if not, post your errors.

  • How to store and retrieve blob data type in/from oracle database using JSP

    how to store and retrieve blob data type in/from oracle database using JSP and not using servlet
    thanks

    JSP? Why?
    start here: [http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html]

  • Calling Oracle Reports from WEB Pages(JSP)

    We are using Weblogic as the web server, Oracle 8i as the database and JSP(Java Server Pages) as the scripting language.
    We need reports to be invoked and displayed to the browser. Is it possible to invoke Oracle Reports 6i reports from JSP WEB pages and display the output to the browser? How can we do this and what are the additional s/w requirements, if any?
    null

    yes it is possible. There is a cgi script called viewreport.cgi. Have the jsp page call it (GET or POST method) and place the user parameters inside the form.

  • Mixing sun-database-binding with Oracle sequences

    Hello,
    I wish to insert rows inside the database, for instance rows representing persons, and rows representing their addresses. Primary keys for both person and address are Oracle sequence based.
    My question is, if I insert a person, then one of her address, how can I retrieve the person ID for the address row to reference it.
    The insert statement for the person is (for the moment) as follow
    insert into Person (PERSON_ID, FIRST_NAME, LAST_NAME) values (PERSON_SEQ.nextval, ?, ?)The problem with this approach is that I never know the person ID, and am unable to make any references to it in the address row.
    I tried to add an operation in the NetBeans generated person table WSDL. This operation would execute this statement:
    select PERSON_SEQ.nextval from dualBut, for the moment, it's a failure.
    Could you provide me with some hints?

    Hi,
    First I would advise you to register and post on the [email protected] alias - you can find the details of how to do this on the OpenESB site..... you'll reach a larger audience this way.
    Second, you need a Stored Procedure in Oracle to do this, then use this from the DB BC, here's one I created which does something similar, i.e. returns a value I'm interested in after an "Update" statement....
    CREATE OR REPLACE PROCEDURE "NEXTAPPNUMFINDER" (nextAppNum OUT NUMBER)
    IS
    BEGIN
    UPDATE ACTIVE_APPLICATION_NUMBER
    SET APPLICATION_NUMBER_NEXT = APPLICATION_NUMBER_NEXT + 1
    RETURNING APPLICATION_NUMBER_NEXT
    INTO nextAppNum;
    END;
    Hope this helps
    Mark

Maybe you are looking for

  • In the evaluation mode im nt able to view my ocr result for more than 2 seconds

    im doing my final year project on image processing using labview 2010(evaluation). im using a microsoft webcam(VX-700). my objective is character recognition using vision. im able to capture an image and store the same. the software also recognizes t

  • Need help getting my itunes library to work!!

    Recently my computer CRASHED.... it wouldn't let me into windows, it was pulling all kinds of error messages. So to fix the problem I wiped the system and reinstalled everything. However, now the Itunes that came with my Ipod doesnt work... So I came

  • How to transfer music from laptop to ipad

    I have music in my laptop in itune folder.How do I transfer music from itune in laptop to itune in ipad2.

  • Pie chart using Class cl_igs_chart ??

    Hi All, I am looking for Sample code, how to draw Pie chart using standard class: cl_igs_chart. I found a Standard SAP prog: GRAPHICS_IGS_CHART_TEST for drawing Bar chart, looking for pie chart now? Please help me!! Thanks in advance.

  • Timeout waiting for ARP/RARP stack underflow

    My U60 running solaris 10 crashed, and all I see on the screen is this: Timeout waiting for ARP/RARP stack underflow What does it mean?