Diadem file (image) to database
Greetings all,
Recently we've found a problem with our application. Instead of exporting report images to a network unit we'll have to save them in a database.
Until now, we saved them to a network drive without any problem. We're able to access our database and insert text values from the application, but now we need to save files (images). This is where things become complicated. DIAdem offers a textStream object, but not a inputstream that allows to read a byte array...
So, anyone had a problem like this and found a solution? I've found some samples of something similar on NI site, but all of them are for labview...
Any help is greatly appreciated,
Tomas
Solved!
Go to Solution.
Sub Base64StringToFile(ByRef vCode, ByVal fullFilePath)
if FileExist(fullFilePath) then
FileDelete(fullFilePath)
end if
Dim oXML : Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
dim oNode : Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.text = vCode
Dim BinaryStream : Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = 1
BinaryStream.Open
BinaryStream.Write oNode.nodeTypedValue
BinaryStream.SaveToFile fullFilePath
Set BinaryStream = Nothing
Set oNode = Nothing
Set oXML = Nothing
End Sub
Sub Base64FileToString(ByVal fullFilePath, ByRef vCode)
Dim BinaryStream : Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = 1
BinaryStream.Open
BinaryStream.LoadFromFile(fullFilePath)
Dim oXML : Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
dim oNode : Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.nodeTypedValue = BinaryStream.Read()
vCode = oNode.text
End Sub
I used those two methods to read binary file and put it into base64 string. Maybe this helps.
Similar Messages
-
I'm trying to load a pdf file into a database like a link or image using DIADEM.
Can some help me with this?
thanks
SergioTake a look at following documents
http://digital.ni.com/public.nsf/allkb/E7D3FE1C9EECDD5F86256F43006D8ECC
http://digital.ni.com/public.nsf/allkb/60786875B7C1131A86256C080052324C
National Instruments
Applications Engineer -
How to insert an image file in Oracle database
hi
can you please tell me how to insert an image file into oracle database????
suppose there is one image file in c:\pictures\rose.jpg. how to insert that file into database? theoretically i know that will be BFILE type but i dont know how to insert that.
will be waiting for your reply........
thanks & regards,
PriyatoshHello,
The easiest way to load a blob is to use SQL loader.
This example comes from the utilities guide:
LOAD DATA
INFILE 'sample.dat'
INTO TABLE person_table
FIELDS TERMINATED BY ','
(name CHAR(20),
1 ext_fname FILLER CHAR(40),
2 "RESUME" LOBFILE(ext_fname) TERMINATED BY EOF)
Datafile (sample.dat)
Johny Quest,jqresume.txt,
Speed Racer,'/private/sracer/srresume.txt',
Secondary Datafile (jqresume.txt)
Johny Quest
500 Oracle Parkway
Secondary Datafile (srresume.txt)
Loading LOBs
10-18 Oracle Database Utilities
Speed Racer
400 Oracle Parkway
regards,
Ivo -
How to insert a image file into oracle database
hi all
can anyone guide me how to insert a image file into oracle database now
i have created table using
create table imagestore(image blob);
but when inserting i totally lost don't know what to do how to write query to insert image fileHi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
out.println(" <input type='submit' name='submit' value='Submit' class='smalltext'>");
out.println("</form>"); Import this once you have the jar file:
import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
boolean result = true;
String fileName = null;
byte fileData[] = null;
String fileUploadError = null;
String imageType = "";
String error = "";
DiskFileUpload fb = new DiskFileUpload();
List fileItems = fb.parseRequest(request);
Iterator it = fileItems.iterator();
while(it.hasNext()){
FileItem fileItem = (FileItem)it.next();
if (!fileItem.isFormField()) {
fileName = fileItem.getName();
fileData = fileItem.get();
// Get the imageType from the filename extension
if (fileName != null) {
int dotPos = fileName.indexOf('.');
if (dotPos >= 0 && dotPos != fileName.length()-1) {
imageType = fileName.substring(dotPos+1).toLowerCase();
if (imageType.equals("jpg")) {
imageType = "jpeg";
String filePath = request.getParameter("FILE_PATH");
session.setAttribute("filePath", filePath);
session.setAttribute("fileData", fileData);
session.setAttribute("fileName", fileName);
session.setAttribute("imageType", imageType);
return result;
} And now finally the method to actually write the file to the database:
private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
//If the previous code found a file that can be uploaded then
//save it into the database via a pstmt
String sql = "";
UtilDBquery udbq = getUser(request).connectToDatabase();
Connection con = null;
int signatureID = 0;
PreparedStatement pstmt = null;
try {
udbq.setUsePreparedStatements(true);
con = udbq.getPooledConnection();
con.setAutoCommit(false);
if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
pstmt = con.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
while(rs.next()) {
signatureID = rs.getInt(1);
if (fileName != null && imageType != null) {
sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
InputStream is2 = new ByteArrayInputStream(fileData);
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, signatureID);
pstmt.setBinaryStream(2, is2, (int)(fileData.length));
pstmt.executeUpdate();
pstmt.close();
con.commit();
con = null;
if(mode.equals("U") && signatureIDIn != 0) {
signatureID = signatureIDIn.intValue();
if (fileName != null && imageType != null) {
sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
InputStream is2 = new ByteArrayInputStream(fileData);
pstmt = con.prepareStatement(sql);
pstmt.setBinaryStream(1, is2, (int)(fileData.length));
pstmt.setInt(2, signatureID);
pstmt.executeUpdate();
pstmt.close();
con.commit();
con = null;
} catch (Exception e) {
con = null;
throw new Exception(e.toString());
return signatureID;
} -
Storing image files (.gif) into database from sql plus
dear all
I have to store image files into a table with BLOB attribute.
What will be the insert command to insert a .gif file into the database.
thanks.You can use DBMS_LOB.LoadFromFile, I assume you would load these as a BLOB.
The documentation can be found on technet at
urlhttp://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_20b.htm#1009007
[\url]
An alternative would be to use java to read the file from the file system, and serve it up as a CLOB or BLOB, and INSERT it into the database from there.
Good Luck,
Eric Kamradt -
How I can store Image file in a database
Can any one how i can stored image file in a database and then by using same database how i can show in HTML page...(in a browser)
This is not something that can be answered easily. There is quite alot of code involved....
To get started I suggest you read up on the built-in package 'DBMS_LOB' from Oracle . Most of what you need you should find there.
regards Dave. -
How to upload files/images to the database from a form.
I'm making a custom user profile form.
The users can update their profile in this form.
I cannot use the standard profile form, because the customer got very specific
demands about the context of the profile form.
In this custom profile form the user must be able to upload an image
from their hard disk(just like in the standard profile form).
I've got the following questions about uploading pictures:
- How do I make a button to show the explorer window.
- how do I get the chooses file-name in a field.
- how do I get the new file in the database.
- how do I get rid of an old file in the database.
- how do I get the image on the form.
Or is there a special portal way to upload images/files in a form.
Does anyone have a clue?
regards
arnyHi,
Regular Portal forms will support upload of images/documents to the database. Just identify your column as a blob, and the 'Browse' button will automatically show up in the form and the users will get to choose the file they want to upload from their desktop.
The thing is, I haven't been able to figure out how to get that document/image back out of the database (e.g. in a report), once it's put in. Maybe someone else can answer that. -
How to fetch the image file from oracle database and display it.
hi... i've inserted the image file into the oracle database... now i want to retreive it and want to display it... can anybody help me... pls
not a big deal dude... i fetched the image from database and saved it into my local hard disk.. but when tried to open it,ends up with no preview... dont know what d prob is... any idea... i've inserted the image as bytes n trying to fetch it as binary stream.. is that the problem... here im giving my insertion and retireving code.. jus go through it...
Insertion code:_
* To change this template, choose Tools | Templates
* and open the template in the editor.
package PMS;
import java.io.File;
import java.io.FileInputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Browse_java
static Connection con=null;
public static void main(String args[])
try{
System.out.println("(browse.java) just entered in to the class");
con = new PMS.DbConnection().getConnection();
System.out.println("(browse.java) connection string is"+con);
PreparedStatement ps = con.prepareStatement("INSERT INTO img_exp VALUES(?,?)");
System.out.println("(browse.java) prepare statement object is"+ps);
File file =new File("E:/vanabojanalu-/DSC02095.JPG");
FileInputStream fs = new FileInputStream(file);
System.out.println("lenth of file"+file.length());
byte blob[]=new byte[(byte)file.length()];
System.out.println("lenth of file"+blob.length);
fs.read(blob);
ps.setString(1,"E:/vanabojanalu-/DSC02095.JPG");
ps.setBytes(2, blob);
// ps.setBinaryStream(2, fs,(int)file.length());
System.out.println("(browse.java)length of picture is"+fs.available());
int i = ps.executeUpdate();
System.out.println("image inserted successfully"+i);
catch(Exception e)
e.printStackTrace();
finally
try {
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
and Retrieving code is:
* To change this template, choose Tools | Templates
* and open the template in the editor.
package PMS;
import java.beans.Statement;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.*;
import javax.servlet.http.*;
import oracle.jdbc.OracleResultSet;
* @author Administrator
public class view_image2 extends HttpServlet {
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("image/jpeg");
//PrintWriter out = response.getWriter();
try
javax.servlet.http.HttpServletResponse res=null;;
int returnValue = 0;
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
InputStream in = null;
OutputStream os = null;
Blob blob = null;
//String text;
//text=request.getParameter("text");
//Class.forName("com.mysql.jdbc.Driver");
con=new PMS.DbConnection().getConnection();
System.out.println("jus entered the class");
//String query = "SELECT B_IMAGE FROM img_exp where VC_IMG_PATH=?";
//conn.setAutoCommit(false);
PreparedStatement pst = con.prepareStatement("select b_image from img_exp where vc_img_path=?");
System.out.println("before executing the query");
pst.setString(1,"C:/Documents and Settings/Administrator/Desktop/Leader.jpg");
rs = pst.executeQuery();
//System.out.println("status of result set is"+rs.next());
System.out.println("finished writing the query");
int i=1;
if(rs.next())
System.out.println("in rs") ;
byte[] byte_image=rs.getBytes(1);
// byte blob_byte[]= new byte[(byte)blob.length()];
//System.out.println("length of byte is"+blob_byte);
//String len1 = (Oracle.sql.blob)rs.getString(1);
//System.out.println("value of string is"+len1);
//int len = len1.length();
//byte [] b = new byte[len];
//in = rs.getBinaryStream(1);
int index = in.read(byte_image, 0, byte_image.length);
System.out.println("value of in and index are"+in+" "+index);
FileOutputStream outImej = new FileOutputStream("C://"+i+".JPG");
//FileOutputStream fos = new FileOutputStream (imgFileName);
BufferedOutputStream bos = new BufferedOutputStream (outImej);
//byte [] byte_array = new byte [blob_byte.length]; //assuming 512k size; you can vary
//this size depending upon avlBytes
//int bytes_read = in.read(blob_byte);
bos.write(index);
/*while (index != -1)
outImej.write(blob_byte, 0, index);
index = in.read(blob_byte, 0, blob_byte.length);
//System.out.println("==========================");
//System.out.println(index);
//System.out.println(outImej);
//System.out.println("==========================");
/*ServletOutputStream sout = response.getOutputStream(outImej);
for(int n = 0; n < blob_byte.length; n++) {
sout.write(blob_byte[n]);
sout.flush();
sout.close();*/
outImej.close();
//i++;
else
returnValue = 1;
catch(Exception e)
System.out.println("SQLEXCEPTION : " +e);
finally {
//out.close();
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
* Returns a short description of the servlet.
public String getServletInfo() {
return "Short description";
// </editor-fold>
} -
Not able to download image from database
not able to download image from database am in jdeveloper 11g release 2 am using this example
: http://tompeez.wordpress.com/2011/11/26/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-2/
hi am not able to down load my image my jsp xml is
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document title="sms4200.jspx" id="d1">
<af:messages id="m1"/>
<af:form id="f1" usesUpload="true">
<af:panelStretchLayout topHeight="211px" id="psl1" inlineStyle="width:1338px; background-color:Navy;">
<f:facet name="top">
<af:panelHeader text="Sms Intergration Sources" id="ph1">
<f:facet name="context"/>
<f:facet name="menuBar"/>
<f:facet name="toolbar"/>
<f:facet name="legend"/>
<f:facet name="info"/>
<af:panelStretchLayout id="psl2" inlineStyle="height:178px; width:1018px;" topHeight="22px"
endWidth="589px" startWidth="55px" bottomHeight="33px">
<f:facet name="end">
<af:panelHeader text="Office" id="ph2"
inlineStyle="width:900px; background-color:Navy;">
<f:facet name="context"/>
<f:facet name="menuBar"/>
<f:facet name="toolbar"/>
<f:facet name="legend"/>
<f:facet name="info"/>
<af:panelFormLayout id="pfl3" inlineStyle="background-color:Navy;" rows="1">
<f:facet name="footer"/>
<af:inputText label="#{bindings.Name1.hints.label}"
required="#{bindings.Name1.hints.mandatory}"
columns="20"
maximumLength="#{bindings.Name1.hints.precision}"
shortDesc="#{bindings.Name1.hints.tooltip}" id="it2">
<f:validator binding="#{bindings.Name1.validator}"/>
</af:inputText>
<af:inputText
label="#{bindings.LocalUpDirectory1.hints.label}"
required="#{bindings.LocalUpDirectory1.hints.mandatory}"
columns="20"
maximumLength="#{bindings.LocalUpDirectory1.hints.precision}"
shortDesc="#{bindings.LocalUpDirectory1.hints.tooltip}"
id="it3">
<f:validator binding="#{bindings.LocalUpDirectory1.validator}"/>
</af:inputText>
</af:panelFormLayout>
</af:panelHeader>
</f:facet>
<f:facet name="top">
<af:inputText value="#{bindings.IntegrationTypeName1.inputValue}"
label="#{bindings.IntegrationTypeName1.hints.label}"
required="#{bindings.IntegrationTypeName1.hints.mandatory}"
columns="#{bindings.IntegrationTypeName1.hints.displayWidth}"
maximumLength="#{bindings.IntegrationTypeName1.hints.precision}"
shortDesc="#{bindings.IntegrationTypeName1.hints.tooltip}" id="it1">
<f:validator binding="#{bindings.IntegrationTypeName1.validator}"/>
</af:inputText>
</f:facet>
</af:panelStretchLayout>
</af:panelHeader>
</f:facet>
<f:facet name="center">
<!-- id="af_one_column_header_stretched" -->
<af:decorativeBox theme="dark" id="db1" inlineStyle="width:1050px; background-color:Navy;">
<f:facet name="center">
<af:panelGroupLayout layout="scroll" id="pgl3" inlineStyle="background-color:Navy;">
<af:panelStretchLayout id="psl3" inlineStyle="width:1012px; height:502px;"
topHeight="133px" startWidth="0px">
<f:facet name="center">
<af:panelStretchLayout id="psl5" endWidth="659px" startWidth="171px">
<f:facet name="center"/>
<f:facet name="start"/>
<f:facet name="end">
<af:panelGroupLayout layout="scroll" id="pgl2">
<af:inputFile label="Select Image" id="if1" autoSubmit="true"
valueChangeListener="#{ImageBean.uploadFileValueChangeEvent}"/>
<af:commandButton actionListener="#{bindings.CreateInsert.execute}"
text="Restart Load Image Process"
disabled="#{!bindings.CreateInsert.enabled}"
id="cb2"/>
<af:commandButton actionListener="#{bindings.Commit.execute}"
text="Save"
disabled="#{!bindings.Commit.enabled}"
id="cb3"/>
<af:commandButton text="View" id="cb1"
partialSubmit="true"
unsecure="#{ImageBean.downloadButton}"
action="#{image.downloadImage}"
binding="#{image2.downloadButton}"/>
</af:panelGroupLayout>
</f:facet>
<f:facet name="top"/>
</af:panelStretchLayout>
</f:facet>
<f:facet name="start"/>
<f:facet name="top">
<af:panelStretchLayout id="psl4" startWidth="232px" endWidth="296px"
bottomHeight="18px" topHeight="11px">
<f:facet name="bottom"/>
<f:facet name="center"/>
<f:facet name="start">
<af:panelFormLayout id="pfl1" labelAlignment="top">
<f:facet name="footer"/>
<af:inputText label="File from PC to be Transfered" id="it4"/>
</af:panelFormLayout>
</f:facet>
<f:facet name="end">
<af:panelFormLayout id="pfl2" labelAlignment="top" maxColumns="10">
<f:facet name="footer">
<af:inputText value="#{bindings.DocumentName.inputValue}"
label="File Transfered to Database"
required="#{bindings.DocumentName.hints.mandatory}"
columns="50"
rows="1"
maximumLength="#{bindings.DocumentName.hints.precision}"
shortDesc="#{bindings.DocumentName.hints.tooltip}"
id="it5" simple="false">
<f:validator binding="#{bindings.DocumentName.validator}"/>
</af:inputText>
</f:facet>
</af:panelFormLayout>
</f:facet>
<f:facet name="top"/>
</af:panelStretchLayout>
</f:facet>
</af:panelStretchLayout>
</af:panelGroupLayout>
</f:facet>
</af:decorativeBox>
</f:facet>
</af:panelStretchLayout>
</af:form>
</af:document>
</f:view>
</jsp:root>
and my log file is
<ViewHandlerImpl> <_checkTimestamp> Apache Trinidad is running with time-stamp checking enabled. This should not be used in a production environment. See the org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION property in WEB-INF/web.xml
<UIXEditableValue> <_isBeanValidationAvailable> A Bean Validation provider is not present, therefore bean validation is disabled
the method am calling is
public BlobDomain downloadImage() {
FacesContext facesContext = null;
OutputStream outputStream = null;
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
// get an ADF attributevalue from the ADF page definitions
AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("Documentimage");
if (attr == null) {
return null;
// the value is a BlobDomain data type
BlobDomain blob = (BlobDomain)attr.getInputValue();
try { // copy hte data from the BlobDomain to the output stream
IOUtils.copy(blob.getInputStream(), outputStream);
// cloase the blob to release the recources
blob.closeInputStream();
// flush the outout stream
outputStream.flush();
} catch (IOException e) {
// handle errors
e.printStackTrace();
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), "");
FacesContext.getCurrentInstance().addMessage(null, msg);
return blob;
}i get this error when clicking the button
error when not able to download image
<BeanHandler> <getStructure> Failed to build StructureDefinition for : sms4200.ImageBean
<UIXEditableValue> <_isBeanValidationAvailable> A Bean Validation provider is not present, therefore bean validation is disabled
Edited by: Tshifhiwa on 2012/06/03 10:53 AM
Edited by: Tshifhiwa on 2012/06/03 10:56 AM
Edited by: Tshifhiwa on 2012/06/03 10:57 AMhi i try to run your sample am geting this error
Error 500--Internal Server Error
oracle.jbo.DMLException: JBO-27200: JNDI failure. Unable to lookup Data Source at context jdbc/HRDS
at oracle.jbo.server.DBTransactionImpl.lookupDataSource(DBTransactionImpl.java:1453)
at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(DBTransactionImpl2.java:329)
at oracle.jbo.common.ampool.DefaultConnectionStrategy.connect(DefaultConnectionStrategy.java:203)
at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolConnect(ApplicationPoolMessageHandler.java:600)
at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolMessage(ApplicationPoolMessageHandler.java:417)
at oracle.jbo.server.ApplicationModuleImpl.doPoolMessage(ApplicationModuleImpl.java:8972)
at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(ApplicationPoolImpl.java:4606)
at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareApplicationModule(ApplicationPoolImpl.java:2536)
at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:2346)
at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:3245)
at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:571)
at oracle.jbo.http.HttpSessionCookieImpl.useApplicationModule(HttpSessionCookieImpl.java:234)
at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:504)
at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:499)
at oracle.adf.model.bc4j.DCJboDataControl.initializeApplicationModule(DCJboDataControl.java:517)
at oracle.adf.model.bc4j.DCJboDataControl.getApplicationModule(DCJboDataControl.java:867)
at oracle.adf.model.binding.DCDataControl.setErrorHandler(DCDataControl.java:487)
at oracle.jbo.uicli.binding.JUApplication.setErrorHandler(JUApplication.java:261)
at oracle.adf.model.BindingContext.put(BindingContext.java:1318)
at oracle.adf.model.binding.DCDataControlReference.getDataControl(DCDataControlReference.java:247)
at oracle.adf.model.BindingContext.instantiateDataControl(BindingContext.java:1020)
at oracle.adf.model.dcframe.DataControlFrameImpl.doFindDataControl(DataControlFrameImpl.java:1645)
at oracle.adf.model.dcframe.DataControlFrameImpl.internalFindDataControl(DataControlFrameImpl.java:1514)
at oracle.adf.model.dcframe.DataControlFrameImpl.findDataControl(DataControlFrameImpl.java:1474)
at oracle.adf.model.BindingContext.internalFindDataControl(BindingContext.java:1150)
at oracle.adf.model.BindingContext.get(BindingContext.java:1103)
at oracle.adf.model.binding.DCParameter.evaluateValue(DCParameter.java:82)
at oracle.adf.model.binding.DCParameter.getValue(DCParameter.java:111)
at oracle.adf.model.binding.DCBindingContainer.getChildByName(DCBindingContainer.java:2748)
at oracle.adf.model.binding.DCBindingContainer.internalGet(DCBindingContainer.java:2796)
at oracle.adf.model.binding.DCExecutableBinding.get(DCExecutableBinding.java:115)
at oracle.adf.model.binding.DCUtil.findSpelObject(DCUtil.java:329)
at oracle.adf.model.binding.DCBindingContainer.evaluateParameterWithElCheck(DCBindingContainer.java:1478)
at oracle.adf.model.binding.DCBindingContainer.findDataControl(DCBindingContainer.java:1608)
at oracle.adf.model.binding.DCIteratorBinding.initDataControl(DCIteratorBinding.java:2542)
at oracle.adf.model.binding.DCIteratorBinding.getDataControl(DCIteratorBinding.java:2477)
at oracle.adf.model.binding.DCIteratorBinding.getAttributeDefs(DCIteratorBinding.java:3319)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.fetchAttrDefs(JUCtrlValueBinding.java:514)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttributeDefs(JUCtrlValueBinding.java:465)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttributeDef(JUCtrlValueBinding.java:541)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttributeDef(JUCtrlValueBinding.java:531)
at oracle.jbo.uicli.binding.JUCtrlValueBinding$1JUAttributeDefHintsMap.(JUCtrlValueBinding.java:4104)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getAttributeHintsMap(JUCtrlValueBinding.java:4211)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.getHints(JUCtrlValueBinding.java:2564)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.internalGet(JUCtrlValueBinding.java:2389)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlAttrsBinding.internalGet(FacesCtrlAttrsBinding.java:275)
at oracle.adf.model.binding.DCControlBinding.get(DCControlBinding.java:749)
at javax.el.MapELResolver.getValue(MapELResolver.java:164)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(Unknown Source)
at com.sun.el.ValueExpressionImpl.getValue(Unknown Source)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at org.apache.myfaces.trinidad.bean.FacesBeanImpl.getProperty(FacesBeanImpl.java:73)
at oracle.adfinternal.view.faces.renderkit.rich.LabelLayoutRenderer.getLabel(LabelLayoutRenderer.java:929)
at oracle.adfinternal.view.faces.renderkit.rich.LabelLayoutRenderer.encodeAll(LabelLayoutRenderer.java:213)
at oracle.adfinternal.view.faces.renderkit.rich.LabeledInputRenderer.encodeAll(LabeledInputRenderer.java:215)
at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
at oracle.adfinternal.view.faces.renderkit.rich.PanelFormLayoutRenderer._encodeFormItem(PanelFormLayoutRenderer.java:1088)
at oracle.adfinternal.view.faces.renderkit.rich.PanelFormLayoutRenderer.access$100(PanelFormLayoutRenderer.java:50)
at oracle.adfinternal.view.faces.renderkit.rich.PanelFormLayoutRenderer$FormColumnEncoder.processComponent(PanelFormLayoutRenderer.java:1604)
at oracle.adfinternal.view.faces.renderkit.rich.PanelFormLayoutRenderer$FormColumnEncoder.processComponent(PanelFormLayoutRenderer.java:1523)
at org.apache.myfaces.trinidad.component.UIXComponent.processFlattenedChildren(UIXComponent.java:187)
at org.apache.myfaces.trinidad.component.UIXComponent.processFlattenedChildren(UIXComponent.java:318)
at org.apache.myfaces.trinidad.component.UIXComponent.encodeFlattenedChildren(UIXComponent.java:283)
at oracle.adfinternal.view.faces.renderkit.rich.PanelFormLayoutRenderer._encodeChildren(PanelFormLayoutRenderer.java:420)
at oracle.adfinternal.view.faces.renderkit.rich.PanelFormLayoutRenderer.encodeAll(PanelFormLayoutRenderer.java:208)
at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
at oracle.adfinternal.view.faces.renderkit.rich.PanelGroupLayoutRenderer._encodeChild(PanelGroupLayoutRenderer.java:447)
at oracle.adfinternal.view.faces.renderkit.rich.PanelGroupLayoutRenderer.access$1500(PanelGroupLayoutRenderer.java:30)
at oracle.adfinternal.view.faces.renderkit.rich.PanelGroupLayoutRenderer$EncoderCallback.processComponent(PanelGroupLayoutRenderer.java:734)
at oracle.adfinternal.view.faces.renderkit.rich.PanelGroupLayoutRenderer$EncoderCallback.processComponent(PanelGroupLayoutRenderer.java:637)
at org.apache.myfaces.trinidad.component.UIXComponent.processFlattenedChildren(UIXComponent.java:187)
at org.apache.myfaces.trinidad.component.UIXComponent.processFlattenedChildren(UIXComponent.java:318)
at org.apache.myfaces.trinidad.component.UIXComponent.encodeFlattenedChildren(UIXComponent.java:283)
at oracle.adfinternal.view.faces.renderkit.rich.PanelGroupLayoutRenderer.encodeAll(PanelGroupLayoutRenderer.java:360)
at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer.encodeCenterFacet(PanelStretchLayoutRenderer.java:879)
at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer._encodeCenterPane(PanelStretchLayoutRenderer.java:1294)
at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer._encodeMiddlePanes(PanelStretchLayoutRenderer.java:351)
at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer.encodeAll(PanelStretchLayoutRenderer.java:316)
at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
at oracle.adf.view.rich.render.RichRenderer.encodeStretchedChild(RichRenderer.java:2194)
at oracle.adfinternal.view.faces.renderkit.rich.RegionRenderer.access$400(RegionRenderer.java:50)
at oracle.adfinternal.view.faces.renderkit.rich.RegionRenderer$ChildEncoderCallback.processComponent(RegionRenderer.java:707)
at oracle.adfinternal.view.faces.renderkit.rich.RegionRenderer$ChildEncoderCallback.processComponent(RegionRenderer.java:692)
at org.apache.myfaces.trinidad.component.UIXComponent.processFlattenedChildren(UIXComponent.java:187)
at org.apache.myfaces.trinidad.component.UIXComponent.processFlattenedChildren(UIXComponent.java:318)
at org.apache.myfaces.trinidad.component.UIXComponent.encodeFlattenedChildren(UIXComponent.java:283)
at oracle.adfinternal.view.faces.renderkit.rich.RegionRenderer._encodeChildren(RegionRenderer.java:297)
at oracle.adfinternal.view.faces.renderkit.rich.RegionRenderer.encodeAll(RegionRenderer.java:186)
at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
at oracle.adf.view.rich.component.fragment.UIXRegion.encodeEnd(UIXRegion.java:323)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer.encodeCenterFacet(PanelStretchLayoutRenderer.java:879)
at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer._encodeCenterPane(PanelStretchLayoutRenderer.java:1294)
at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer._encodeMiddlePanes(PanelStretchLayoutRenderer.java:351)
at oracle.adfinternal.view.faces.renderkit.rich.PanelStretchLayoutRenderer.encodeAll(PanelStretchLayoutRenderer.java:316)
at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:641)
at oracle.adf.view.rich.render.RichRenderer.encodeAllChildrenInContext(RichRenderer.java:3062)
at oracle.adfinternal.view.faces.renderkit.rich.FormRenderer.encodeAll(FormRenderer.java:274)
at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
at oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:641)
at oracle.adf.view.rich.render.RichRenderer.encodeAllChildrenInContext(RichRenderer.java:3062)
at oracle.adfinternal.view.faces.renderkit.rich.DocumentRenderer.encodeAll(DocumentRenderer.java:1277)
at oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
at oracle.adfinternal.view.faces.component.AdfViewRoot.encodeAll(AdfViewRoot.java:91)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)
at org.apache.myfaces.trinidadinternal.application.ViewDeclarationLanguageFactoryImpl$ChangeApplyingVDLWrapper.renderView(ViewDeclarationLanguageFactoryImpl.java:350)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:165)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:1027)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:334)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:232)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:122)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: javax.naming.NameNotFoundException: While trying to lookup 'jdbc.HRDS' didn't find subcontext 'jdbc'. Resolved ''; remaining name 'jdbc/HRDS'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at oracle.jbo.server.DBTransactionImpl.lookupDataSource(DBTransactionImpl.java:1439)
... 190 more
my connection.xml is
<?xml version = '1.0' encoding = 'UTF-8'?>
<References xmlns="http://xmlns.oracle.com/adf/jndi">
<Reference name="HRDS" className="oracle.jdeveloper.db.adapter.DatabaseProvider" credentialStoreKey="HRDS" xmlns="">
<Factory className="oracle.jdeveloper.db.adapter.DatabaseProviderFactory"/>
<RefAddresses>
<StringRefAddr addrType="sid">
<Contents>smsdev</Contents>
</StringRefAddr>
<StringRefAddr addrType="subtype">
<Contents>oraJDBC</Contents>
</StringRefAddr>
<StringRefAddr addrType="port">
<Contents>1521</Contents>
</StringRefAddr>
<StringRefAddr addrType="hostname">
<Contents>localhost</Contents>
</StringRefAddr>
<StringRefAddr addrType="user">
<Contents>hr</Contents>
</StringRefAddr>
<SecureRefAddr addrType="password"/>
<StringRefAddr addrType="oraDriverType">
<Contents>thin</Contents>
</StringRefAddr>
</RefAddresses>
</Reference>
</References>
Edited by: Tshifhiwa on 2012/06/04 2:20 PM -
Insert PDF or Doc file to the Database from Frontend
Hi
I am in ISB company working with Oracle 9iDS. The scenario is to me that I would like to insert some document files(especially Pdf formated files) to the database.
I can use Read_Image_file. but that is used for the image file to bring the image file from physical location to my application, how it is for PDF?
and how can i save it in the database?
thanks
farhadSo are you saying you want to load a file from the pc/client to the database - then you can use webutil.
see otn.oracle.com/products/forms
Regards
Grant Ronald
Forms Product Management -
How To Store pdf or doc file in Oracle Database using Java Jdbc?
can any one help me out How To Store pdf or doc file in Oracle Database using Java Jdbc in JSP/Serlet? i tried like anything. using blob also i tried. but i am able 2 store images in DB not files. please if u know or else if u have some code like this plz send that to me, and help me out plz. i need that urgent.
Hi.. i am not getting error, But i am not getting the original contents from my file. i am getting all ASCII vales, instead of my original data. here i am including my code.
for Adding PDF in DB i used image.jsp
Database table structure (table name. pictures )
Name Null? Type
ID NOT NULL NUMBER(11)
IMAGE BLOB
<%@ page language="java" import="java.util.*,java.sql.*,java.io.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
PreparedStatement ps,pstmt,psmnt;
ps = con.prepareStatement("INSERT INTO pictures VALUES(?,?)");
File file =
new File("D:/info.pdf");
FileInputStream fs = new FileInputStream(file);
ps.setInt(1,4);
ps.setBinaryStream(2,fs,fs.available());
int i = ps.executeUpdate();
if(i!=0){
out.println("<h2>PDF inserted successfully");
else{
out.println("<h2>Problem in image insertion");
catch(Exception e){
out.println("<h2>Failed Due To "+e);
%>
O/P: PDF inserted successfully
i tried to display that pdf using servlet. i am giving the code below.
import java.io.IOException;
import java.sql.*;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DispPDF extends HttpServlet {
* The doGet method of the servlet. <br>
* This method is called when a form has its tag value method equals to get.
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//response.setContentType("text/html"); i commented. coz we cant use response two times.
//PrintWriter out = response.getWriter();
try{
InputStream sPdf;
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
PreparedStatement ps,pstmt,psmnt;
psmnt = con.prepareStatement("SELECT image FROM pictures WHERE id = ?");
psmnt.setString(1, "4"); // here integer number '4' is image id from the table.
ResultSet rs = psmnt.executeQuery();
if(rs.next()) {
byte[] bytearray = new byte[1048576];
//out.println(bytearray);
int size=0;
sPdf = rs.getBinaryStream(1);
response.reset();
response.setContentType("application/pdf");
while((size=sPdf.read(bytearray))!= -1 ){
//out.println(size);
response.getOutputStream().write(bytearray,0,size);
catch(Exception e){
System.out.println("Failed Due To "+e);
//out.println("<h2>Failed Due To "+e);
//out.close();
OP
PDF-1.4 %âãÏÓ 2 0 obj <>stream x+är á26S°00SIá2PÐ5´1ôÝ BÒ¸4Ü2KüsSSS4C²ê Pkø$VãGÒU×713CkW )(Ü endstream endobj 4 0 obj <>>>/MediaBox[0 0 595 842]>> endobj 1 0 obj <> endobj 3 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj xref 0 7 0000000000 65535 f 0000000325 00000 n 0000000015 00000 n 0000000413 00000 n 0000000168 00000 n 0000000464 00000 n 0000000509 00000 n trailer <<01b2fa8b70ac262bfa939cc786f8770c>]/Root 5 0 R/Size 7/Info 6 0 R>> startxref 641 %%EOF
plz help me out. -
How to place an image in database and how to retrieve and display it in the front end
how to place an image in database and how to retrieve and display it in the front end
and to place an image in database and retrieve the image from database using xml
please,help me out.Create a table with a Long RAW Datatype column for storing the Image Column Data.
Create the form based on the table , which by defaults the column with LONG RAW atatype to a Image Item.
You can use Forms Built in function READ_IMAGE_FILE to read a Image file stored on the file system in to the image item.
A save on the form saves the image in the Image item in the long raw column. -
Insert Image in database from Java Prog, but some excp. occured
I want to insert the content of an Image file into my database, but I am getting the below exception.
I am reading the file and taking the content into a string. The string displays perfectly (if I print the string using system.out.println statement) but while inserting into database it gives problem.
Following is my code::
import java.io.*;
import java.sql.*;
public class ImageInsert
public static void main(String args[])
try
DataInputStream dis = new DataInputStream(new FileInputStream("reshmi.gif"));
String str="" , ImageContent="";
while((str = dis.readLine()) != null )
ImageContent = ImageContent + str;
//System.out.println("Content :"+ str);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:somedata" , "sa" , "");
Statement st = con.createStatement();
String as = "INSERT INTO TESTIMAGE (ImageFile) VALUES(\"" + ImageContent + "\")" ;
int q = st.executeUpdate(as);
System.out.println("The data Inserted:"+q);
}catch(Exception er) {er.printStackTrace();}
// end of code
Where as if I insert it manually in my SQL Server executing the insert statement it inserts the image perfectly:
Following Exceptions I am receivng :
*********** BELOW IS THE EXCEPTION********
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation m
ark before the character string 'GIF89a��'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Compiled Code)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:4246)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:1172)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:206)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:163)It looks like imageContent contains a quote character, making your statement invalid. Something like
Insert into .... value("<some chars>..."...<some chars>")
Using single quotes will not resolve this problem since imageContent could also contains single quote chars.
Try using BLOBs instead strings. I don't know if SQLServer supports BLOBs but Oracle does.
JCG -
i want to insert a image in database(mysql) using servlet/jsp.
please help me outtry it using file IO. when the file is read and store that in object and then try to insert
-
FileNotFoundException Uploading image to database
Hello
I'm trying to upload image to databases, in my server it works perfectly but when i run the application in the hosting appear FileNotFoundException.
This is the part of html file than call to servlet.
<FORM ACTION="http://hosting/servlet/lordcyb3r.Connect">
<center><h4><b>Insert image</b></h4></center><BR><BR>
Name:
<input type="text" class="bginput" name="nombre" value="" size="40"/><BR>
<input type="hidden" name="c" value=""/>
<input type="file" class="bginput" name="image" size="40"/><BR>
Comment:
<input type="text" class="bginput" name="comentario" value="" size="60"/><BR>
<INPUT TYPE="SUBMIT" VALUE="Insert">
</FORM>
This is the get method of Connect servlet
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String nombre = request.getParameter("nombre");
String ruta = request.getParameter("image");
String comentario = request.getParameter("comentario");
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection connection = DriverManager
.getConnection("jdbc:mysql://host/db?user=userid&password=psw");
PreparedStatement ps = connection
.prepareStatement("insert into imagedata values ( ?, ?, ?, ? )");
ps.setString(1, nombre);
ps.setString(2, ruta.substring(ruta.lastIndexOf("/") + 1));
ps.setString(3, ruta.substring(ruta.lastIndexOf(".") + 1));
ps.setString(4, comentario);
ps.execute();
ps = connection
.prepareStatement("insert into image values ( ?, ? )");
File file = new File(request.getParameter("image"));
InputStream is = new FileInputStream(file); // LINE 86 <--- HERE IS THE EXCEPTION
ps.setString(1, nombre);
ps.setBinaryStream(2, is, (int) file.length());
ps.execute();
is.close();
connection.close();
out.println("<br><br>Imagen insertada con �xito");
} catch (InstantiationException e) {
out.println("<br><br>InstantiationException");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
out.println("<br><br>IllegalAccessException");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
out.println("<br><br>ClassNotFoundException");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e1) {
out.println("<br><br>SQLException");
// TODO Auto-generated catch block
e1.printStackTrace();
This is the StackTrace.
java.io.FileNotFoundException: G-Natalia Duque.jpg (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at lordcyb3r.Connect.doGet(Connect.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:95)
at com.caucho.server.http.Invocation.service(Invocation.java:291)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:339)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:268)
at com.caucho.server.TcpConnection.run(TcpConnection.java:136)
at java.lang.Thread.run(Thread.java:602)
Can you help me?
I think so the method is searching the image in the server and no in the client.
If is this, How can i do it works?
Thanks for your help.to upload the file basic thump rule is the form type is multipart form data and method should be post.
u have to use any upload component to upload the file from the client machine to the server and then u have to upload it to the database
baiju
Maybe you are looking for
-
EFI Bios overriding installer - Malware ?
Hi, it seems there's something living in this machine's bios. After numerous system reinstall attempts (including full drive format using a linux bootable USB to force a DD wipe), and installing from the internet issues persist. The Machine (Macboo
-
Exchange 2013 SP1 Install fails on step 5 of 9: Mailbox Role: Mailbox Service
We have exchange installed on a windows 2008 R2 box. We keep getting the following error when we try to install the update: Error: The following error was generated when "$error.Clear(); if ($RoleIsDatacenter -ne $true -and $RoleIsDatacent
-
Any help anyone can give?
-
hi guys, i am using monthly lot size"MB" for all my raw/packaging materials. PROBLEM : material "M1" has leadtime as 30 days(25 days + 5 days QC) This material is part of Bill of matwrial of Finished good "FG1" Now suppose if i put requirement of FG1
-
Hi guys, I'm starting to work in PL/SQL. I've got some experience in ms sql server with T-SQL and I'm trying to understand some PL basis. What I want to do, is a stored procedure that returns the result of a given query. Thats a simple thing to do in