How to isolate the Sql Statement from Java Code

Hi
I Need to know that can we segregate the Sql Statements and convert them to Stored Procedures so as to isolate the Sql statements from Java Code.
So i have one static web page which uses four select Statements so what i want is to create a stored procedure encapsulating these queries. So that the Java Web Developer will simply call the Stored Procedure instead of using four different SQL Statements.
Suppose the developer has these four Statements
Select ename,empno,sal,job from emp;
select empno,ename,mgr from emp;
select deptno,dname from dept;
select emp.ename,emp.empno,emp.deptno,dept,dname fromemp,dept;
So can i encapsulate these four Sql Statements in one Procedure and the Web developer can call the Store procedure and dont need to write the Sql Statements in his code.
Can Anybody guide me how to write this Stored type of Store procedure.
Thanks

http://www.google.com/search?q=java+windows+registry
Next time, search yourself. It might be beyond your belief, but you're really, really not the first person to wonder about this.

Similar Messages

  • How Can I Retrieve SQL Statement From The User ?

    Hi
    I want to know, how can I make the user can enter the SQL statement from himself ?? in this code he can't enter it. Only he can display the SQL that i wrote it...
    this is my Code:
    import java.sql.*;
    public class db_testing {
         static final String DRIVER = "com.mysql.jdbc.Driver";            
         static final String DATABASE_URL = "jdbc:mysql://localhost/S204111933";
         public static void main(String[] args) {
              Connection cn=null;
              Statement st= null;
              ResultSet rset=null;
              try{
                   Class.forName(DRIVER);
                   cn=DriverManager.getConnection(DATABASE_URL, "root", "admin");
                   st=cn.createStatement();
                   rset=st.executeQuery("select * from employee");
                   ResultSetMetaData metadata=rset.getMetaData();
                   System.out.println("The begining: ");
                   for(int i=1;i<=metadata.getColumnCount();i++)
                   System.out.print(metadata.getColumnName(i)+"\t");
                   System.out.println();
                   System.out.println();
                   while(rset.next()){
                   for(int i=1;i<=metadata.getColumnCount();i++)
                   System.out.print(rset.getObject(i)+"\t\t");
                   System.out.println();}
              catch(Exception e){
                   e.printStackTrace();
              finally{
                   try{
                   cn.close();
                   st.close();
                   rset.close();
                   catch(Exception e1){
                        e1.printStackTrace();
    }

    The following changes in the code will make the user to give the input
    import java.sql.*;
    public class db_testing {
    static final String DRIVER = "com.mysql.jdbc.Driver";
    static final String DATABASE_URL = "jdbc:mysql://localhost/S204111933";
    public static void main(String[] args) {
    Connection cn=null;
    Statement st= null;
    ResultSet rset=null;
    try{
    Class.forName(DRIVER);
    cn=DriverManager.getConnection(DATABASE_URL, "root", "admin");
    // st=cn.createStatement();
    // rset=st.executeQuery("select * from employee");
    PreparedStatement pstmt=null;
    pstmt=cn.prepareStatement("select * from employee where id=?");
    pstmt.setInt(1,Integer.parseInt(args[0]));
    rset=pstmt.executeQuery();
    ResultSetMetaData metadata=rset.getMetaData();
    System.out.println("The begining: ");
    for(int i=1;i<=metadata.getColumnCount();i++)
    System.out.print(metadata.getColumnName(i)+"\t");
    System.out.println();
    System.out.println();
    while(rset.next()){
    for(int i=1;i<=metadata.getColumnCount();i++)
    System.out.print(rset.getObject(i)+"\t\t");
    System.out.println();}
    catch(Exception e){
    e.printStackTrace();
    finally{
    try{
    cn.close();
    st.close();
    rset.close();
    catch(Exception e1){
    e1.printStackTrace();
    }

  • How to write the sql statement of my finder function in cmp?

    hi,
    I create a cmp ejb from table INFOCOLUMN,and I create a my finder function ,which sql statement is :
    select * from INFOCOLUMN WHERE employee_id=id
    employee_id is a column of the table,and id is the finder function parameter.
    The error is : invalid column name
    So,how to write the sql statement.
    Thanks .

    Mole-
    Bind variables are of the form $1, $2, etc., so your query stmt should look like:
    select * from INFOCOLUMN WHERE employee_id=$1
    -Jon

  • How to put the SQL-statement returned value into the field (as a default)

    Hi,
    I am using Developer/2000 (Forms Designer) under windows 98.
    Please tell me how to put the SQL-statement value (as a default value) into the field before enter-query mode. Noted that I have tried the following ways but still some problems:-
    1) Place the SQL-statement into PRE_QUERY trigger in the form/block level.
    There is a message box which ask 'Do you want to save the changes?'.
    2) Place the SQL-statement before execute enter_query. There is still a
    message box which ask 'Do you want to save the changes?'.
    Any hints? Thanks. Urgent.

    solved it!
    1) Suppress DEFAULT save message
    if form_failure then
    raise form_trigger_failure;
    end if;
    2) Place the default value before enter-query.
    Ref: Title='Default value in query field in ENTER_QUERY mode' in designer forum by CVZ
    form level trigger
    ============
    WHEN-NEW-ITEM-INSTANCE
    =======================
    if :system.mode = 'ENTER-QUERY' then
    :block.item := 'default waarde';
    end if;
    3) Suppress the changes whenever leaving the default field.
    if :block.item is null then
    -- assign statement
    end if;

  • How to call a .bat file from java code?

    How to call a .bat file from java code? and how can i pass parameters to that .bat file?
    Thanks in advance

    thanks for ur reply
    but still i am getting the same error.
    I am trying to run a .bat file of together tool, my code looks like below
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.File;
    class SysCall{
         public static void main(String args[]){
              String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
              //String path="D://Borland//Together6.2//bin//Together.bat ";
              Runtime r= Runtime.getRuntime(); //Declare the system call
              try{
                   System.out.println("Before batch is called");
                   Process p=r.exec(cmd);
                   System.out.println(" Exit value =" + p.exitValue());
                   System.out.println("After batch is called");
              /*can produce errors which must be caught*/
              catch(Exception e) {
                   e.printStackTrace();
                   System.out.println (e.toString());
    I am getting the below exception
    Before batch is called
    java.lang.IllegalThreadStateException: process has not exited
    at java.lang.Win32Process.exitValue(Native Method)
    at SysCall.main(SysCall.java:17)
    java.lang.IllegalThreadStateException: process has not exited

  • Clear the Filter Criteria from java code programmatically

    Hi All,
    I am using jdev version 11.1.1.6.0.
    I do have ADF table for which I have added filter to each column .
    I created table using java class data control.
    Filter is working Fine .
    My use case is-
    When I click on search button data is populated in table.
    When anybody enters filter value in column suppose product and hit enter ,it filters data.
    if he clears and do not hit enter key and search again then it does not show all data it only show filtered data.
    So how can I programmatically clear all filters so on click of  search it will show all the values not filtered values.
    I have not used default Filter Behavior.
    Please check below code for reference
      <af:table value="#{bindings.AfMyAccOrderStatusHistorySearchVO.rangeSet}"
                                  var="row"
                                  rows="#{bindings.AfMyAccOrderStatusHistorySearchVO.rangeSize}"
                                  emptyText="#{bindings.AfMyAccOrderStatusHistorySearchVO.viewable ? 'No data to display.' : 'Access Denied.'}"
                                  fetchSize="#{bindings.AfMyAccOrderStatusHistorySearchVO.rangeSize}"
                                  rowBandingInterval="0" id="tblStatusHistoryList"
                                  autoHeightRows="#{bindings.AfMyAccOrderStatusHistorySearchVO.rangeSize}"
                                  rowSelection="single"      
                                  width="100%"
                                  partialTriggers="::cb5 ::cb8 ::cb1 ::cb2"
                                  filterModel="#{bindings.AfMyAccOrderStatusHistorySearchVO1Query.queryDescriptor}"
                                  queryListener="#{bindings.AfMyAccOrderStatusHistorySearchVO1Query.processQuery}"
                                  filterVisible="true" varStatus="vs"
                                  binding="#{AfMyAccOrderStatusHistoryAction.orderStatusHistorySearchList}">
    <af:column headerText="#{alfaprojectBundle['ordstatushistory.column.invoiceDate']}"
                                      width="70"
                                      sortProperty="invoiceDate"
                                      sortable="true" filterable="true"
                                      id="c7" filterFeatures="caseInsensitive">
                              <af:outputText value="#{row.invoiceDate}" id="ot16"/>
                            </af:column>                     
                            <af:column headerText="#{alfaprojectBundle['ordstatushistory.column.soldto']}"
                                       width="100"   
                                       sortProperty="soldTo"
                                       sortable="true" filterable="true"
                                       id="c14" filterFeatures="caseInsensitive">
                              <af:outputText value="#{row.soldTo}"
                                             visible="#{row.visibilityIsOrdrFirstItem}"
                                             id="ot23"/>
                            </af:column>
    So how to clear all filter values from java code.

    I can't get the example "Programmatically Manipulating a Table's QBE Filter Fields"
    Where is it ?
    https://smuenchadf.samplecode.oracle.com/samples/ClearTableColumnFilterFields.zip
    Thks

  • Convert SQL statements to JAVA Code ?

    Using SQL queries Can I convert SQL statements to JAVA Code ?
    Edited by: user11238895 on Jun 7, 2009 10:54 PM
    Edited by: user11238895 on Jun 7, 2009 11:12 PM

    Me very new to Oracle.
    can we convert SQL Queries to JAVA Code using simple built in SQL queries ?
    Which SWISS SQL Tool does [Converting SQL Queries to JAVA Code]

  • How to find the  System Dbtype in java code

    How to find the System Dbtype in java code
    I need various Db connection my project (oracle, sq l,sybase,db2),So How to find the System Dbtype in java code

    Welcome to the Forums.
    Please go through the FAQ of the Forum.
    You has posted your query in the wrong Forum, this one is dedicated to Oracle Forms.
    Please try {forum:id=1050}.
    Regards,

  • Pleasse How To  Compute Spaces in Statement (by JAVA code)

    hi
    Please can you help me ;
    How To Compute Spaces in Statement (by JAVA code) .
    Best Regards;

    Hi,
    can you be more specific? What statement? If it is a string you can use a String buffer and add spaces to wherever you want within a string.
    Frank

  • How to view the SQL statement generated during execution of the BW Query?

    Dear Experts,
    I am trying to retrieve data in a SAP BW Query from a Non-SAP system.
    I think if I am able to see the complete SQL statement that was generated when I executed the BW Query, I may be able to use it to retrieve the data.
    Do you know how and where I can see the SQL statement of a BW Query's SQL statement?
    I tried RSRT options to execute the Query but still could not find the SQL statement.
    Thanks in advance.
    Regards,
    Shunhui.

    hi
    goto rsrt
    give your query name
    select execute + debug option
    in the debug option under data manager check the check box "display SQL/BIA query
    selcet continue
    you can see the sql statement
    thanq

  • How to get the SQL statement

    I cannot figure how to get the text(SQL statement) from a system view(i guess it is in a system view... but witch??). 'Till now i have the sql_address and the sql_hash_value..
    I know it is possible.. EM does it ... so i should be able to do the same..
    ps:I use 9.2

    v$sql ?

  • How could I investigate SQL statement from standard audit record ?

    We use Oracle 11gR2.
    We use standard audit , audit_trail=DB.
    We found suspicious audit record but that  SQL_BIND,SQL_TEXT colums were NULL.
    How could I investigate that SQL statement from standard audit record ?

    Only "DB, EXTENDED" would cause the SQL statement to be captured.
    If you have the Diagnostics Pack licence you could try querying DBA_HIST_SQLTEXT (joined to DBA_HIST_SNAPSHOT) -- but this would only list SQLs captured by AWR (i.e. the "Top 'N'" SQLs in that snapshot).
    Hemant K Chitale

  • How to monitor the sql statement running?

    Hi ,
    i need to check the status of the sql script running on the database.
    what is the way to chect that?
    if the particular query is taking very long time what might be the reason?

    Since you are [relatively] new at this ..
    the recommended technique will change based on version of Oracle database, the edition of the database, the options of the database and the operating system.
    For example, I would normally suggest a newbie with Oracle Database 10g or 11g Enterprise Edition to use the Enterprise Manager Diagnostics Pack. A demo thereof is on the Oracle BY Example site (http://otn.oracle.com) - look for Tutorials towards the top.
    As for why ... it's waiting on things. Which things may depend on the database, the operating system, the disk subsystem, the network subsystem, memory allocation, sorting, other load, and even how well or badly the SQL statement was written.

  • Get an set the SQL statement from a report at runtime

    i know there is an opportunity to filter the records by using setRecordSelectionFormula() method...but i wondered if you can anyhow get the whole SQL statement that is in the report. i think it would be very useful for many developers to maipulate the SQL directly like you were able to using the PE-functions in the old CRPE32.DLL...
    but in CR XI the CRPE32.DLL is no longer supported. now we have to substitute these functions with the JRC but i am not sure if it provides everything we had in the CRPE32.DLL...
    after all i do not understand why the CRPE32.DLL is still delivered but not supported. in my CR XI R2 installtion i found this file signed with version 11.5.3.438
    by the way it is a question of performance...a query would be faster if you could directly query the database by changing the reports sql statement instead of allowing the report to retrieve all data and then performing the filtering.
    so please, for the next version of the JRC give us the opportunity to get an set the sql statement of a report directly!

    Not an option. crpe32 is proprietory and the SQL we generate is to complex to assume it will be done correctly. Which is why the ability was removed

  • Executing a DDL statement from java code

    Hi all,
    this is code from jdev11.1.1.3 version. I am trying to execute a DDL statement in oracle db from java code, but "ORA-00900: invalid SQL statement" error is coming.
    I am trying to create a table in same schema in same db by using 'Copy' command.
    Same DDL command is executing from sql command prompt & table is being created. Plz help me , as how to do from java?
            public String cmb_action() {
            // Add event code here...
            try {
                //getting source db connection
                InitialContext initialContext = new InitialContext();
                DataSource ds = (DataSource) initialContext.lookup("java:comp/env/jdbc/SourceConnDS");
                Connection sourceconn = ds.getConnection();
                sourceconn.setAutoCommit(false);
                String sql = "Copy from myschema/mypass@DB insert t_dept using select * from dept;"                       
                Statement stat = sourceconn.createStatement();
                stat.executeUpdate(sql);
                sourceconn.commit();
                System.out.println("done");
              catch (Exception ne) {
                // TODO: Add catch code
                ne.printStackTrace();
            return null;
        }

    I have a requirement to transfer data from one db to another db from Java Application Layer.Maybe, maye not. We get all sorts of weird "requirements" - which are nothing but thoughts or proposed solutions.
    But,
    Did the "requirement" mention whether the table existed already or not in the target database? - If not, did it tell you to create it - drop/create it?
    Did the "requirement" deliver some explanation to why this copying was neeeded? - Are we talking replication? - Or a one time cloning?
    Etc, etc,
    Personally I would always argue against a "reuirement" like that. - It just isn't the way to do it. Period.
    Regards
    Peter
    P.S: If you are satisfied with what COPY does, then you could let Java make an OS call and do it from there?

Maybe you are looking for

  • Acrobat 7 quits on printing Windows XP SP3

    Hi all Anytime I try to print a PDF from Acrobat it quits. I get an obscure memory reference error message. It's with any PDF, wheter I generate it from InDesign (printing to pdf or exporting) And it happens with PDFs I haven't created. I tried the D

  • How can I fix blank spots and missing images with firefox

    I type in pch.com for instance and the image doesn't appear and when I hit begin It shows me spaces for names address etc. but there is no submit box. I can click where it should be and it works. On yahoo themes, All the squares are white. If I point

  • Skype rejects payment cards, even from Target

    YES rejects all cards (Banks hate Skype for some reason cause it's outside the US); Bought another Skype Card at Target in the US and tried to apply it to paying for my phone # renewal (I get very few calls a year so I don't really need it but it is

  • Invoice List Header text disabled (VF22) and note 357732 missing

    1. Can any body please let me know the Invoice List text Determination? Presently, My Invoice list screen is showing the Header text tab is disable, if possible please let me know how to do enable so that I can enter into the Text. 2.  I checked SAP

  • BEX  large amount of filter values

    We have BEX Reports within webtemplates for the users. They want to filter a large amount of values (about 100)for e.g. the materialnumber. The materialnumbers for the filter differ from day to day. Does anybody know how it is possible to add so many