Null or empty response from database?

Is there anything I can do with connecting to my database? I get null or empty response. There is no error message.
package databaseconnection; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class MainTest { static String userName = "mynickname"; static String userPassword = "myunforgettablepassword"; static String databaseUrl = "jdbc:mysql://databaseserver.com/myfavouritedatabase"; static String userQuery = "SELECT * FROM ques"; public static void main(String[] args) { // ConnectToDatabase CTD = new ConnectToDatabase();             MainTest MainTest= new MainTest();             MainTest.connect(userName, userPassword, databaseUrl, userQuery); // CTD.connect(userName, userPassword, databaseUrl, userQuery); System.out.println(); // i get null as the response? } void connect(String userName, String userPassword, String databaseUrl, String userQuery){ try { Class.forName ("com.mysql.jdbc.Driver").newInstance (); Connection conn = DriverManager.getConnection (databaseUrl, userName, userPassword); Statement stat = conn.createStatement(); String query = userQuery; ResultSet result = stat.executeQuery(query); try{                         while (result.next()) { String s = result.getString("Name");         System.out.println(s);     return; } }                                 catch ( SQLException sqlException)         {               sqlException.printStackTrace();         } System.out.println("Result(s): "); while(result.next()){ System.out.println("name:\t" + result.getString("Name")); System.out.println(""); } conn.close(); }catch (SQLException e) { } catch (InstantiationException e) {} catch (IllegalAccessException e) {} catch (ClassNotFoundException e) {}         } }
/* * Found here and modified from: * http://www.romow.com/computer-blog/how-to-use-mysql-with-java/ */ package databaseconnection; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; import javax.swing.JOptionPane; public class ConnectToDatabase { String s; public void connect(String userName, String userPassword, String databaseUrl, String userQuery){ try { Class.forName ("com.mysql.jdbc.Driver").newInstance (); Connection conn = DriverManager.getConnection (databaseUrl, userName, userPassword); Statement stat = conn.createStatement(); String query = userQuery;                     ResultSet result = stat.executeQuery(query); try{                                                 while (result.next()) {       s = result.getString("Name");         System.out.println(s);     return; } }                                 catch ( SQLException sqlException)         {               sqlException.printStackTrace();         }                         System.out.println("Result(s): "); while(result.next()){ System.out.println("name:\t" + result.getString("Name")); System.out.println(""); }                             conn.close(); }catch (SQLException e) { } catch (InstantiationException e) {} catch (IllegalAccessException e) {} catch (ClassNotFoundException e) {}         }     }        

Note: This thread was originally posted in the Swing forum, but moved to this forum for closer topic alignment.

Similar Messages

  • To get list of suspended responses from database

    Hi All,
    we have O2A PIP installed with below versions:
    Oracle AIA     11.1.1.5
    Oracle WebLogic    10.3.5
    SOA Suite    11.1.1.5
    O2C PIP        11.1.1.1
    In Production some of the orders are failing because of Siebel internal error and hence those responses are also erroring out in AIA.
    Now as per the resequencing logic all subsequent responses for that account is going into suspended state so that only when the faulted response was recovered successfully, the subsequent response will flow.
    The issue we have here is, whenever any new order is coming bearing same Account no. for which the response of some order has failed, the responses of new orders are also going into suspended state. now all suspended responses we can only see that in mediator_instance table, one row is getting added with same group_id of that account. leaving us with no option to identify if this response is for new order or same order which has faulted.
    we can identify all the responses which has faulted by combining mediator_instance and composite_instance table as instance of updateSalesOrderSiebelComsProvABCSImpl gets created for the response which has failed.
    but we need the list of all new orders and its group_id which is going into suspended state because of some other order's faulted response.
    Please let us know if there is any way to get this list from database.
    Thanks & Regards,
    Vivek

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Getting response from Database by sending in parameters

    Hi,
    I am providing parameter which supplies string values to query the database using adapter. I can see the invoke activity sending the string value to the database, but respnse message does not contain anthing.
    Can someone please tell me how to retrieve records from database by suplying parmeter value?
    Thank You
    Anil

    hi Anil,
    use a simple stored procedure or pl/sql function and specify the input and output parameters. We can send any no of parameters to a function and a function can able to return a value. so you can achieve your requirement using pl/sql functions. Learn about that more.
    when you will define ParterLink (using DBAdapter browing databse to select your function ), you shud be able to view one OUT parameter with datatype what you have mentioned earlier in pl/sql function. When you define Invoke for that Parterlink, you should get Invoke Output variable with output variable (having name of that function.)
    If you cannot browse the function in your DB Adapter, just make sure that the user you have defined in DB Adapter has enough privileges to access that function.
    Regards
    Rajesh A

  • Slow response from database

    Database is suddenly slow. As a user can I see if any tables are locked? Any major operation going on?

    > Database is suddenly slow.
    Why the database? Maybe it is I/O that is slow? (someone copying/moving/deleting large files on the db server)
    Maybe there is insufficient CPU capacity on the db server? (someone running 50 Perl processes concurrently to parse a bunch of files)
    Maybe it is the network that is slow? (someone downloading movies and impacting the network segment that the db server is on)
    > As a user can I see if any tables are locked?
    Why locked tables? Oracle does not have lock escalation. Oracle row locks never escalates into page locks which in turn escalates to table locks.
    > Any major operation going on?
    Maybe.. but then it does not need to be a major operation. It could be that the CPU is running 1% busy, the I/O channels running at 1% capacity, plenty of free memory available, very little swapping.. and still, things seems "slow" despite nothing really being pushed even slightly hard on the server.
    This scenario can be caused by many processes all waiting (in a queue) to access a single dedicated serialised/non-shared resource. And as the resource can only service one customer at a time, it is a major bottleneck - with the rest of the resources on that db server being grossly underutilised.
    Mere observation ito measuring performance and determining performance problems is useless. The database may seem slow. But that does not in any way imply that the database itself is actually slow.
    You have to look at things like the network, CPU, I/O and memory utilisation on the db server, to determine what component (if any) is responsible for decreasing performance.
    At the same time, you also need to look at the wait states of the processes on that db server as maybe there is no resource problem, but a problem with serialisation and processing all waiting in a queue to be serviced.
    Performance Tuning starts with The Identification of The Problem. So you need to pop the hood, on the network, disks, operating system and db server, to isolate and identify the problem.
    Unfortunately, there is no easy magic wand to wave to uncover the performance issue.

  • External HTTP-Webservice with empty response

    Hi community,
    I have implemented an external http webservice which is working fine when I test it directly via se80 - I receive the results I want.
    Now I want to capsulate it into a function module but always receive a empty response structure. I call it the way
    TRY.
           CALL METHOD WSProxy->GET_ITEMS
             exporting
               INPUT  = ls_request
             importing
               OUTPUT = ls_response.
             catch CX_AI_SYSTEM_FAULT.    " Application Integration: Technischer Fehler
             catch ZCX_TECHNICAL_FAULT_MESSAGE.    " Proxy Class (generated)
             catch CX_AI_APPLICATION_FAULT.    " Application Integration: Applikations Fehler
       ENDTRY.
    I receive no exception about missing parameters...

    Hi Daniel,
    I am facing the same problem calling an external WS from SAP.
    How did you solve it? In my case i receive non empty response from the WS call in the SE80 with the test service consumer but not from Abap.
    Thank you very much.
    Kind Regards
    Jon

  • Passing null/empty values from a actionscript VO to a Coldfusion ORM object

    This is the situation.
    If you have an actionscript VO that binds to a Coldfusion ORM object via the RemoteClass metadata and some of the values are not set, null, or empty strings and you pass it from Flex to Coldfusion then the Coldfusion deserialization barfs saying the values are not acceptable date values (for type="date") or valid emails (for validation="email") or other such validations, even if required="false" on the property.
    For instance, if you have the following actionscript VO:
    package vo
        [RemoteClass(alias="com.companyname.Person")]
        [Bindable]
        public class Person
            public var person_id:Number;
            public var last_name:String;
            public var first_name:String;
            public var email:String;
            public var created_date:date;
         public function Person() {}
    And you have the corresponding Coldfusion component:
    <cfcomponent displayname="person" output="false"
        alias="com.companyname.Person"
        schema="dbo" persistent="true"
        table="PERSON">
        <cfproperty name="person_id" type="numeric" fieldtype="id" validate="integer" required="true" column="PERSON_ID"/>
        <cfproperty name="last_name" type="string" column="LAST_NAME" required="true"/>
        <cfproperty name="first_name" type="string" required="true" column="FIRST_NAME"/>
        <cfproperty name="email" type="string" validate="email" required="false" column="EMAIL"/>
        <cfproperty name="date_created" type="date" required="false" column="DATE_CREATED"/>
    </cfcomponent>
    Then if you pass the actionscript VO as is to Coldfusion, the deserialization complains that you do not have a valid email or a valid date for date_created.  This is bad, bad, bad.  Essentially if you have a validation of certain types (email being one) or a date property, or probably some other cases, then you essentially can not make it not required, it automatically makes it required because the Coldfusion serializer considers null/empty values as invalid dates or emails.  But the serializer should not care for values that are not required, there has to be a way to pass null/empty values to these data types, but apparently there's not.  If you pass an empty string ("") you still have the same problem.  I know Coldfusion does not have null values, but there has to be a way to do this, otherwise it defeats the purpose of having required="false" and some kind of validation on the property.
    There seems to be two ways around it.  One is to override the implicit setters for the properties on the Coldfusion side and check for 0 length values yourself, then set the property if it is not, or create your own validation routine.  I ended up creating my own validation function since I didn't want to have to write a setter function for everyone of these cases and I can pass back user friendly validation messages.
    Have other people encountered this problem?  How have you gotten around it?  Thanks.

    I realize that I didn't clarify that I am using ColdFusion
    for getting the data. This class was generated by the Create CFC
    wizard in Flex Builder.
    package com.generated
    [Managed]
    [RemoteClass(alias="components.generated.clients.Clients")]
    public class Clients
    public var clientid:Number = 0;
    public var clientfirstname:String = "";
    public var clientlastname:String = "";
    public var clientaddress1:String = "";
    public var clientaddress2:String = "";
    public var clientcity:String = "";
    public var clientstate:String = "";
    public var clientzip:String = "";
    public var clientphone:String = "";
    public var clientemail:String = "";
    public function Clients()
    }

  • Passing null/empty values from Flex to a Coldfusion ORM object

    This is the situation.
    If you have an actionscript VO that binds to a Coldfusion ORM object via the RemoteClass metadata and some of the values are not set, null, or empty strings and you pass it from Flex to Coldfusion then the Coldfusion deserialization barfs saying the values are not acceptable date values (for type="date") or valid emails (for validation="email") or other such validations, even if required="false" on the property.
    For instance, if you have the following actionscript VO:
    package vo
        [RemoteClass(alias="com.companyname.Person")]
        [Bindable]
        public class Person
            public var person_id:Number;
            public var last_name:String;
            public var first_name:String;
            public var email:String;
            public var created_date:date;
         public function Person() {}
    And you have the corresponding Coldfusion component:
    <cfcomponent displayname="person" output="false"
        alias="com.companyname.Person"
        schema="dbo" persistent="true"
        table="PERSON">
        <cfproperty name="person_id" type="numeric" fieldtype="id" validate="integer" required="true" column="PERSON_ID"/>
        <cfproperty name="last_name" type="string" column="LAST_NAME" required="true"/>
        <cfproperty name="first_name" type="string" required="true" column="FIRST_NAME"/>
        <cfproperty name="email" type="string" validate="email" required="false" column="EMAIL"/>
        <cfproperty name="date_created" type="date" required="false" column="DATE_CREATED"/>
    </cfcomponent>
    Then if you pass the actionscript VO as is to Coldfusion, the deserialization complains that you do not have a valid email or a valid date for date_created.  This is bad, bad, bad.  Essentially if you have a validation of certain types (email being one) or a date property, or probably some other cases, then you essentially can not make it not required, it automatically makes it required because the Coldfusion serializer considers null/empty values as invalid dates or emails.  But the serializer should not care for values that are not required, there has to be a way to pass null/empty values to these data types, but apparently there's not.  If you pass an empty string ("") you still have the same problem.  I know Coldfusion does not have null values, but there has to be a way to do this, otherwise it defeats the purpose of having required="false" and some kind of validation on the property.
    There seems to be two ways around it.  One is to override the implicit setters for the properties on the Coldfusion side and check for 0 length values yourself, then set the property if it is not, or create your own validation routine.  I ended up creating my own validation function since I didn't want to have to write a setter function for everyone of these cases and I can pass back user friendly validation messages.
    Have other people encountered this problem?  How have you gotten around it?  Thanks.

    Looks like a known workaround to this issue is to wrap the Flex object in an array.
    The ColdFusion CFC will accept that as an array, with the first an only element being a struct, which is the object you built in Flex.

  • Empty box received, no response from seller, claim opened, paypal says to send item back

    Item is a 30" lawnmower blade and by the looks of the box it slipped out of the bottom during shipment.  I called seller initially and he said they would send another and file a claim with the carrier.  I waited about 2 weeks and still no item so I left voicemails over the course of a couple days, also emailed the seller with no response. I opened claim with paypal and they said they ruled in my favor, but need tracking info showing that I sent the item back to the seller.  Do I really need to pay more $ and spend more time shipping an empty box?  This does not make sense and it has been a month (6/19) since I paid for the item. I have tried calling paypal and there is a series of 5-6 advertisements, then it says to call a different number which goes to a completely different company for phone/internet service. I emailed paypal about this and got a generic response with links to some FAQs.   What would you do?

    That's all terrible. Just for clarification, this is a peer to peer forum. I am guessing that you posted this here to have others be aware of this. You most likely won't get a response from a VZW rep here and if you do it may not be fruitful.
    I can also tell you that a store rep doesn't have the ability to change the shipping address unless it is done at the time of the order. It is correct that to change the shipping address the tracking number has to be generated and then VZW has to fill out a form with FedEx and that could delay the package by up to 48 hours. I don't know how you received 2 packages BUT when VZW sends a device they make a note of the ESN on your account with the package's tracking number. If, in deed, their records indicate that 2 devices were sent they can easily rectify this situation. How? It is simple.
    1.) Take note of the ESN on your current device. Take the battery out and it is on the sticker. It will most likely begin with 99.
    2.) Call them. I know that you don't want to do this but insist that they look through the notes and confirm the ESNs that were sent to determine which one is on your account and which one is the missing one.
    3.) Have them input the ESN in to the system and see if it is activated on another account. If it is, they won't tell you who has it but they should easily see that it isn't you.
    This can also be done in a corporate VZW store. Not that you'd want to but if the store that Brian works at is one, I would go back there.
    Hope this information helps you start to get to the bottom of this. It shouldn't be on us to do any legwork but we have to be proactive when it comes to our money.

  • Choice format for null or empty string vs non-empty

    How can I provide a choice format string for null or empty substitution strings?
    I know one would not nomally do this, but the substitution strings are being passed in by an independant legacy code. I need something equivalent to
    Some message with a choice {0,choice,null#nothing|not-null#something}
    Unfortunately, programatic implementation is not currently an option

    Ya, I will try that. That seems to be a good idea. Thanks for the response.
    I have one more query. Whenever we add a new column to any table in Oracle, the column name is stored in Upper case. So when we generate XML File from the database, all the tags are either in upper case (or we can use qry.useLowerCaseTagNames() to retrieve the tag names in lower case). But the XSD contains tag names in mixed case. So when validating the XML Document against an XSD, it throws a validation error.
    Is there any way I can avoid this?

  • System.Exception: null or empty values

    Have designed a 4 part form Using DW MX, ASP.NET C# and MySQL
    and currently getting the below error when moving from one page to
    the next.
    The web.config file is on the server, there are no null or
    empty values, and the key tags match.
    I am new to applicaiton development in DW and am now stuck -
    any suggestions?
    System.Exception: This page has a MM:DataSet, MM:Insert,
    MM:Update or MM:Delete tag with a null or empty value for the
    ConnectionString and DatabaseType attributes.
    Often, such values come from application settings in the
    web.config file. That file might be missing from the server
    executing this page. Or, it might be missing the particular add key
    tags for the database connection this page uses. If you are using
    Dreamweaver, look for the web.config file in the local root folder
    of your Dreamweaver site. Once you find this file, you can either:
    Put this file onto the server that is executing this page.
    Copy the add key tags from the web.config in the local root
    folder of your Dreamweaver site and paste them into the web.config
    file in the server that is executing this page.
    at DreamweaverCtrls.DataSet.DoInit()
    Text

    http://java.sun.com/docs/books/tutorial/uiswing/components/spinner.html#model
    Might be a good start.

  • How to define null or empty value in BAPI function modules?

    Hi,
    I have problem with BAPI functions, where some parameters are mandatory.
    For example: when I try to use HR BAPI's(BAPI_PERSDATA_CHANGE, etc.) I have to insert parameters like SUBTYPE,OBJECTID,LOCKINDICATOR. The PA0002 table that is used from this BAPI doesn't have SUBTYPE, OBJECTID, LOCKINDICATOR, for any of the records that I would like to select.
    So what I tried, was to put a ' ', to indicate that is empty. It returned an error message saying "Make an entry in all required fields". Next tried to put in some values for these fields -- and it returned an error message saying "No data selected from 0002 for this period".
    I also tried to run BAPI_FAMILY_CHANGE that uses data from table PA0021. Here I found some records with  SUBTYPE, OBJECTID fields that were not empty, but LOCKINDICATOR was still missing. So I tried to put LOCINDICATOR value directly in to database (with MS SQL Enterprise Manager).  After that I was able to use BAPI_FAMILY_CHANGE.
    I think that manually inserting data in database is not normal procedure.
    Is there something that I have missed out?
    I mean -- how can I get this to work without inserting data directly in database?
    How can I define null or empty value in BAPI function modules?
    Thank you in advance.
    Best regards,
    Mihail

    Defining an empty value for a parm in a table is easy.
    First get the function's definition from the SAP system
    Second only populate the fields for which you have a value to set
    Third execute the function.
    The JCO takes care of the rest.
    Enjoy

  • How to get string value from database table using Visual Studio 2005?

    Hi,
    Im developing plugin in illustrator cs3 using visual studio 2005. I need to get the values eneterd in database. Im able to get the integer values. But while getting string values it is returning empty value.
    Im using the below code to get the values from database table
    bool Table::Get(char* FieldName,int& FieldValue)
        try
            _variant_t  vtValue;
            vtValue = m_Rec->Fields->GetItem(FieldName)->GetValue();
            FieldValue=vtValue.intVal;
        CATCHERRGET
        sprintf(m_ErrStr,"Success");
        return 1;
    Im using the below code to get the values.
    AIErr getProjects()
        char buf[5000];
        int i;   
        std::string  catName;
        ::CoInitialize(NULL);
        Database db;
        Table tbl;
        errno_t err;
        err = fopen(&file,"c:\\DBResult.txt","w");
        fprintf(file, "Before Connection Established\n");
        //MessageBox(NULL,CnnStr,"Connection String",0);
        if(!db.Open(g->username,g->password,CnnStr))
            db.GetErrorErrStr(ErrStr);
            fprintf(file,"Error: %s\n",ErrStr);
        fprintf(file, "After Connection Established\n");
    if(!db.Execute("select ProjectID,ProjectName from projectsample",tbl))
            db.GetErrorErrStr(ErrStr);
            fprintf(file,"Error: %s\n",ErrStr);
        int ProjectID;
        int UserID;
        int ProjectTitle;
        char ProjectName[ProjectNameSize];
        if(!tbl.ISEOF())
            tbl.MoveFirst();
        ProjectArrCnt=0;
        for(i=0;i<128;i++)
            buf[i]='\0';
            int j=0;
        while(!tbl.ISEOF())
            if(tbl.Get("ProjectID",ProjectID))
                fprintf(file,"Project ID: %d ",ProjectID);
                ProjectInfo[ProjectArrCnt].ProjectID = ProjectID;
                sprintf(buf,"%d",ProjectID);
                //MessageBox(NULL, buf,"f ID", 0);
                j++;
            else
                tbl.GetErrorErrStr(ErrStr);
                fprintf(file,"Error: %s\n",ErrStr);
                break;
            //if(tbl.Get("ProjectTitle",ProjectName))
            if(tbl.Get("ProjectName",ProjectName))
                MessageBox(NULL,"Inside","",0);
                fprintf(file,"ProjectTitle: %s\n",ProjectName);
                //catName=CategoryName;
                ProjectInfo[ProjectArrCnt].ProjectName=ProjectName;
                //sprintf(buf,"%s",ProjectName);
                MessageBox(NULL,(LPCSTR)ProjectName,"",0);
            else
                tbl.GetErrorErrStr(ErrStr);
                fprintf(file,"Error: %s\n",ErrStr);
                break;
            ProjectArrCnt++;
            //MessageBox(NULL, "While", "WIN API Test",0);
            tbl.MoveNext();
        //MessageBox(NULL, ProjectInfo[i].ProjectName.c_str(),"f Name", 0);
        ::CoUninitialize();
        //sprintf(buf,"%s",file);
        //MessageBox(NULL,buf,"File",0);
        fprintf(file, "Connection closed\n");
        fclose(file);
        for(i=0;i<ProjectArrCnt;i++)
            sprintf(buf,"%i",ProjectInfo[i].ProjectID);
            //MessageBox(NULL,buf,"Proj ID",0);
            //MessageBox(NULL,ProjectInfo[i].ProjectName.c_str(),"Project Name",0);
        return 0;
    In the above code im geeting project D which is an integer value. But not able to get the project name.
    Please some one guide me.

    As I said in the other thread, this really isn't the place to ask questions about a database API unrelated to the Illustrator SDK. You're far more like to find people familliar with your problem on a forum that is dedicated to answering those kinds of questions instead.

  • SQL query or view used internally by Discoverer Open Workbook from Database

    Hi Experts,
    I am involved in developing a web application wherein I have to display the 'All Workbooks' similiar functionality in the 'Open Workbook from Database' dialog box of Discoverer. Can anybody provide me with the background query or view that Discoverer uses to retrieve this data for workbook listing? Please let me know if my question is confusing and requires more details.
    Thanks
    Thomas

    Hi,
    If you just need the list of workbooks then you need to use the EUL_DOCUMENT table:
    SELECT u.User_Name          Owner_Name
    *,Doc.Doc_Name Workbook_Name*
    *,Doc.Doc_Updated_Date Last_Update_Date*
    FROM   Eul_Us.Eul5_Documents Doc
    *,Eul_Us.Eul5_Eul_Users Own_Usr*
    *,Fnd_User u*
    WHERE  Own_Usr.Eu_Id = Doc.Doc_Eu_Id AND
    To_Char(u.User_Id(+)) = Substr(Own_Usr.Eu_Username
    *,2*
    *,10);*
    If you want the exact same list then you need to do the above along with the sharing :
    SELECT DISTINCT
    case when instr(disco_docs.doc_created_by,'#')=0 then disco_docs.doc_created_by
    when instr(disco_docs.doc_created_by,'#')>0 and instr(disco_docs.doc_created_by,'#',2)=0 then (select fu.user_name from fnd_user fu where fu.user_id=substr(disco_docs.doc_created_by,2,5))
    else NULL
    end "Workbook Owner/Creator",
    disco_docs.doc_name "Workbook Name",
    disco_docs.Doc_Updated_Date  "Last Update Date",
    case when instr(disco_users.eu_username,'#')=0 then disco_users.eu_username
    when instr(disco_users.eu_username,'#')>0 and instr(disco_users.eu_username,'#',2)=0 then (select fu.user_name from fnd_user fu where fu.user_id=substr(disco_users.eu_username,2,5))
    else (select resp.responsibility_name from fnd_responsibility_tl resp where resp.responsibility_id=substr(disco_users.eu_username,2,5))
    end as "Shared Name / Responsibility"
    FROM
    eul_us.eul5_documents disco_docs,
    eul_us.eul5_access_privs disco_shares,
    eul_us.eul5_eul_users disco_users
    WHERE
    disco_docs.doc_id = disco_shares.gd_doc_id (+)
    and disco_users.eu_username(+) NOT IN ('EUL5', 'PUBLIC')
    AND disco_users.eu_id(+) = disco_shares.ap_eu_id;
    * Change the EUL_US to your discoverer schema...
    Then you will need to compare the current user with the sharing list or creator
    Good luck
    Tamir

  • View in image from database

    hi will i be able to view image from my database using this class, am using jdeveloper 11g release 2
    package TaskFlowView;
    import java.io.BufferedInputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.sql.DataSource;
    public class ImageServlet extends HttpServlet {
        private static final String CONTENT_TYPE =
            "image/jpg; charset=utf-8";
         * @param config
         * @throws ServletException
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
         * @param request
         * @param response
         * @throws ServletException
         * @throws IOException
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException,
                                                               IOException {
            response.setContentType(CONTENT_TYPE);
            response.setContentType(CONTENT_TYPE);
            String detailDocumentId = request.getParameter("detail");
            String thumbnailDocumentId = request.getParameter("thumbnail");
            boolean thumbnail = true;
            String DocumentId = null;
            OutputStream os = response.getOutputStream();
            Connection conn = null;
            try {
                Context ctx = new InitialContext();
                DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/SMSDEV");
                conn = ds.getConnection();
                PreparedStatement statement = conn.prepareStatement(
                  "SELECT file_name, " +
                  "dlin.id, " +
                  "FROM  sms_document_links dlin " +
                  "sms_document_references dref" +
                  "WHERE dref.id = ?" +
                  "dref.dlin_id = dlin.id");
                if (detailDocumentId != null) {
                    DocumentId = detailDocumentId;
                    thumbnail = false;
                } else {
                    DocumentId = thumbnailDocumentId;
                statement.setString(1,(thumbnail ? "Y" : "N"));           
                statement.setInt(2, new Integer(DocumentId));
                ResultSet rs = statement.executeQuery();
                if (rs.next()) {
                    Blob blob = rs.getBlob("IMAGE");
                    BufferedInputStream in = new BufferedInputStream(blob.getBinaryStream());
                    int b; byte[] buffer = new byte[10240];
                    while ((b = in.read(buffer, 0, 10240)) != -1) { os.write(buffer, 0, b); }
                    os.close();
            } catch (Exception e){
                System.out.println(e);
            } finally {
                try{
                    if (conn != null){
                         conn.close();
                 } catch (SQLException sqle){
                     System.out.println("SQLException error");
        }Edited by: Tshifhiwa on 2012/05/29 1:52 PM
    Edited by: Tshifhiwa on 2012/05/29 1:56 PM

    hi this what i have done, am still having error with my iterator line= DCIteratorBinding lBinding = lBindingContainer.findIteratorBinding(sms4200ModuleDataControlIter),the error say type or variable sms4200ModuleDataControlIter not found but thats the name in my page defination,and is this the class i must write this method
    import com.sun.rowset.internal.Row;
    import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.ContentType;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.sql.SQLException;
    import oracle.jbo.domain.BlobDomain;
    import oracle.jbo.domain.Timestamp;
    import oracle.jbo.server.AttributeDefImpl;
    import oracle.jbo.server.EntityImpl;
    import oracle.jbo.server.ViewRowImpl;
    import javax.faces.event.ValueChangeEvent;
    import org.apache.myfaces.trinidad.model.UploadedFile;
    import javax.faces.application.FacesMessage;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ValueChangeEvent;
    import oracle.adf.model.binding.DCBindingContainer;
    import oracle.adf.model.binding.DCIteratorBinding;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCIteratorBindingDef;
    import sms4200.common.SmsDocumentLinksViewRow;
    import sun.misc.IOUtils;
    // ---    File generated by Oracle ADF Business Components Design Time.
    // ---    Wed May 30 13:12:49 CAT 2012
    // ---    Custom code may be added to this class.
    // ---    Warning: Do not modify method signatures of generated methods.
    public class SmsDocumentLinksViewRowImpl extends ViewRowImpl implements SmsDocumentLinksViewRow {
        public static final int ENTITY_SMSDOCUMENTLINKS = 0;
        private static final String CONTENT_TYPE =
            "image/jpg; charset=utf-8";
            DocumentImage {
                public Object get(SmsDocumentLinksViewRowImpl obj) {
                    return obj.getDocumentImage();
                public void put(SmsDocumentLinksViewRowImpl obj, Object value) {
                    obj.setDocumentImage((BlobDomain)value);
      public static final int DOCUMENTIMAGE = AttributesEnum.DocumentImage.index();
        public BlobDomain getDocumentImage() {
            return (BlobDomain) getAttributeInternal(DOCUMENTIMAGE);
         * Sets <code>value</code> as attribute value for DOCUMENT_IMAGE using the alias name DocumentImage.
         * @param value value to set the DOCUMENT_IMAGE
        public void setDocumentImage(BlobDomain value) {
            setAttributeInternal(DOCUMENTIMAGE, value);
        private BlobDomain createBlobDomain(UploadedFile file)
            // init the internal variables
            InputStream in = null;
            BlobDomain blobDomain = null;
            OutputStream out = null;
            try
                // Get the input stream representing the data from the client
                in = file.getInputStream();
                // create the BlobDomain datatype to store the data in the db
                blobDomain = new BlobDomain();
                // get the outputStream for hte BlobDomain
                out = blobDomain.getBinaryOutputStream();
                // copy the input stream into the output stream
        39               * IOUtils is a class from the Apache Commons IO Package (http://www.apache.org/)
        40               * Here version 2.0.1 is used
        41               * please download it directly from http://projects.apache.org/projects/commons_io.html
        42               */
                IOUtils.copy(in, out);
            catch (IOException e)
                e.printStackTrace();
            catch (SQLException e)
                e.fillInStackTrace();
            // return the filled BlobDomain
            return blobDomain;
        public void uploadFileValueChangeEvent(ValueChangeEvent valueChangeEvent){
                    // The event give access to an Uploade dFile which contains data about the file and its content
                    // Get the original file name
                    UploadedFile file = (UploadedFile) valueChangeEvent.getNewValue();
                    // Get the original file name
                    String fileName = file.getFilename();
                    String contentType = CONTENT_TYPE.valueOf(fileName);
                        //get(fileName);
                    // get the current roew from the ImagesView2Iterator via the binding
                    DCBindingContainer lBindingContainer =
                        (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
                   // DCIteratorBinding lBinding = lBindingContainer.findIteratorBinding(&quot;sms4200ModuleDataControlIter&quot;);
                      DCIteratorBinding lBinding = lBindingContainer.findIteratorBinding(sms4200ModuleDataControlIter);
                    Row newRow = (Row)lBinding.getCurrentRow();
                    // set the file name
                    //newRow.setAttribute(&quot;DOCUMENTIMAGE&quot; fileName);
                    newRow.setColumnObject(DOCUMENTIMAGE, fileName);
                    // create the BlobDomain and set it into the row
                   // newRow.setAttribute(DOCUMENTIMAGE, createBlobDomain(file));
                    newRow.setColumnObject(DOCUMENTIMAGE, createBlobDomain(file));
                    // set the mime type
                    //newRow.setAttribute(&quot;ContentType&quot;, contentType);
                    newRow.setColumnObject(DOCUMENTIMAGE,contentType);                                                       
    my PageDef file is
    <?xml version="1.0" encoding="UTF-8" ?>
    <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.2.60.81" id="sms4200PageDef"
                    Package="SmsFrontUI.pageDefs">
      <parameters/>
      <executables>
        <variableIterator id="variables"/>
        <iterator Binds="ViewObj1" RangeSize="25" DataControl="TaskFlowAppModuleDataControl" id="ViewObj1Iterator"/>
        <iterator Binds="sms4200_1" RangeSize="25" DataControl="TaskFlowAppModuleDataControl" id="sms4200_1Iterator"/>
        <iterator id="sms4200ModuleDataControlIter" DataControl="sms4200ModuleDataControl" RangeSize="25"
                  Binds="SmsDocumentLinksView1"/>
      </executables>
      <bindings>
        <attributeValues IterBinding="ViewObj1Iterator" id="IntegrationTypeName">
          <AttrNames>
            <Item Value="IntegrationTypeName"/>
          </AttrNames>
        </attributeValues>
        <attributeValues IterBinding="ViewObj1Iterator" id="Name">
          <AttrNames>
            <Item Value="Name"/>
          </AttrNames>
        </attributeValues>
        <attributeValues IterBinding="ViewObj1Iterator" id="LocalUpDirectory">
          <AttrNames>
            <Item Value="LocalUpDirectory"/>
          </AttrNames>
        </attributeValues>
        <attributeValues IterBinding="sms4200_1Iterator" id="IntegrationTypeName1">
          <AttrNames>
            <Item Value="IntegrationTypeName"/>
          </AttrNames>
        </attributeValues>
        <attributeValues IterBinding="sms4200_1Iterator" id="Name1">
          <AttrNames>
            <Item Value="Name"/>
          </AttrNames>
        </attributeValues>
        <attributeValues IterBinding="sms4200_1Iterator" id="LocalUpDirectory1">
          <AttrNames>
            <Item Value="LocalUpDirectory"/>
          </AttrNames>
        </attributeValues>
      </bindings>
    </pageDefinition>and my view is
    <?xml version="1.0" encoding="windows-1252" ?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <!---->
    <ViewObject
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="SmsDocumentLinksView"
      Version="11.1.2.60.81"
      SelectList="SmsDocumentLinks.ID,
           SmsDocumentLinks.EDRMS_ID,
           SmsDocumentLinks.FILE_PLAN_NO,
           SmsDocumentLinks.DOCUMENT_NAME,
           SmsDocumentLinks.SCAN_DT,
           SmsDocumentLinks.DATE_CREATED,
           SmsDocumentLinks.DATE_MODIFIED,
           SmsDocumentLinks.MODIFIED_BY,
           SmsDocumentLinks.CREATED_BY,
           SmsDocumentLinks.DOCUMENT_IMAGE,
           SmsDocumentLinks.DITYP_ID,
           SmsDocumentLinks.DWSTA_CODE,
           SmsDocumentLinks.SOURCE_FILE_NAME"
      FromList="SMS_DOCUMENT_LINKS SmsDocumentLinks"
      BindingStyle="OracleName"
      CustomQuery="false"
      PageIterMode="Full"
      UseGlueCode="false"
      RowClass="sms4200.SmsDocumentLinksViewRowImpl"
      ComponentClass="sms4200.SmsDocumentLinksViewImpl"
      RowInterface="sms4200.common.SmsDocumentLinksViewRow"
      ClientRowProxyName="sms4200.client.SmsDocumentLinksViewRowClient">
      <DesignTime>
        <Attr Name="_codeGenFlag2" Value="Access|Coll|Prog|VarAccess"/>
        <Attr Name="_isCodegen" Value="true"/>
      </DesignTime>
      <EntityUsage
        Name="SmsDocumentLinks"
        Entity="sms4200.SmsDocumentLinks"/>
      <ViewAttribute
        Name="Id"
        IsNotNull="true"
        PrecisionRule="true"
        EntityAttrName="Id"
        EntityUsage="SmsDocumentLinks"
        AliasName="ID">
        <TransientExpression><![CDATA[(new oracle.jbo.server.SequenceImpl("SMS_CAT_SEQ",adf.object.getDBTransaction())).getSequenceNumber()]]></TransientExpression>
      </ViewAttribute>
      <ViewAttribute
        Name="EdrmsId"
        PrecisionRule="true"
        EntityAttrName="EdrmsId"
        EntityUsage="SmsDocumentLinks"
        AliasName="EDRMS_ID"/>
      <ViewAttribute
        Name="FilePlanNo"
        PrecisionRule="true"
        EntityAttrName="FilePlanNo"
        EntityUsage="SmsDocumentLinks"
        AliasName="FILE_PLAN_NO"/>
      <ViewAttribute
        Name="DocumentName"
        PrecisionRule="true"
        EntityAttrName="DocumentName"
        EntityUsage="SmsDocumentLinks"
        AliasName="DOCUMENT_NAME"/>
      <ViewAttribute
        Name="ScanDt"
        PrecisionRule="true"
        EntityAttrName="ScanDt"
        EntityUsage="SmsDocumentLinks"
        AliasName="SCAN_DT"/>
      <ViewAttribute
        Name="DateCreated"
        PrecisionRule="true"
        EntityAttrName="DateCreated"
        EntityUsage="SmsDocumentLinks"
        AliasName="DATE_CREATED"/>
      <ViewAttribute
        Name="DateModified"
        PrecisionRule="true"
        EntityAttrName="DateModified"
        EntityUsage="SmsDocumentLinks"
        AliasName="DATE_MODIFIED"/>
      <ViewAttribute
        Name="ModifiedBy"
        PrecisionRule="true"
        EntityAttrName="ModifiedBy"
        EntityUsage="SmsDocumentLinks"
        AliasName="MODIFIED_BY"/>
      <ViewAttribute
        Name="CreatedBy"
        PrecisionRule="true"
        EntityAttrName="CreatedBy"
        EntityUsage="SmsDocumentLinks"
        AliasName="CREATED_BY"/>
      <ViewAttribute
        Name="DocumentImage"
        IsQueriable="false"
        PrecisionRule="true"
        EntityAttrName="DocumentImage"
        EntityUsage="SmsDocumentLinks"
        AliasName="DOCUMENT_IMAGE"/>
      <ViewAttribute
        Name="DitypId"
        PrecisionRule="true"
        EntityAttrName="DitypId"
        EntityUsage="SmsDocumentLinks"
        AliasName="DITYP_ID"/>
      <ViewAttribute
        Name="DwstaCode"
        PrecisionRule="true"
        EntityAttrName="DwstaCode"
        EntityUsage="SmsDocumentLinks"
        AliasName="DWSTA_CODE"/>
      <ViewAttribute
        Name="SourceFileName"
        PrecisionRule="true"
        EntityAttrName="SourceFileName"
        EntityUsage="SmsDocumentLinks"
        AliasName="SOURCE_FILE_NAME"/>
    </ViewObject>Edited by: Tshifhiwa on 2012/05/30 8:57 PM

  • Problem in printing the data from database when i print inside servlet

    hi to all!
    the objective of the code below is getting the data from database table and has to send that data to the web browser using out.println .note: out - PrintWriter object
    In a getQuestion method, i am getting the data from database table and store it in String q and when i print the q within this method it is getting printed, but i got the null value when i printed the String q inside service method doPost. why..? its puzzling me.
    package servlet;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class test extends HttpServlet {
         Connection con;
         ResultSet rs;
         Statement s;
         StringBuffer q;
         StringBuffer o1;
         StringBuffer o2;
         StringBuffer o3;
         public void getQuestion() throws Exception
              if(rs.next())
                   q=new StringBuffer(rs.getString("question"));
                   o1=new StringBuffer(rs.getString("option1"));
                   o2=new StringBuffer(rs.getString("option2"));
                   o3=new StringBuffer(rs.getString("option3"));
                   System.out.println(q);
                   System.out.println(o1);
                   System.out.println(o2);
                   System.out.println(o3);
         public void connect(){
              try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con=DriverManager.getConnection("jdbc:odbc:ds","sa","server");
              s=con.createStatement();
              rs=s.executeQuery("select * from qa order by newid()");
              getQuestion();
              catch(Exception e)
                   System.out.println("erroe");
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws IOException,ServletException
              response.setContentType("text/html");
              new test().connect();
              PrintWriter out=response.getWriter();
              request.setAttribute("question", q);
              request.setAttribute("option1", o1);
              request.setAttribute("option2", o2);
              request.setAttribute("option3", o3);
              //RequestDispatcher rd=getServletContext().getRequestDispatcher("/show.jsp");
              //rd.forward(request, response);
              out.println("<html>");
    out.println("<head>");
         out.println("<title>" + "shock!!!" + "</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h2>"+"Read twice before u answer"+"<h2>");
    out.println("<p></p>");
    //why the value of q is not getting printed, instead i get null
    out.println("<h2>"+ q +"<h2>");
    out.println("how is it");
    out.println("</body>");
    out.println("</html>");
    Edited by: Mahesh_yeswecan on Nov 29, 2008 10:42 AM

    As u said , i have done a silly mistake earlier. though i have corrected the code still i am getting the same null value
    package servlet;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class test extends HttpServlet  {
         Connection con;
         ResultSet rs;
         Statement s;
         StringBuffer q;
         StringBuffer o1;
         StringBuffer o2;
         StringBuffer o3;
         public void getQuestion() throws Exception
              if(rs.next())
                   q=new StringBuffer(rs.getString("question"));
                   o1=new StringBuffer(rs.getString("option1"));
                   o2=new StringBuffer(rs.getString("option2"));
                   o3=new StringBuffer(rs.getString("option3"));
                   System.out.println(q);
                   System.out.println(o1);
                   System.out.println(o2);
                   System.out.println(o3);
         public void connect(){
              try
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              con=DriverManager.getConnection("jdbc:odbc:ds","sa","server");
              s=con.createStatement();
              rs=s.executeQuery("select * from qa order by newid()");
              getQuestion();
              catch(Exception e)
                   System.out.println("erroe");
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws IOException,ServletException
              response.setContentType("text/html");
              connect();
              PrintWriter out=response.getWriter();
              request.setAttribute("question", q);
              request.setAttribute("option1", o1);
              request.setAttribute("option2", o2);
              request.setAttribute("option3", o3);
              //RequestDispatcher rd=getServletContext().getRequestDispatcher("/show.jsp");
              //rd.forward(request, response);
              out.println("<html>");
            out.println("<head>");
             out.println("<title>" + "shock!!!" + "</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h2>"+"Read twice before u answer"+"<h2>");
            out.println("<p></p>");
            //why the value of q is not getting printed, instead i get null
            out.println("<h2>"+ q +"<h2>");
            out.println("how is it");
            out.println("</body>");
            out.println("</html>");
    }

Maybe you are looking for

  • Home Network and Multiple Switches

    Hi, I am upgrading my small office network as I have run out of ports on my Cisco SG100-24 unmanaged switch. I have purchased another SG100-24 which will give me the ports required. My question is how best to connect them. I am currently using my ISP

  • Display tag: how to get pagesize parameter from TableDecorator?

    Hi all, I'm designing�org.displaytag.decorator.TableDecorator wrapper for our project, but I need to get pagesizeparameter from TableDecorator and I don't know - how to do it :( Any ideas? ps. http://www.displaytag.org used

  • Function modules used in CG02

    Hi, Does anyone know the standard function modules or tables related to the transaction CG02. I have a requirement to fetch the plating data of certain specifications.The plating data is being displayed on the transaction.but we don't know from where

  • I have a full creative cloud subscription, do I still have to pay for Forms Central?

    I have Acrobat XI as part of my Creative Cloud subscription, why or do I have to upgrade and pay for Forms Central too, this seems a bit harsh and greedy in my opinion. I am just a single user.

  • Validate XML record-by-record

    Hi, Our process receives XML files on a daily basis and the files are processed through Java. If a record in XML fails to validate against the XSD (i.e. schema validation error), the whole file gets rejected. The file gets loaded only after that reco