Help needed in SQL Loader-Urgent..!

Hi All,
I am having a staging table with 4 columns, I have to insert
values in 3 of the columns from a CSV file using SQl Loader( The
CSV file has only 3 columns in it) and a default value has to be
inserted in to the 4th column.How can I attain this?? Can I have
this default
value logic written in the Control file used for the data insert? If
yes, Please tell me how..
Thanks,
Vidya

did you refer the doc before posting this question?
http://download.oracle.com/docs/cd/B10501_01/server.920/a96652/toc.htm

Similar Messages

  • Expert Help needed with Sql Loader !

    Hello Friends...I am using one .dat file that contains several values in a
    particular column and I need to load those values in different tables with
    sqlloader.....For example: in column 3 there are values 0001, 0004, 0007, 9999
    ..> values 0001 and 0004 need to be loaded into table1 and value 0007 is
    loaded into table2 and value 9999 needs to be loaded into table3.
    I can successfully use the when clause to load one value at a time but
    cannot load a range or multiple values during the sqlloader load. I can
    call and run separate .ctl files but less complexity and fewer files would
    be better. Tried everything I know but no luck, can't do loads in same
    .ctl file......Does the when clause have limitations whereby only one value
    at a time can evaluated as True or False ?
    I would like to do a Not or InBetween evaluations if possible on that
    single coulmn and then do the loads in the specific tables.
    Any help would be appreciated as I can see my hair turn grayer by the
    minute..My thanks in advance..

    You're asking sql*load to perform an unnatural act.
    Load in you dat file as-is. Create a pl/sql procedure to do the rest.
    Your batch script calls sql*load, then sql*plus to run the proc.
    Must simpler. sql*load is not a procedural language.

  • Help needed in SQL Loader

    Hi,
    Am using SQL Loader to insert rows in a table.
    I have 5 cols in table A. But the data is not present in all cols always.
    Have used TRAILING NULLCOLS but with no help.. few rows are inserted and for many others it throws "ORA-01841: (full) year must be between -4713 and +9999, and not be 0" error
    (because the value is null in that particular column position)
    How do I handle such cases.Please help asap.
    FYI -
    CONTROL FILE
    load data
    infile '/home/krkanth/test_spam_20070513.dat'
    BADFILE 'sample.bad'
    DISCARDFILE 'sample.dsc'
    into table spam_rule_stats
    fields terminated by "\t"
    optionally enclosed by '"'
    TRAILING NULLCOLS
    (MAIL_DATE date 'yyyymmdd hh24:mi:ss', METRIC_TYPE, HEURISTIC_TYPE, HEURISTIC_VALUE, REJECTION_COUNT,
    RULE_START_DATE DATE 'yyyymmdd hh24:mi:ss',
    RULE_END_DATE date 'yyyymmdd hh24:mi:ss',SOURCE)
    Am getting error Rejected - Error on table SPAM_RULE_STATS, column RULE_END_DATE.
    ORA-01841: (full) year must be between -4713 and +9999, and not be 0
    SAMPLE DATA
    20070513 RULE SENDER [email protected] 534 20070214 22:02:56
    SnA_ALERTS
    20070513 RULE SENDER [email protected] 6 20070503 21:19:36 200
    70518 21:19:36 RULE_EXTENSIONS
    20070513 RULE SENDER [email protected] 519 20061105 05:40:44 SnA
    _ALERTS
    20070513 RULE SENDER [email protected] 332 20070509 02:44:51 20070524 02
    :44:51 JASD_HP_AUTOREJECT
    20070513 RULE SENDER [email protected] 928 20070512 14:49:14 20070527 14:49:14 JAS
    D_HP_AUTOREJECT
    20070513 RULE SENDER [email protected] 19875 20070507 22:30:01 20070522 22
    :30:01 RULE_EXTENSIONS
    20070513 RULE SENDER [email protected] 3 20070509 09:08:38 20070524 09:08:38
    JASD_HP_AUTOREJECT
    20070513 RULE SENDER [email protected] 10 20070503 21:19:36 200
    70518 21:19:36 RULE_EXTENSIONS
    20070513 RULE SENDER [email protected] 4 20070506 04:39:48 20070521 04
    :39:48 JASD_HP_AUTOREJECT
    Thanks.

    not sure if this will work but you may want to give it a try:
      change from:
        (MAIL_DATE date 'yyyymmdd hh24:mi:ss'
      to:
        (MAIL_DATE date 'yyyymmdd'since the first data on your file does not have the timestamps

  • Help Needed regarding SQL Loader Error

    Hi,
    I am trying to insert some records into two tables using same control file.
    I am using the follwing command to load data
    sqlload "$ORAUSER" CONTROL="$LDRFILE" DATA="$DATA_PATH/$DATA_FILE" BAD="$BAD_FILE" LOG="$LOG_FILE" DISCARD="$DISCARD_FILE" ERRORS="$MAX_ERRS"
    I am getting the error: SQL-LOADER - 350: Illegal combination of non-alphanumeric characters
    #!/bin/ksh
    Please suggest me what I need to do.
    Thanks,
    Srinivas.

    it appears that you are using this line code in your korn shell script. if you try to do a manual run on the unix command line do you still get the same error?
    also can you post a sample value for all the parameters you have.

  • Help needed on SQL*LOADER

    Hi,
    I am using oracle 8i for Windows release 8.1.7.
    I have a data feed file 'XYZ.ctl' which contains numerous records.Each record is having various data. This data is subdivided into fields seprated by '~'.
    Each field can be of variable length. Thus my data per line is represented as below:
    1)A~BG~1223~023456~AW3456DF~001~desc1~002~desc2~~~~~~~~~~~~
    2)A~MN~1423~073453~AW56DF~001~desc11~002~desc22~003~desc33~~~~~~~~~~~~~~~~~~
    Here the point that is to be noted is each field ends with '~'.
    Now I would like to push data from 'A' to 'AW3456DF' of 'record 1' to Table X and from there on i.e from '001' to 'desc2' to Table Y.
    Similarly for record 2 I would like to push data from 'A' to 'AW56DF' to Table X and from there on i.e from '001' to 'desc33' to Table Y.
    This has to be achieved through SQL*Loader. Can it be achieved? If not then is there another way? Actually much of the loading that is done in production is already present and working fine. We just need to implement
    the above functionality.
    Another point is that the numeric part i.e. '001' would go in column 'Col1'and the description part i.e 'desc1' would go in column 'Col2' of table Y.
    Please let me know if anything could be done.
    Thanking in advance.
    Rajeev

    UTL_FILE
    With the UTL_FILE package, your PL/SQL programs can read and write operating system text files. UTL_FILE provides a restricted version of operating system stream file I/O.
    UTL_FILE I/O capabilities are similar to standard operating system stream file I/O (OPEN, GET, PUT, CLOSE) capabilities, but with some limitations. For example, you call the FOPEN function to return a file handle, which you use in subsequent calls to GET_LINE or PUT to perform stream I/O to a file. When file I/O is done, you call FCLOSE to complete any output and free resources associated with the file.
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_file.htm#ARPLS069
    Joel P�rez

  • Need help to run sql loader from Form6i

    Hi All,
    I have some problem with the sql loader running from form 6i.
    I have done following steps for that.
    1. have created bat file to run sql loader.
    2.Alos created ctl and txt files inside the same folder.
    In the form , in button press i have written below code
    HOST('cmd /c C:\load1.bat > C:\output.txt');
    But it is giving error as -
    "Unable to open Load1.ctl."
    but i have run that bat files from command prompt ; and it is running fine.
    I guess probably it is not getting the correct path.
    Will pls help me, wt exacly I'm doing wrong?
    Rg,
    Subir

    Hi Francois,
    Thanks for reply.
    It is not a problem with the batch files. Coz, I just able to run batch files, but that is not correct solution.
    Once the host command id firing, that time it is going to path -
    "c:\orant\Form60\"
    And in this path it searching for that batch files and all the require files; but the require files are present in some different folder. So i think I need to change the path as well, but that I'm unable to do.
    To resolve the problem, I have copied all the files in "c:\orant\Form60\" folder, and then it is working.
    So I think I need to changed the path, so how to change the path. If I able to change the path I think it will worked. How to change the path?
    Best Rg,
    Subir

  • Help needed in importing application -  Urgent

    Hi,
    I am new fairly new to apex and would be grateful for any help....
    I have an application that i would like to import and install... but i am obtaining an error...
    Situation is as follows:
    Application in machine A with oracle 10g standard and apex 3.0. Workspace is portal, schema is status_portal...
    export is working fine.
    Need to import it to machine B with oracle 10g and apex 3.0 Workspace is
    online_portal, schema is portal
    Import also works fine...
    But when i try to install the imported application, i get following error:
    ORA-20001: GET_BLOCK Error. ORA-20001: Execution of the statement was unsuccessful. ORA-02291: integrity constraint (FLOWS_030000.WWV_FLOWS_FK) violated - parent key not found <pre>begin wwv_flow_api.create_flow( p_id =&gt;134, p_display_id=&gt;134, p_owner =&gt; 'STATUS_PORTAL', p_name =&gt; 'Status Portal', p_alias =&gt; 'F114', p_page_view_logging =&gt; 'YES', p_default_page_template=&gt; 3865804637029456 + wwv_flow_api.g_id_offset, p_printer_fri
    Please guide me as to what to do....
    History:
    I have tried exporting from machine A to apex online workspace and installing there.... and vice versa...It is working fine...
    the problem arises only when i try import & install on machine B....
    Please help me.... i need to do this urgently
    Thanks,
    Sumana

    Hi Scott,
    I will not be able to show the actual application, as it has our customer's information. But i have created a sample application and done the export and import. The details are as follows:
    Machine A Details:
    Workspace name = portal
    worskspace ID = 3727029916111535
    schema = status_portal
    Exported Application Name = Status Portal
    Exported Application ID = 117
    When importing application from machine A to online workspace:
    Online Workspace Details: (when importing application 117)
    Workspace Name = sumana
    Workspace iD = 3033192431425185475
    schema = sumanadb
    Imported Application Name = Status Portal
    Imported Application IS = 42146
    You can access the workspace using: http://apex.oracle.com/pls/otn/f?p=4550:1:
    the password is sumi123
    When importing application from machine A:
    Machine B Details:
    1 ) Workspace1 Name = auditws
    workspace ID = 7048503433678645
    schema = audit_schema
    When installing imported application no 117 I get:
    ORA-20001: GET_BLOCK Error. ORA-20001: Execution of the statement was unsuccessful.
    ORA-02291: integrity constraint (FLOWS_030000.WWV_FLOWS_FK) violated - parent key not
    found <pre>begin wwv_flow_api.create_flow( p_id =>129, p_display_id=>129, p_owner =>
    'STATUS_PORTAL', p_name => 'Status Portal', p_alias => 'F114117', p_page_view_logging =>
    'YES', p_default_page_template=> 10898936714426385 + wwv_flow_api.g_id_offset, p_printer
    Error installing application.
    Return to application.
    2) Workspace2 name = online_portal
    workspace ID = 9302626026712423
    schema = portal
    When installing imported application no 117 I get:
    ORA-20001: GET_BLOCK Error. ORA-20001: Execution of the statement was unsuccessful.
    ORA-02291: integrity constraint (FLOWS_030000.WWV_FLOWS_FK) violated - parent key not found
    <pre>begin wwv_flow_api.create_flow( p_id =>159, p_display_id=>159, p_owner => 'STATUS_PORTAL',
    p_name => 'Status Portal', p_alias => 'F114117', p_page_view_logging => 'YES',
    p_default_page_template=> 10898936714426385 + wwv_flow_api.g_id_offset, p_printer
    Error installing application.
    Return to application.
    3) When importing application no 130 from machine B to machine B
    (from workspace auditws and schema audit_schema to workspace online_portal and schema portal)
    I get the error as said before
    "Access Denied by application security check" Also, i observed that,
    the application gets installed in auditws and audit_schema itself...
    Screenshots are here:
    4) when importing application no 130 from auditws back to auditws, it works fine.

  • Help Needed in SQL QPAC

    Hi there,
    I need some help regarding the SQL QPAC which is a built in QPAC in Adobe Livecycle Workflow. The SQL QPAC takes MYSQL as the default database. Suppose if we need to connect to the SQL Server or any other database, what is the procedure to do that.
    Suraj

    Hi Suraj
    You need to deploy a second copy of the SQL QPAC, and point it at a different datasource. The datasource is defined as a deployment parameter (it will prompt you when you deploy the new version of the qpac).
    You will also need to define the datasource in your application server. This is done in different ways for different application servers - for details, please see: standards_based_qpacs.pdf (part of the Workflow SDK), page 12, "Creating a JNDI datasource".
    Alternately, you can try out our SQLPlus QPAC. This allows you to directly specify connection url, driver, username and password. The SQLPlus QPAC does a lot of other things that the regular SQL QPAC doesn't do, such as handling multiple rows, testing your query, and outputting the data in a variety of ways.
    Details at: http://www.avoka.com/avoka/qpac_library.shtml
    Howard

  • Help in calling sql loader and an oracle procedure in a script

    Hi Guru's
    please help me in writing an unix script which will call sql loader and also an oracle procedure..
    i wrote an script which is as follows.
    !/bin/sh
    clear
    #export ORACLE_SID='HOBS2'
    sqlldr USERID=load/ps94mfo16 CONTROL=test_nica.ctl LOG=test_nica.log
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    sqlplus USERID=load/ps94mfo16 << EOF
    EXEC DO_TEST_SHELL_SCRIPT
    it is loading the data in to an oracle table
    but the procedure is not executed..
    any valuable suggestion is highly appriciated..
    Cheers

    multiple duplicate threads:
    to call an oracle procedure and sql loader in an unix script
    Re: Can some one help he sql loader issue.

  • Help required in SQL Loader

    Is it possible to load a single target file from multiple flat file sequentially using SQL Loader?
    Example -
    Table structure -
    <Emp_id><Emp_Name><Dept_id><Total_sales><Commission>
    <Emp_id><Emp_Name><Dept_id> column will be load from Emp_master flat file
    <Total_sales> column will be load from sales flat file - there will be two fields emp_id and total_sales
    <Commission> column will be load from commission flat file - there will be two fields emp_id and commission.
    I have tried this to merge these three flat file and create a single flat file, but in my real requirement i found it is quite tedious.
    Is there any other approach?
    Thanks in Advance

    You can load into 3 temporary tables and insert into main table using a query
    OR
    You can use shell script (I hope UNIX environment) to merge the files
    There is no direct way to load the data for same row from multiple files using SQL * Loader

  • VCM installation help needed on SQL DB and Reporting server

    Hi All,
    I'm new to VCM and now i got stuck at the SQL DB and Report server portion.
    I'm running the vcm server on VM and the SQL is a physical server, both are sitting on the same LAN.
    I have create the SQL DB but VCM just fail to validate the DB and report server.
    I login to VCM using a Domain account for installation, and i tried to testing the DB using ODBC from the window, result fail.
    Error message as attach.
    I'm now totally lost on SQL portion.
    My Question:
    Is there any configuration needed on SQL DB?
    How to get the reporting server to working?
    What port is needed to it all working??
    VCM server Ms Win2012.
    SQL version 2012.
    Many thanks to all who reply.

    Hi Simonhoo79,
    For SSRS,   first check whether the report server link is accessible from your browser : "http://s01-fes-vcm1:80/ReportServer" . If you continue to get 404 error there also, then you need to reconfigure you report server first before proceeding to vcm installation. Follow the steps on below link on how to reconfigure report server using report services configuration Manager for 404 error.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/75910bcb-a879-4eb7-9757-acc45201fa3a/can-not-connect-to-reportserver-http-404-file-not-found?forum=sqlexpress
    For SQL server ODBC connection,
    Dont create ODBC connection for SQL Native Client. Create ODBC connection for SQL Server.
    1. Open ODBC Data Source Administrator
    2. Click User DSN tab and Click Add button.
    3. Select SQL server and click finish
    4. Give name and description and Give the SQL server name (with instance name if your using named instance) or IP in the Server text box.
    5. Click Next and select either Windows authentication or sql authentication based on your SQL server authentication mode and click next.
    6. If the details given are correct then it will proceed further and  check "Change the dafault database to" to your VCM database
    7. Click next and finish and try test data source.
    VCM 5.7.2 and below will support installation only on windows server 2008 R2  and it doesn't support windows server 2012  but it support both 2008 and 2012 sql servers.

  • SQL Loader Urgent

    We want to load two tables from one file simultaneously from one comma separated data file. These tables has Master-Detail relation. Each row in the text file contain all the fields for Master Table and in some field fields of Detail table and data in text file is stored as Concatenated string ~ separated.
    Text file
    1, Sinatra, Jalora, Concatenated~String~Separated,11.00
    Mater Table
    1, Sinatra, Jalora, 11.0
    Detail table
    1, Concatenated
    1, String
    1, Separated
    We want to call a function in SQL Loader to insert into Detail Table. If Yes Then How??
    null

    Hi Sanya
    I don't now technique in SQLLodar how get detail table, but you can try another technique trouhg trigger.
    Look this :
    1. This is base tables
    create table masterT (id number primary key,Fname varchar2(40),Lname varchar2(40),value number(10,2));
    create table detailT1 (id number primary key,masterT_id number references masterT(id),text varchar2(80));
    2. This is fictive table a his trigger
    create table xxx ( id number primary key, Fname varchar2(40), Lname varchar2(40), text varchar2(2000), value number(10,2));
    create or replace trigger tg_xxx_i
    before insert on xxx for each row
    declare
    lm number := 1;
    ln number := 1;
    lx varchar2(2000);
    lmastert_id number;
    begin
    insert into masterT values (:new.id,:new.fname,:new.lname,:new.value);
    lx := :new.text;
    lm := instr(lx,'~',ln);
    while lm > 0 loop
    insert into detailT1 values (seqdetailT1.Nextval(),mastert_id,substr(lx,ln,lm-ln));
    ln := lm + 1;
    lm := instr(lx,'~',ln);
    end loop;
    insert into detailT1 values (seqdetailT1.Nextval(),:new.mastert_id,substr(lx,ln,2000));
    end;
    ed
    null

  • Need help in using sql loader

    Hi,
    I am using sqlloader to load data from csv file to a table. csv file format is as below. And the condition is to load only data from locations DHL and ABC
    item loc scheddate qty
    10000001     DHL     7/13/2011     100
    1000002     DHL     7/14/2011     10
    101     ABC     7/15/2011     1000
    10000002     ABC     7/16/2011     100
    100 X 7/16/2011 0
    and I am loading into table tab1
    (note: there are few other cols which are nullable and don't want to isnert them)
    here is the code I have written
    LOAD DATA
    INFILE file1.csv'
    REPLACE
    INTO TABLE tab1
    WHEN (LOC = 'DHL')
    FIELDS TERMINATED BY ","
    TRAILING NULLCOLS
    ITEM,
    LOC,
    SCHEDDATE DATE "MM/DD/YYYY",
    QTY,
    EXPDATE DATE (:SCHEDDATE,'MM/DD/YYYY'),
    STARTDATE DATE "MM/DD/YYYY" ":SCHEDDATE",
    SEQNUM SEQUENCE(1000,1),
    ORDERNUM CONSTANT "2",
    INTEGRATION_JOBID CONSTANT "RBI603"
    INTO TABLE igpmgr.INTINS_SCHEDRCPTS
    WHEN (LOC = 'ABC')
    FIELDS TERMINATED BY ","
    TRAILING NULLCOLS
    ITEM,
    LOC,
    SCHEDDATE DATE "MM/DD/YYYY",
    QTY,
    EXPDATE DATE "MM/DD/YYYY" "to_char(to_date(:SCHEDDATE,'MM/DD/YYYY')+365,'DD/MM/YYYY')",
    STARTDATE DATE "MM/DD/YYYY" ":SCHEDDATE",
    SEQNUM SEQUENCE(1000,1),
    ORDERNUM CONSTANT "2",
    INTEGRATION_JOBID CONSTANT "RBI603"
    But its only inserting rows from loc DHL and not from ABC...
    Please help me..
    Thanks,
    Ravi.

    Hello Ravi,
    Based on your sample data, adding commas to match the field terminators specified in the control file:10000001,DHL,7/13/2011,100
    1000002,DHL,7/14/2011,10
    101,ABC,7/15/2011,1000
    10000002,ABC,7/16/2011,100
    100,X,7/16/2011,0Consider the following:LOAD DATA
    INFILE test.csv'
    APPEND
    INTO TABLE tab1
    WHEN (LOC = 'ABC')
    FIELDS TERMINATED BY ","
    TRAILING NULLCOLS
    ( ITEM
    , LOC
    , SCHEDDATE          DATE "MM/DD/YYYY"
    , QTY                                                -- moved to the fourth column to match the order presented in the sample data
    , EXPDATE            DATE "MM/DD/YYYY"               -- changed specified date format to use double quotes instead of single quotes and swapped order of DD & MM to match SCHEDDATE in sample data, but also not present in the sample data, so would expect this to be treated as null, so not sure why it is specified
    , STARTDATE          DATE "MM/DD/YYYY" ":SCHEDDATE"
    , SEQNUM             SEQUENCE(1000,1)
    , ORDERNUM           CONSTANT          "2"
    , INTEGRATION_JOBID  CONSTANT          "RBI603"
    INTO TABLE tab1
    WHEN (LOC = 'DEF')
    FIELDS TERMINATED BY ","
    TRAILING NULLCOLS
    ( ITEM               POSITION(1)                     -- added POSITION(1) to allow sqlldr to start reading from the beginning of the line
    , LOC
    , SCHEDDATE          DATE "MM/DD/YYYY"
    , QTY                                                -- moved to the fourth column to match the order presented in the sample data
    , EXPDATE            DATE "MM/DD/YYYY"               -- not present in the sample data, so would expect this to be treated as null, so not sure why it is specified
    , STARTDATE          DATE "MM/DD/YYYY" ":SCHEDDATE"
    , SEQNUM             SEQUENCE(1000,1)
    , ORDERNUM           CONSTANT          "2"
    , INTEGRATION_JOBID  CONSTANT          "RBI603"
    )Hope this helps,
    Luke
    Please mark the answer as helpful or answered if it is so. If not, provide additional details.
    Always try to provide actual or sample statements and the full text of errors along with error code to help the forum members help you better.

  • Help needed in HTTP Tunneling - urgent

    Hi all,
    I urgently need a working code sample of a client which sends requests to a server that redirects the request to an RMI server via RMI servlet.
    Does any of you familiar of such a code sample?
    Thanks

    I'm sorry, but HTTP Tunneling is not working for me. I must have done something wrong.
    Let me describe my configuration:
    I have a server behind NAT router which connected to apache2 and tomcat 4.1 web servers. The apache2 and tomcat are not connected between them.
    I deployed war file on tomcat which contains the servlet for the HTTP Tunneling which its code is:
    public class RmiHttpTunnelerServlet extends HttpServlet
        public void init(ServletConfig config) throws ServletException
            super.init(config);
            System.out.println("Simplified RMI Servlet Handler loaded successfully.");
        public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
            try
                String queryString = req.getQueryString();
                String command, param;
                int delim = queryString.indexOf("=");
                if (delim == -1)
                    command = queryString;
                    param = "";
                else
                    command = queryString.substring(0, delim);
                    param = queryString.substring(delim + 1);
                if (command.equalsIgnoreCase("forward"))
                    try
                        ServletForwardCommand.execute(req, res, param);
                    catch (ServletClientException e)
                        returnClientError(res, "client error : " + e.getMessage( ));
                        e.printStackTrace();
                    catch (ServletServerException e)
                        returnServerError(res, "internal server error : " + e.getMessage());
                        e.printStackTrace();
                else
                    returnClientError(res, "invalid command: " + command);
            catch (Exception e)
                returnServerError(res, "internal error: " + e.getMessage());
                e.printStackTrace();
        public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
            returnClientError(res, "GET Operation not supported: Can only forward POST requests.");
        public void doPut(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
            returnClientError(res, "PUT Operation not supported: Can only forward POST requests.");
        public String getServletInfo()
            return "Simplified RMI Call Forwarding Servlet Servlet.<br>\n ";
        private static void returnClientError(HttpServletResponse res, String message) throws IOException
            res.sendError(HttpServletResponse.SC_BAD_REQUEST,
                          "<HTML><HEAD><TITLE>Java RMI Client Error < / TITLE > < / HEAD > < BODY > " +
                          "<H1>Java RMI Client Error</H1>" + message + "</BODY></HTML>");
            System.err.println(HttpServletResponse.SC_BAD_REQUEST + "Java RMI Client Error" + message);
        private static void returnServerError(HttpServletResponse res,
                                              String message) throws IOException
            res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                          "<HTML><HEAD>< TITLE > Java RMI Server Error < / TITLE > < / HEAD > < BODY > " +
                          "<H1>Java RMI Server Error < / H1 > " + message + " < / BODY > < / HTML > ");
            System.err.println(HttpServletResponse.SC_INTERNAL_SERVER_ERROR + "Java RMI Server Error : " + message);
        }There is also a utility class:
    public class ServletForwardCommand {
        public static void execute(HttpServletRequest request, HttpServletResponse response, String stringifiedPort)
            throws ServletClientException, ServletServerException, IOException {
            int port = convertStringToPort(stringifiedPort);
            Socket connectionToLocalServer = null;
            try {
                connectionToLocalServer = connectToLocalServer(port);
                forwardRequest(request, connectionToLocalServer);
                forwardResponse(response, connectionToLocalServer);
            } finally {
                if (null != connectionToLocalServer) {
                    connectionToLocalServer.close();
        private static int convertStringToPort(String stringfiedPort) throws ServletClientException {
            int returnValue;
            try {
                returnValue = Integer.parseInt(stringfiedPort);
            } catch (NumberFormatException e) {
                throw new ServletClientException("invalid port number: " + stringfiedPort);
            if (returnValue <= 0 || returnValue > 0xFFFF) {
                throw new ServletClientException("invalid port: " + returnValue);
            if (returnValue < 1024) {
                throw new ServletClientException("permission denied for port: " + returnValue);
            return returnValue;
        private static Socket connectToLocalServer(int port) throws ServletServerException {
            Socket returnValue;
            try {
                returnValue = new Socket(InetAddress.getLocalHost(), port);
            } catch (IOException e) {
                throw new ServletServerException("could not connect to " + "local port");
            return returnValue;
        private static void forwardRequest(HttpServletRequest request, Socket connectionToLocalServer)
            throws IOException, ServletClientException, ServletServerException {
            byte buffer[];
            DataInputStream clientIn = new DataInputStream(request.getInputStream());
            buffer = new byte[request.getContentLength()];
            try {
                clientIn.readFully(buffer);
            } catch (EOFException e) {
                throw new ServletClientException("unexpected EOF " + "reading request body");
            } catch (IOException e) {
                throw new ServletClientException("error reading request" + " body");
            DataOutputStream socketOut = null;
            // send to local server in HTTP
            try {
                socketOut = new DataOutputStream(connectionToLocalServer.getOutputStream());
                socketOut.writeBytes("POST / HTTP/1.0\r\n");
                socketOut.writeBytes("Content-length: " + request.getContentLength() + "\r\n\r\n");
                socketOut.write(buffer);
                socketOut.flush();
            } catch (IOException e) {
                throw new ServletServerException("error writing to server");
        private static void forwardResponse(HttpServletResponse response, Socket connectionToLocalServer)
            throws IOException, ServletClientException, ServletServerException {
            byte[] buffer;
            DataInputStream socketIn;
            try {
                socketIn = new DataInputStream(connectionToLocalServer.getInputStream());
            } catch (IOException e) {
                throw new ServletServerException("error reading from " + "server");
            String key = "Content-length:".toLowerCase();
            boolean contentLengthFound = false;
            String line;
            int responseContentLength = -1;
            do {
                try {
                    line = socketIn.readLine();
                } catch (IOException e) {
                    throw new ServletServerException("error reading from server");
                if (line == null) {
                    throw new ServletServerException("unexpected EOF reading server response");
                if (line.toLowerCase().startsWith(key)) {
                    responseContentLength = Integer.parseInt(line.substring(key.length()).trim());
                    contentLengthFound = true;
            while ((line.length() != 0) &&
                (line.charAt(0) != '\r') && (line.charAt(0) != '\n'));
            if (!contentLengthFound || responseContentLength < 0)
                throw new ServletServerException("missing or invalid content length in server response");
            buffer = new byte[responseContentLength];
            try {
                socketIn.readFully(buffer);
            } catch (EOFException e) {
                throw new ServletServerException("unexpected EOF reading server response");
            } catch (IOException e) {
                throw new ServletServerException("error reading from server");
            response.setStatus(HttpServletResponse.SC_OK);
            response.setContentType("application/octet-stream");
            response.setContentLength(buffer.length);
            try {
                OutputStream out = response.getOutputStream();
                out.write(buffer);
                out.flush();
            } catch (IOException e) {
                throw new ServletServerException("error writing response");
    }I checked also with packets monitoring tool, I couldn't see any http transportation.
    Any help will be appreciated.

  • Need a SQL Query (URGENT)

    Hi Folks,
    I have 2 tables, in which the 1st one has 200 columns and 2 table had 2 columns.. There is one common column for both the tables, but there is little change in schema of the tables...The common col in 2nd table is a primary key but the same column in the 1st table is a ordinary one..The data type for the common column is same...
    Now i need to write a query to select 199columns(except the common column)from the 1st table and the other column(2nd col)other than the common column frm the 2nd table for "table1.commoncolumn=table2.commoncolumn"......
    I had tried the natural join but its nt working in my informix sql database....I also tried by explicitly mentioning column names like "select column1,column2....column199,table2.column2 from table1,table2 where table1.commoncolumn=table2.commoncolumn", but its having a severe performance impact.......
    Can some please suggest a query for the above one?? Thankx in advance..

    Please gimme possible solutions & suggestions regarding the above query....
    The informix z forum very slow...The problem is, you labeled your questions badly. As this is a forum of volunteers people tend to react badly to the use of the word "urgent" in the subject line. Nobody's question matters more than anybody else's. In fact some regulars won't answer questions with "urgent" in the strapline as a matter of principle.
    Then when we get to actually read your question it turns out to be a question about Informix. I guess not many people here use Informix so your potential pool of responders is pretty small (for instance I'm not even sure how to spell it).
    It's not our fault the Informix forums are so lame.
    Anyway, what I suggest is you repost your question with a new title: (Off topic) Need help with an INFORMIX query.
    At least that will attract people who might be able to answer your question. Then you need to include the actual query you're running and all the supporting details necessary for people to understand the nature of the performance impact.
    You need to ask the right people and you need to ask the right question. This is standard etiquette (and indeed common sense) regardless of which forum you're using.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

Maybe you are looking for

  • Song and Artist Info missing under itunes but not in the original file, and putting track number next to certian songs. Help

    i recently updated my itunes...today i opened it up and moticed abuout 100 songs missing...they are now at the bottom of itunes song list with a number next to them with information mission such as this the example below 01 human                     

  • How can i set the dynamic text box to show variable value?

    In AS2, I can make a dynamic text box set a var name, when i use button set/change the var value, this textbox can show the value also. but In AS3, dynamic text box can't add var name. than how can i do it now?

  • User does not work correctly in Unity

    Hello We have a customer with a Unity server integrated with Exchange. Everything works fine except one user. The issue is this: The user calls his mailbox and then he gets a message saying "the connection with the message server is lost" then he can

  • Title in Charts

    Hello All, I have a requirement where in i want to Display the chart TITLE like as below, "XYZ Organisation Report From 01-May-2001 to 05-May-2005" Am able to display the 1st line i.e "XYZ Organisation Report", but am not able to get the second line

  • Move sprite using keyboard

    Hi. I am trying to make a simple game where you move a tank around. My problem is that I can't seem to get it to move right. Here is the code: import java.applet.*; import java.awt.*; import java.awt.event.*; import java.awt.geom.AffineTransform; pub