Problem in showing binary data from database

Hi,
I store some image files in my Oracle database and I want to show them in JSP pages. I constructed a jsp page which returns the image, foto.jsp looks like this:
<jsp:useBean id="photo" class="BizDel.Foto" scope="session" />
<%
int iNumPhoto;
Connection conn=null;
try{
DriverManager.registerDriver(new OracleDriver());
conn=DriverManager.getConnection("jdbc:oracle:thin:@server:1521:orcl", "username", "password");
conn.setAutoCommit (false);
byte[] imgData=Foto.getPhoto(conn);
response.setContentType("image/gif");
ServletOutputStream o=response.getOutputStream();
o.write(imgData);
o.flush();
o.close();
catch(Exception e)
e.printStackTrace();
throw e;
finally
conn.close();
%>
Foto.getPhoto() returns the image file as a binary array.
In the jsp page that I want to display the image, I wrote
<img src=foto.jsp/>
I see that the image processed, but nothing is displayed in the page. When I wrote the foto.jsp directly in the address bar, the image is retrieved properly and the page tries to process it as a file(tries to find a plugin for displaying the image file, that I dont want to.).
Can anyone help?

Andi,
Thanks for your suggestion.
I tried your way. Here is the servlet code:
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
int iNumPhoto;
Connection conn=null;
if(request.getParameter("imgID")!=null){
iNumPhoto=Integer.parseInt(request.getParameter("imgID"));
try{
DriverManager.registerDriver(new OracleDriver());
conn=DriverManager.getConnection("jdbc:oracle:thin:@server:1521:orcl", "username", "password");
conn.setAutoCommit (false);
          //retrieves the photo from database, works well...
byte[] imgData=Foto.getPhoto(conn);
response.setContentType("image/gif");
OutputStream o=response.getOutputStream();
o.write(imgData);
o.flush();
o.close();
catch(Exception e)
e.printStackTrace();
throw e;
finally
try{conn.close();}catch(Exception e){}
Again, there is no exception but the page does not show the image. When I directly write the servlet in the address bar, this time nothing happens, I cannot see the image.
Any suggestions...?

Similar Messages

  • Encoding problem while reading binary data from MQ-series

    Dear all,
    we are running on 7.0 and we have an encoding problem while reading binary data from MQ-series. Because we are getting flat strings from queue we use module "Plain2ML" (MessageTransformBean) for wrapping xml-elements around the incoming data.
    The MQ-Series-Server is using CCSID 850, which we configured in connection parameters in communication channel (both parameters for Queuemanager CCSID and also CCSID of target).If there are special characters in the message (which HEX-values differ from codepage to codepage) we get errors in our adapter while executing, please see stack-trace for further analysis below.
    It seems to us that
    1. method ByteToCharUTF8.convert() expects UTF-8 in binary data
    2. Both CCSID parameters are not used anyway in JMS-adapter
    How can we solve this problem without changing anything on MQ-site?
    Here is the stack-trace:
    Catching com.sap.aii.af.mp.module.ModuleException: Transform: failed to execute the transformation: com.sap.aii.messaging.adapter.trans.TransformException: Error converting Message: 'sun.io.MalformedInputException'; nested exception caused by: sun.io.MalformedInputException caused by: com.sap.aii.messaging.adapter.trans.TransformException: Error converting Message: 'sun.io.MalformedInputException'; nested exception caused by: sun.io.MalformedInputException
        at com.sap.aii.af.modules.trans.MessageTransformBean.throwModuleException(MessageTransformBean.java:453)
        at com.sap.aii.af.modules.trans.MessageTransformBean.process(MessageTransformBean.java:387)
        at com.sap.aii.af.mp.module.ModuleLocalLocalObjectImpl0_0.process(ModuleLocalLocalObjectImpl0_0.java:103)
        at com.sap.aii.af.mp.ejb.ModuleProcessorBean.process(ModuleProcessorBean.java:292)
        at com.sap.aii.af.mp.processor.ModuleProcessorLocalLocalObjectImpl0_0.process(ModuleProcessorLocalLocalObjectImpl0_0.java:103)
        at com.sap.aii.adapter.jms.core.channel.filter.SendToModuleProcessorFilter.filter(SendToModuleProcessorFilter.java:84)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.ConvertBinaryToXiMessageFilter.filter(ConvertBinaryToXiMessageFilter.java:304)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.ConvertJmsMessageToBinaryFilter.filter(ConvertJmsMessageToBinaryFilter.java:112)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.InboundDuplicateCheckFilter.filter(InboundDuplicateCheckFilter.java:87)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.TxManagerFilter.filterSend(TxManagerFilter.java:123)
        at com.sap.aii.adapter.jms.core.channel.filter.TxManagerFilter.filter(TxManagerFilter.java:59)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.DynamicConfigurationFilter.filter(DynamicConfigurationFilter.java:72)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.PmiAgentFilter.filter(PmiAgentFilter.java:66)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.InboundCorrelationFilter.filter(InboundCorrelationFilter.java:60)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.JmsHeadersProfileFilter.filter(JmsHeadersProfileFilter.java:59)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageInvocationsFilter.filter(MessageInvocationsFilter.java:89)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.JarmMonitorFilter.filter(JarmMonitorFilter.java:57)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.filter.ThreadNamingFilter.filter(ThreadNamingFilter.java:62)
        at com.sap.aii.adapter.jms.core.channel.filter.MessageFilterContextImpl.callNext(MessageFilterContextImpl.java:195)
        at com.sap.aii.adapter.jms.core.channel.SenderChannelImpl.doReceive(SenderChannelImpl.java:263)
        at com.sap.aii.adapter.jms.core.channel.ChannelImpl.receive(ChannelImpl.java:437)
        at com.sap.aii.adapter.jms.core.connector.MessageListenerImpl.onMessage(MessageListenerImpl.java:36)
        at com.ibm.mq.jms.MQMessageConsumer$FacadeMessageListener.onMessage(MQMessageConsumer.java:399)
        at com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl$JmsProviderMessageListener.onMessage(JmsMessageConsumerImpl.java:904)
        at com.ibm.msg.client.wmq.v6.jms.internal.MQMessageConsumer.receiveAsync(MQMessageConsumer.java:4249)
        at com.ibm.msg.client.wmq.v6.jms.internal.SessionAsyncHelper.run(SessionAsyncHelper.java:537)
        at java.lang.Thread.run(Thread.java:770)
    Caused by: com.sap.aii.messaging.adapter.trans.TransformException: Error converting Message: 'sun.io.MalformedInputException'; nested exception caused by: sun.io.MalformedInputException
        at com.sap.aii.messaging.adapter.Conversion.service(Conversion.java:714)
        at com.sap.aii.af.modules.trans.MessageTransformBean.processTransform(MessageTransformBean.java:538)
        at com.sap.aii.af.modules.trans.MessageTransformBean.processTransform(MessageTransformBean.java:528)
        at com.sap.aii.af.modules.trans.MessageTransformBean.processTransform(MessageTransformBean.java:471)
        at com.sap.aii.af.modules.trans.MessageTransformBean.process(MessageTransformBean.java:364)
        ... 36 more
    Caused by: sun.io.MalformedInputException
        at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:270)
        at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:287)
        at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:337)
        at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:223)
        at java.io.InputStreamReader.read(InputStreamReader.java:208)
        at java.io.BufferedReader.fill(BufferedReader.java:153)
        at java.io.BufferedReader.readLine(BufferedReader.java:316)
        at java.io.LineNumberReader.readLine(LineNumberReader.java:176)
        at com.sap.aii.messaging.adapter.Conversion.convertPlain2XML(Conversion.java:310)
        at com.sap.aii.messaging.adapter.Conversion.service(Conversion.java:709)
        ... 40 more
    Any ideas?
    Kind regards, Stefan

    Hi Stefan,
    for the first MTB now we are using only one parameter: Transform.ContentType = text/plain;charset="ISO-8859-1"
    The second MTB, which does the XML-Wrapping, is configured like this:
    Transform.Class = com.sap.aii.messaging.adapter.Conversion
    Transform.ContentType = application/xml
    xml.conversionType = SimplePlain2XML
    xml.fieldNames = value
    xml.fieldSeparator = §%zulu§%
    xml.processFieldNames = fromConfiguration
    xml.structureTitle = payload
    Both CCSID configuration parameters from the "Source"-Tab we've set to 850.
    Now, we don't get an error anymore - sun.io.malformedInputException - , but, unfortunately, now special character conversion succeeded (we need an "ß" and we get an ISO-HEX-E1 -> á).  E1 is (different from ISO) an "ß" in 850.
    Any ideas?

  • Problem in populating jtable data from database

    hi,
    i am using JTable to retrieve data from database and show it in table. JTable
    is working fine with static data. but while retrieving from databse its giving a NullPointerException at getColumnClass() method. Below is complete source code. plzz help.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.sql.*;
    import javax.swing.table.*;
    /*jdbc connection class*/
    class connect
    Connection con;
    Statement stat;
    public connect()throws Exception
    Class.forName("org.postgresql.Driver");
    con=DriverManager.getConnection("jdbc:postgresql://localhost/dl","dl","dl");
    stat=con.createStatement();
    public ResultSet rsf(String rsstr)throws Exception
    ResultSet rs=stat.executeQuery(rsstr);
    return rs;
    public void upf(String upstr)throws Exception
    stat.executeUpdate(upstr);
    class MyTableModel extends AbstractTableModel
    private String[] columnNames = {"name","id","dep","cat","rem","chkout"};
    Object[][] data;
    public MyTableModel()
    try{
    connect conn=new connect();
    ResultSet rs3=conn.rsf("select * from usertab");
    ResultSetMetaData rsmd=rs3.getMetaData();
    int col=rsmd.getColumnCount();
    int cou=0;while(rs3.next()){cou++;}
    data=new Object[cou][col];
    System.out.println(cou+" "+col);
    ResultSet rs2=conn.rsf("select * from usertab");
    int i=0;int j=0;
    for(i=0;i<cou;i++)
    rs2.next();
    for(j=0;j<col;j++)
    data[i][j]=rs2.getString(getColumnName(j));
    System.out.println(data[0][2]);
    }catch(Exception e){System.out.println("DFD "+e);}
            public int getColumnCount() {
                return columnNames.length;
            public int getRowCount() {
                return data.length;
            public String getColumnName(int col) {
                return columnNames[col];
            public Object getValueAt(int row, int col) {
                return data[row][col];
           public Class getColumnClass(int c) {
              return getValueAt(0, c).getClass();
            public boolean isCellEditable(int row, int col) {
                if (col < 2) {
                    return false;
                } else {
                    return true;
            public void setValueAt(Object value, int row, int col) {
                data[row][col] = value;
                fireTableCellUpdated(row, col);
    class MyFrame extends JFrame
    public MyFrame()
         setSize(600,500);
         JPanel p1=new JPanel();
         p1.setBackground(new Color(198,232,189));
         JTable table = new JTable(new MyTableModel());
         table.setPreferredScrollableViewportSize(new Dimension(500,200));
         table.setBackground(new Color(198,232,189));
         JScrollPane scrollPane = new JScrollPane(table);
         scrollPane.setBackground(new Color(198,232,189));
         p1.add(scrollPane);
         getContentPane().add(p1);
    /*Main Class*/
    class test2
         public static void main(String args[])
         MyFrame fr =new MyFrame();
         fr.setVisible(true);
    }thanx

    hi nickelb,
    i had returned Object.class in the getColumnClass() method. But then i
    got NullPointerException at getRowCount() method. i could understand that the
    main problem is in data[][] object. In all the methods its returning null values as it is so declared outside the construtor. But if i declare the object inside the constructor, then the methods could not recognize the object. it seems i cant do the either ways. hope u understood the problem.
    thanx

  • Problem with displaying the data from Database on swf file.

    Hi ,
      I am new to flash.Thanks in Advance Please help me....
    Actually my requirement is my application consists a button(submit_Btn) when we click on the button(submit_Btn), each time it must to database(through servlet) and brings the data from database and places it on the flash swf file.Here my problem is for the first time when we click on the button it goes to database and place the data(which was returned from database) on the swf file.Next  when we click on the button for the second time(or anytime) it is not going  and bringing the new data from database(if some data is modified in database or not),Infact it is showing the old data(the data that was collected from previous ClickListener) only on the swf file and it is also not showing any complile time or run time error.
    my Code looks like this:
    submit_Btn.addEventListener(MouseEvent.CLICK,onCheck2);
    function onCheck2(evnt:MouseEvent):void {
    var xmlLoader:URLLoader = new URLLoader();
        var xmlurl:String = "http://localhost:8888/xmlServlet";
        var xmlrequest:URLRequest = new URLRequest(xmlurl);
    xmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
    xmlLoader.addEventListener(Event.COMPLETE, xmlcompleteHandler);
    xmlLoader.load(xmlrequest);
    function xmlcompleteHandler(event:Event):void {
        var loader:URLLoader = URLLoader(event.target);
        var succData:String=loader.data;
            var xmlData:XML = new XML();
            var xmlList:XMLList;
            xmlData = XML(loader.data);
            xmlList = xmlData.children();
            for (var i=0; i<xmlList.length(); i++) {
                for (var n=0; n<xmlData.UserHumanap[i].HumanapDot.length(); n++) {
                        var x_coordinate:Number = xmlData.UserHumanap[i].HumanapDot[n].@x;
                        var y_coordinate:Number = xmlData.UserHumanap[i].HumanapDot[n].@y;
                        var point2:Point = new Point(x_coordinate,y_coordinate);
                        var circle:Sprite = new Sprite();
                        circle.graphics.beginFill(0x00ff00);
                        circle.graphics.drawCircle(point2.x,point2.y,3);   //Placing the data as dots on the swf file
    Thanks in Advance.......Please Help me..........
    its Urgent..........
    Thanks,
    Swarthi

    Checkout following line in your code
    var xmlurl:String = "http://localhost:8888/xmlServlet";
    now change it to
    var xmlurl:String = "http://localhost:8888/xmlServlet?random="+String(MAth.random());
    I think you will get the point now

  • 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>");
    }

  • Swing Applet in JSP: problem with fetching data from database

    i am facing a problem while fetching data from database using Swing Applet plugged in a JSP page.
    // necessary import statements
    public class NewJApplet extends javax.swing.JApplet {
    private JLabel jlblNewTitle;
    private Vector vec;
    public static void main(String[] args) {
    JFrame frame = new JFrame();
    NewJApplet inst = new NewJApplet();
    frame.getContentPane().add(inst);
    ((JComponent)frame.getContentPane()).setPreferredSize(inst.getSize());
    frame.pack();
    frame.setVisible(true);
    public NewJApplet() {
    super();
    initGUI();
    private void initGUI() {
    try {
    this.setSize(542, 701);
    this.getContentPane().setLayout(null);
    jlblTitle = new JLabel();
    this.getContentPane().add(jlblTitle);
    jlblTitle.setText("TITLE");
    jlblTitle.setBounds(197, 16, 117, 30);
    jlblTitle.setFont(new java.awt.Font("Dialog",1,20));
    jlblNewTitle = new JLabel();
    this.getContentPane().add(jlblNewTitle);
    Vector vecTemp = getDBDatum(); // data fetched fm DB r stored here.
    jlblNewTitle.setText(vecTemp.get(1).toString());
    jlblNewTitle.setBounds(350, 16, 117, 30);
    jlblNewTitle.setFont(new java.awt.Font("Dialog",1,20));
    } catch (Exception e) {
    e.printStackTrace();
    }//end of initGUI()
    private Vector getDBDatum() {
    // fetches datum from oracle database and stores it in a vector
    return lvecData;
    }//end of getDBDatum()
    }//end of class
    in index.jsp page i have included the following code for calling this applet:
    <jsp:plugin type="applet" code="NewJApplet.class" codebase="applets"
    width="600" height="300">
    <jsp:fallback>Could not load applet...</jsp:fallback>
    </jsp:plugin>
    if i view it in using AppletViewer it runs perfectly and display the data in JLabel. (ie, both jlblTitle and jlblNewTitle).(ie, DATA FETCHES FROM db AND DISPLAYS PROPERLY)
    BUT IF I CLICK ON INDEX.JSP, ONLY jlblTitle APPEARS. jlblnNewTitle WILL BE BLANK(this label name is supposed to fetch from database)
    EVERY THING IS DISPAYING PROPERLY EXCEPT DATA FROM DATABASE!!!
    i signed the applet as follows :
    grant {
    permission java.security.AllPermission;
    Can any body help me to figure out the problem?

    This is the Swing Applet java code
    import java.awt.Dimension;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Vector;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.JScrollPane;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTree;
    import javax.swing.ScrollPaneConstants;
    import javax.swing.SwingConstants;
    public class HaiApplet extends javax.swing.JApplet {
         private JLabel     jlblTitle;
         private JLabel     jlblNewTitle;
         private Vector     vec;
         * main method to display this
         * JApplet inside a new JFrame.
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              NewJApplet inst = new NewJApplet();
              frame.getContentPane().add(inst);
              ((JComponent)frame.getContentPane()).setPreferredSize(inst.getSize());
              frame.pack();
              frame.setVisible(true);
         public HaiApplet() {
              super();
              initGUI();
         private void initGUI() {
              try {               
                   this.setSize(542, 701);
                   this.getContentPane().setLayout(null);
                        jlblTitle = new JLabel();
                        this.getContentPane().add(jlblTitle);
                        jlblTitle.setText("OMMS");
                        jlblTitle.setBounds(197, 16, 117, 30);
                        jlblTitle.setFont(new java.awt.Font("Dialog",1,20));
                        jlblTitle.setHorizontalAlignment(SwingConstants.CENTER);
                        jlblTitle.setForeground(new java.awt.Color(0,128,192));
                        jlblNewTitle = new JLabel();
                        this.getContentPane().add(jlblNewTitle);
                        Vector vecTemp = getDBDatum();
                        jlblNewTitle.setText(vecTemp.get(1).toString());
                        jlblNewTitle.setBounds(350, 16, 117, 30);
                        jlblNewTitle.setFont(new java.awt.Font("Dialog",1,20));     
              } catch (Exception e) {
                   e.printStackTrace();
         }//end of initGUI()
         private Vector getDBDatum() {
              Vector lvecData = new Vector(10,5);
              Connection lcon = null;
              Statement lstmt = null;
              ResultSet lrsResults = null;
              String lstrSQL = null;
              String lstrOut = null;
              try {
                   OmmsDBConnect db = new OmmsDBConnect();
                   lcon = db.connectDb();
                   lstmt = lcon.createStatement(lrsResults.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
                   lstrSQL = "select DT_ID from P_DATATABLES";
                   lrsResults = lstmt.executeQuery(lstrSQL);        
                   int i = 0;
                   lrsResults.last();
                   int length = lrsResults.getRow();
                   System.out.println(length);
                   lrsResults.beforeFirst();
                   int recCount = 0;
                   while (lrsResults.next()) {
                        recCount++;
                        lvecData.addElement(new String(lrsResults.getString("DT_ID")));
                   //     System.out.println("ID :  " + lrsResults.getString(1));
                        i++;
                   }System.out.println("here 3 out fm while");
              catch(SQLException e) {
                   System.out.print("SQLException: ");
                   System.out.println(e.getMessage());
              catch(Exception ex) {
                   lstrOut = "Exception Occured " + ex.getMessage();
              finally {
                   try {
                        lrsResults.close();
                        lstmt.close();
                        lcon.close();
                        System.out.println("[DONE]");
                   catch(Exception e) {
                        System.out.println(e);
             }//end of finally
              return lvecData;
         }//end of getDBDatum()
    }//end of classOfcourse the above code compiles and runs well. in Applet Viewer
    I plugged the above Swing Applet in a JSP page index.jsp
    <jsp:plugin type="applet" code="NewJApplet.class" codebase="applets"
                   width="600" height="300">
         <jsp:fallback>Could not load applet...</jsp:fallback>
    </jsp:plugin>Every thing is working fine in AppletViewer...But if i view this in any browser, then only the jlblTitle is displaying. jlblNewTitle is not displaying(this label name is actually fetching from thedatabase)
    can any body help me regarding this matter.? Thx in Advance.

  • How can I transfer binary data from a database to another database?

    Hi all.
    I want to transfer binary data from a MS SQL Server 2000 to anohter SQL Server 2000.
    I created JDBC(table) to JDBC(stored procedure) scenario,and
    I uploaded a JPG image file to the sender table using the java program I developed.
    The JPG data was transfered to receiver,but the transfered data was broken.
    I can't not open the file correctly.
    Can XI transfer binary data using JDBC adapter?
    The sender table structure is following.
    <b>column (data type)</b>
      id  (int 4)
      binary (binary 8000)
      flag (int 4)
    The receiver stored procedure parameter is following.
    <b>parameter (data type)</b>
       id  (smallint)
      binary (binary 8000)
      flag (smallint)
    Regards.
    Yuuki

    Hi,
    <i>Can XI transfer binary data using JDBC adapter?</i>
    Ans: Yes
    Supported JDBC Types
    http://help.sap.com/saphelp_nw04s/helpdata/en/16/9dc9ac8bc72a48b80e639abaa2e497/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    Mapping JDBC types to Java types
    http://help.sap.com/saphelp_nw04/helpdata/en/7d/79dfa72d1049bc963f4f272bb1638e/frameset.htm
    Regards,
    Prateek

  • Why is performance so slow reading binary data from a SQL Azure DB with EF6.x

    I'm running a WPF client that hits a SQL Azure DB using EF 6.x. For the most part, everything seems to be working fine. The one exception is when I try to read a large binary column.
    I am storing files in the DB as a binary column.  When I test using the local DB, everything sings.  When I switch to the Azure DB, I get timeouts when I try to read the file contents.  I have no problem saving the binary data to the DB, just
    reading it.
    I don't know how to troubleshoot this.  I looked at the Query Performance page in the Azure portal, but it doesn't time stamp anything in there and you can't clear it, so I can't correlate what's running with the queries that show up there.
    I tried to start SQL profiler against the DB, but was denied because I'm not a member of the sysadmin fixed server role.
    If I query for the data directly, it comes back quickly.  So this seems to be an Azure via EF issue.
    Any help is appreciated.
    http://digitalcamel.blogspot.com/

    Hi Digital Camel,
    Since I don't know what your scenario is, I won't argue too much about not storing binaries in your SQL DB, but still: don't store binaries in your SQL DB :). The main reason is simple: first and foremost, in both the current and future pricing tier your
    levels are defines on the size of the DB. Basically, you pay way more by storing your binaries on your SQL layer rathern than storing them elsewhere, such as Azure Storage. Second, the protocol your binaries would be downloaded over the wire is prone to network
    connectivity issues: you could use HTTP(S) or FTP instead, if you'd use Azure Storage. Last but not least, when you download the binary from your DB, you keep a connection open which in the end is a connection other users might have used to query data instead.
    However, in regard to your question, how did you "query for the data directly"? Did you try to query the data using SSMS with the Client Statistics option on? This could tell you if the problem is network, server or client related.
    Hope this helps!
    Alex

  • How do i add data from database to JTable ! Urgent

    How do i add data from database to the columns of JTable?.

    hi,
    Thanks for ur link. but this is just a part of my application which i am developing user interface in swing package for which i want to know how to show data to user in the table format where by table input data will be from the database. say something like todays activity is shown to the user in table format... So u have any idea of how to do this...

  • [webdynpro] How to get the data from database and store in Excel sheet

    Hi All-
    I am developing an application in Webdynpro and I need to provide a URL ( link ) which if clicked , need to collect the data from Database ( SQL Server ) and puts in an Excel Sheet corresponding fields and opens the sheet.....
    Please look into this issue and help me out......
    Regards,
    Cris

    Hi Cris,
    Add-on to wat santosh has pointed to:
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    (Or) If you have implemented your logic to get Database records below Blog should guide you in opening an excel with ur records.
    Exporting table data to MS-Excel Sheet(enhanced Web Dynpro Binary Cache)
    Regards,
    N.

  • Oracle form: how to retrieve data from database to pop list

    I have problem in retrieving data from database to item list in
    oracle forms.
    Can anyone help me.
    thanks.

    The next is an example but you can find this information in
    Forms Help:
    DECLARE
         G_DESCS RECORDGROUP;
         ERRCODE NUMBER;
         rg_id RECORDGROUP;
         rg_name VARCHAR2(40) := 'Descripciones';
    BEGIN
         rg_id := FIND_GROUP(rg_name);
         IF Id_Null(rg_id) THEN
         G_DESCS := Create_Group_From_Query (rg_name, 'SELECT
    DESCRIPCION DESCRIPCION, DESCRIPCION DESC2 FROM FORMAS_PAGO);
         ERRCODE := POPULATE_GROUP(G_DESCS);
         POPULATE_LIST('FORMAS_PAGO.CMBDESCRIPCION',G_DESCS);
         END IF;
    END;
    Saludos.
    Mauricio.

  • Facing a Problem while downloading the data from ALV Grid to Excel Sheet

    Hi Friends,
    Iam facing a problem while downloading the data from ALV Grid to excel sheet. This is working fine in Development server , when comes to Quality and Production servers I have this trouble.
       I have nearly 11 fields in ALV Grid and out of which one is PO number of length 10 , all the ten numbers are visible in the excel sheet if we download it from development server but when we download it from Quality or Production it is showing only 9 numbers.
    Can any one help me out in this case.

    hi...
    if this problems happens dont display the same internal as u finally got.
    just create new internal table without calling any standard data elements and domains... but the new internal table s similar like ur final internal table and move all the values to new int table.
    for eg.
    ur final internal int table for disp,
         data : begin of itab occur 0,
                        matnr like mara-matnr,
                   end of itab.
    create new like this,
               data : begin of itab occur 0,
                        matnr(12) type N,
                   end of itab.

  • Problem in displaying XML document from database

    Hi I am getting only record in printing xml file which takes from data base.
    Here is my programme.
    Document doc;
    ����public void processTable(Connection con, String tableName)
    ����{
    ��������try
    ��������{
    ������������this.iColumnCount=0;
    ������������HashMap hm = new HashMap();
    ������������//XML related Interfaces
    ������������DocumentBuilderFactory dbf;
    ������������DocumentBuilder db;
    ������������Element rootElement = null;
    Element colData = null;
    ������������Element relElement = null;
    �����
    ������������//Database relevent Interface
    ������������ResultSet rslt = null;
    ������������DatabaseMetaData dmd = null;
    ������������ResultSetMetaData rsmd= null;
    ������������//Initilize the Factory Classes
    ������������dbf = DocumentBuilderFactory.newInstance();
    ������������db = dbf.newDocumentBuilder();
    ������������doc = db.newDocument();
    ������������//Assign the root elements to document
    ������������rootElement = doc.createElement("entity");
    colData = getColMetaData(tableName);
    ������������rootElement.appendChild(colData);
    ������������doc.appendChild(rootElement);
    ������������TransformerFactory tFactory = TransformerFactory.newInstance();
    ����������������Transformer transformer = tFactory.newTransformer();
    ����������������transformer.transform(new DOMSource(doc),
    ��������������������new StreamResult(new FileOutputStream(tableName+".xml")));
    ��������} catch (Exception sqle)
    ��������{
    ����������������e.printStackTrace();
    ��������}
    ����}
    ����/**
    �����* Method getColMetaData.
    �����* @param tableName
    �����* @return Element
    �����*/
    ����private Element getColMetaData(String tableName)
    ����{
    ��������try{
    ������������ResultSet rslt = null;
    ������������ResultSetMetaData rsmd = null;
    ������������DataTypeMap dtp = new DataTypeMap();
    ������������HashMap hm = new HashMap();
    ������������hm = dtp.DataTypes();
    ������������Connection con = db.createConnection();
    ������������Statement stmt = con.createStatement();
    ������������String sQuery = "select * from " +tableName;
    ������������rslt = stmt.executeQuery(sQuery);
    ������������rsmd = rslt.getMetaData();
    ������������Element rooElement = null;
    ������������//Element currentElement =null;
    ������������iColumnCount = rsmd.getColumnCount();
    ����������������Element currentElement = null;//doc.createElement("field");
    // rootElement = doc.createElement("column");
    ����������������for (int i = 1; i <= iColumnCount; i++)
    ��������������������{
    currentElement = doc.createElement("field");
    ������������������������currentElement.setAttribute("DBFieldName",rsmd.getColumnName(i));
    ������������������������currentElement.setAttribute("FieldName",rsmd.getColumnLabel(i));
    ������������������������
    ��������������������}
    ��������������return currentElement;
    ��������catch(Exception ee){
    ������������logger.info(ee.getMessage());
    ��������}
    ��������return null;
    ����}
    Here 'return currentElement;' return the collection of elements.But when I print
    document it is giving only last element.I am not getting how only one record is printing even it has more records
    please help me in this regards.
    here the out put:
    <?xml version="1.0" encoding="UTF-8"?>
    <entity>
    ��<field DBFieldName="X_TYPE" FieldName="X_TYPE"/>
    </entity>
    -krish
    [email protected]

    Problem in displaying the XML Data from database
    Hi I have requirement of generating the XML from database.I could able to acheive partially.
    I am giving the problem below.
    public void processTable()
    Element rootElement = doc.createElement("entity");
    Element colData= getColMetaData(tableName);
    rootElement.appendChild(colData);
    doc.appendChild(rootElement);
    //print the document
    /*getColData method as follows*/
    private Element getColMetaData(String tableName)
    try{
    ResultSet rslt = null;
    ResultSetMetaData rsmd = null
    Connection con = db.createConnection();
    Statement stmt = con.createStatement();
    String sQuery = "select * from " +tableName;
    rslt = stmt.executeQuery(sQuery);
    rsmd = rslt.getMetaData();
    iColumnCount = rsmd.getColumnCount();
    Element currentElement = doc.createElement("field");
    for (int i = 1; i <= iColumnCount; i++)
    currentElement.setAttribute("FieldName",rsmd.getColumnName(i));
    currentElement.setAttribute("Position", parseString(i));
    rootElement.appendChild(currentElement);
    return currentElement;
    catch(Exception ee){
    logger.info(ee.getMessage());
    return null;
    /* End of Method*/
    Here when I printing the document it is giving out put like :
    <entity >
    <field FieldName="X_ID" Position="1"/>
    </entity>
    The is displaying only one field information even though table contains more then one column.If we maintain all the aboue code in single method it is working fine.I want to decouple the like above.Bcz I may have more then one set of elements like this.
    Please help in this regards,
    -Krish
    [email protected]

  • Problem in loading transactional data from to 0MKT_DSO1(ods) to 0MKTG_C01

    Hi,
    I am trying to load lead transaction data to the standard Crm lead management cube from ODS.There is a problem while loading transaction data from 0MKT_DSO1(ods) to the infocube 0MKTG_C01 as the field 0STATECSYS2(CRM STATUS)  is set to 10 in ods -meaning incorrect transaction. This feild is not there in the infocube.
    There is a routine in the cube that deletes data records with (0statecsys2) set to 10.
    THIS field is not coming in the transaction.
    so, where can i see the master data in crm source system? and why is that feild getting set to 10 ?
    thanks in advance!

    Thanks for the reply..
    I have checked the Fact table which shows
    1. packet Dimension
    2. Time dimension
    3. Unit dimension.
    I have kept the 0CALDAY as the time characteristics.
    Sample data i have loaded from ODS to Cube.
    Sample data in ODS.
    Sales order No_____0CALDAY_____AMOUNT
    800001___________12/02/2009____15
    I have loaded this data in Cube with Full Upload.
    Data in Cube.
    Sales order No_____0CALDAY_____AMOUNT
    800001___________12/02/2009____15
    Again i am loading the same data to cube
    Data in cube after loading.
    Sales order No_____0CALDAY_____AMOUNT
    800001___________12/02/2009____15
    800001___________12/02/2009____15
    The data is duplicated and it is not cumulating.
    Am i missing anything on this.
    Pls help..
    Thanks,
    Siva.

  • Select data from DataBase

    Hi;
    I try to select data from DataBase, But I get the following error, Could anyone help? thanks.
    Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.
    OracleDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at Lookup.main(Lookup.java:12)
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class Lookup {
        public static void main(String[] args)
            throws SQLException, ClassNotFoundException {
            String dbUrl = "jdbc:oracle:thin:@augur.scms.waikato.ac.nz:1521:comp319";
            String user = "group029";
            String password = "group029";
            // Load the driver (registers itself)
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection c = DriverManager.getConnection(dbUrl, user, password);
            Statement s = c.createStatement();
            //SQL code:
            ResultSet r =
                s.executeQuery("SELECT * " +"FROM movie");
         StringBuffer results= new StringBuffer();
            ResultSetMetaData metaData = r.getMetaData();
         int numberOfColumns = metaData.getColumnCount();
         for(int i=1; i<=numberOfColumns; i++)
             results.append(metaData.getColumnName(i)+"\t");
         results.append("\n");
         while (r.next()){
             for( int i=1; i <=numberOfColumns; i++)
              results.append(r.getObject(i)+"\t");
             results.append("\n");
         s.close();
    }

    It's a classpath problem. Either you mistyped the class name, or you don't have the class in your classpath. I think Oracle's drivers come in db12.zip or db12.jar or some such. Whatever that jar or zip file is, it has to be in your classpath, but it's not.
    Or it is in your classpath, but you're in an appserver context where the classloader that the container provides for your app uses something other than the classpath variable. For instance, in tomcat, the jar file would be uder webapps/yourApplication/WEB-INF/lib I think.

Maybe you are looking for

  • Mac computers in the office are not able to connect to our exchange server.

    We started facing this problem about a month ago in our office where the apple computers can not connect to the exchange server via outlook or applemail or anything for that matter. All the other computers can connect to the exchange server with no p

  • How do I publish and ibook for free without a credit card

    I am working with a teacher to publish her students work to the iBooks store. We are trying to download iTunes Connect.  She has tried to use her account and keeps hitting snags.  Her account information is correct but keeps getting rejected.  So I t

  • 10.5 isync3.0 doesn´t like my K800i any more. Do You know a solution?

    H, since i use leopard my K800i Sonyericsson won´t syncronize any more. isync 3.0 I tried all which used to work with 10.4.9... Installing PhonePluginfolder new -won´t do under Leopard Calender can be updated but not adressbook. In the Isync supporte

  • Safari can't run youtube or open jpeg attachments

    The latest safari can't run youtube. Just get black box. Also websites with jpeg attachments don't open. Just blank page. Turned extensions off. Reinstalled flash. Ran permissions repair. Could this be something with java? Use to work.Any help would

  • VA02 - Header Condition Tab - Pricing Authorization

    Dear all One of my requirement is that, In Sales Order VA02, VA03, VA01  - in Header level Condition tab - I want to hide the Cost Price line only. I am able to do that Detail (Item level). But header level, it shows the Cost Price. Can someone hlep