Retrieve image from database to non-database item
Hello
I need to load in a non database item, a image stored in a long raw field in the database.
The READ_IMAGE_FILE works fine to read from a file and to save the image in the database, but how I load the image in a block in a non database item?
Any suggestions???
Thanks!!!
Hi, thanks for your comments...
I need to display in non-db-items because I have a form that dynamically fills an matrix of items from various tables. For example one data is on the table A, another data in table B and image is stored in the table C.
A process dynamically obtains each data where needed and fill the matrix based in a previous criteria.
Possibly this management can be adapted so that the image is read into db-items in my form, however I would like to know if there is a simpler way to do that, without having to change my code.
Thanks!
Similar Messages
-
Retrieve image from my sql database using jsp
I want to retrieve image from my sql (blob type) & save it in given relative path in server .(using jsp and servlets)
please give me some sample codes.PreparedStatement pst = null;
ResultSet rs=null;
pst = conn.prepareStatement("select image from imagedetails where imageid='"+imageid+"'");
rs=pst.executeQuery();
while(rs.next())
byte[] b=rs.getBytes("image");
FileOutputStream fos=new FileOutputStream("c://image.jpg");
fos.write(b);
} hi this the code to retrieve the image from DB and write to a file. -
JAVA, sqlserver - Need to load an image from the sql server database
hi,
I need to load an image from the sql server database using java. I have connected to the database and getting all other records except the records for a photo (datatype = LONGVARBINARY) and Remarks (datatype = LONGVARCHAR).
I am using java and sql server db. The photo and remarks are stored in the db. and i need to show the image and the remarks fetching them from there.
I get the error :
Thread-9 org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
How can I achieve this?
Thanks,
GargiExactly. And are you using MySQL?
No. You are using Microsoft SQL server if I have to believe your initial post. A quick google tells me that the dialect class to use is:
org.hibernate.dialect.SQLServerDialect -
Using Java to Retrieve Images from Oracle
OracleResultSet.getCustomDatum method is deprecated. I was using this method to retrieve an ORDImage from an Oracle 9i database. What are developers using instead of getCustomDatum to retrieve images from the database. Thanks for all help in this matter.
Hi use getBinaryStream(java.lang.String) or getBinaryStream(int) of java.sql.ResultSet for retrieving images from database
Hope it will be useful
regards
chandru -
Question on retrieve image from mysql
i want to retrieve image from mysql database and display on GUI
can anyone tell me how to do
Thank youYou can use the JDBC API for Java Database Connectivity. With this you can obtain data from the database using Java. There is an excellent tutorial here at Sun.com: http://www.google.com/search?q=jdbc+tutorial+site:sun.com You can get the MySQL JDBC driver at their own site: http://www.google.com/search?q=download+jdbc+driver+site:mysql.com Get the most recent version which suits your environment. There is also good documentation available over there.
For displaying in the UI, the approach differs per UI. As you didn't mention which UI you are using, I can't help you further in detail. -
Retrieving image from database in form 6i
hello all
i'm working on form 6i...
i have uploded images into the database of customers in my application using READ_IMAGE_FILE.. IT IS FINE...
But when i am trying retrieves records into the form.... i'm getting all the data except image... Image field is showing empty..
How can i get image from database to form
can u plz help me.....
thanksWhat data type you used for storing image in database. If it is long raw, then you can place an image item within your data block on form and associate it with the column name. This should populate the image by itself.
Below para is from Forms Help.
Image items can be populated in the following ways:
+1. a fetch from a LONG RAW database column+
An image item in a data block is populated automatically when the end user or the application executes a query in the block. When a fetched image is modified or replaced, Form Builder marks that record as Changed, and the next commit operation saves the new image to the corresponding LONG RAW column in the database.
Note: You cannot write a SELECT statement to select a LONG RAW value INTO an image item.
+2. executing the READ_IMAGE_FILE built-in to read an image from the file system+
+(To dynamically write an image from an image item out to a file, use the built-in procedure WRITE_IMAGE_FILE.)+ -
Retrieving image from database?
Hi there,
I am a newbie in java and i use MySql as my database. My problem is, how can i retrieve an image from my database and display it to a container(JLabel, JTextArea etc...)??
If you dont mind could you please give me a "simple" sample code for this one.. Thank you and God Bless :-)[http://forums.sun.com/thread.jspa?threadID=5346264]
These links were really funny............but I think s/he forgot to mark the topic as question as it was first post..... -
Unable retrieve image from database
Hi,
I'm using Mysql-database with blob column. I'm trying to show one image on the page. Now I only get red cross, not image.
I followed advices by jprazak:http://swforum.sun.com/jive/thread.jspa?threadID=47085&tstart=0
I changed code for my purpose.
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
* DisplayPicture.java
public class DisplayPicture extends HttpServlet {
private final String dbUrl="jdbc:mysql://localhost/pictures";
private final String dbUser="read";
private final String dbPassword="public";
/** Creates a new instance of DisplayPicture */
public DisplayPicture() {
public void init(ServletConfig config) throws ServletException {
super.init(config);
public void destroy() {
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String id = request.getParameter("imageid");
String ct = request.getParameter("contenttype");
if((ct==null)||(ct.equals(""))) {
ct = "image/x-jpg";
System.out.println(("Now displaying image with ID: "+id);
try {
ServletOutputStream out = response.getOutputStream();
response.setContentType(ct);
out.write(this.getImage(id));
}catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
public String getServletInfo() {
return "Displays a picture from the database identified by a parameter IMAGEID";;
private byte[] getImage(String id) {
Statement sta = null;
Connection con = null;
ResultSet rs = null;
byte[] result = null;
try {
java.lang.Class.forName("org.gjt.mm.mysql.Driver");
con = java.sql.DriverManager.getConnection(dbUrl,dbUser,dbPassword);
sta = con.createStatement();
rs = sta.executeQuery("SELECT IMAGE FROM IMAGES WHERE IMAGEID="+id);
if(rs.next()) {
result = rs.getBytes("IMAGE");
}else {
System.out.println("Could find image with the ID specified or there is a problem with the database connection"););
rs.close();
sta.close();
con.close();
}catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
return result;
Then I add to file web.xml
<servlet>
<servlet-name>DisplayPicture</servlet-name>
<servlet-class>DisplayPicture</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayPicture</servlet-name>
<url-pattern>/servlets/DisplayPicture</url-pattern>
</servlet-mapping>
And image-component to the page, url-value:
http://localhost:18080/application_name/servlets/DisplayPicture?imageid=1
I get no errors. What is wrong with this code?
ThanksIf I select DEMO_BLOB and BLOBCOL from servers window, I can see in properties window:
SQL Type BLOB
Type Name BLOB
If I select IMAGE column from mysql-table and I can see in properties window this:
SQL Type LONGVARBINARY
Type Name longblob
Could this SQL Type difference be the reason why I can't get images from mysql to the page? -
How to retrieve image in BLOB in oracle database using JSP?
do any one the method to view image in homepage using jsp from BLOB field in oracle database ?
thx<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Bon BOn:
do any one the method to view image in homepage using jsp from BLOB field in oracle database ?
thx<HR></BLOCKQUOTE>
I am using a servlet that retrieves the BLOB from the database, sets the MIME type and puts it in a stream. The code is :
package TestQueryITM;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.net.*;
import java.sql.*;
import oracle.sql.*;
import oracle.jdbc.driver.OracleDriver;
import oracle.jdbc.driver.*;
public class MIMEServlet extends HttpServlet {
DbConnect myDbBean = new DbConnect();
int Id=6;
String MIME ="plain/text";
public void init(ServletConfig config) throws ServletException
super.init(config);
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException
try
String content_type = new String();
String filename = new String();
// Load the Oracle JDBC driver:
Class.forName("oracle.jdbc.driver.OracleDriver");
// Connect to the database:
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@ORAVISION:1521:DEV","[username]", "[password]");
// It's faster when auto commit is off:
conn.setAutoCommit (false);
// Create a Statement:
Statement stmt = conn.createStatement ();
try
BLOB lob_loc = null;
java.io.InputStream in = null;
int pos = 0;
int length = 0;
OracleResultSet rset = (OracleResultSet) stmt.executeQuery (
"SELECT text FROM test WHERE ID = "+Id);
if (rset.next())
lob_loc = ((OracleResultSet)rset).getBLOB(1);
MIME=rset.getString(2);
// File binaryFile = new File("C:/aantekeningen.doc");
// FileInputStream in = new FileInputStream(binaryFile);
in = lob_loc.getBinaryStream();
// This loop fills the buf iteratively, retrieving data // from the InputStream:
res.setContentType (application/pdf);
res.setHeader ("Content-Disposition","attachement;filename=test.doc");
ServletOutputStream op = res.getOutputStream ();
byte[] buffer = new byte[32000];
while ((in != null) && ((length = in.read(buffer)) != -1))
// the data has already been read into buf
System.out.println("Bytes read in: " +
Integer.toString(length));
op.write(buffer,0,length);
op.flush();
op.close ();
in.close();
stmt.close();
conn.commit();
conn.close();
}catch (SQLException e)
e.printStackTrace();
}catch(Exception e)
System.out.println("<BR>");
e.printStackTrace();
System.out.println("<BR>");
public String getServletInfo() {
return "TestQueryITM.MIMEServlet Information";
null -
Retrieve images from DB and attach them to email through javamail
Hi,
I'm trying to use javamail to send emails containing text and images (HTML mail), if I use a physical file in my computer as the image source and use FileDataSource everything works just fine. The problem is that the images in my app are stored into a DB (I'm using MySQL, java struts & DAO), so in order to retrieve & display them I use a jsp that returns a byte array as shown in the example bellow
<img src='getImage.jsp?itemId=<bean:write name="item" property="itemId"/>&heigth=180&width=140&imageIndex=1'/>getImage.jsp reads the image from the DB for the specified item and returns an image of size "heigth*witdh", this works fine when invoked from any jsp or java action class, but I can't get it to work to insert an image into an email as attachment
I've tried to use ByteArrayDataSource and the mail is sent correctly and can be read but the image won't show
bds = new ByteArrayDataSource("/getImage.jsp?itemId="+itemId+"&heigth=180&width=140&imageIndex=1", "image/jpeg");
imageMime.setDataHandler(new DataHandler(bds));
imageMime.setHeader("Content-ID", "<\" + itemId + \">"); // backslashes aren't there in the real code, but if I remove them '+ itemId +' won't show
mailParts.addBodyPart(imageMime);I've also tried with URLDataSource but can't get it to work either, can somebody plz point me in the right direction?
thanks in advance
Edited by: informacionCubica on Jun 8, 2009 3:46 PMHello bshannon,
Thanks for your answer, I tried your suggestion but when I use URLDataSource I get the error message http 500 (in my original post I said that using URLDataSource the mail was sent but without the image... my mistake, I was getting this same error). I traced the error and I found that it is caused by a null pointer exception... let me explain
This is the code for the jsp that returns the image:
4 <jsp:useBean id="coverImage" class="com.mqm.struts.getImageAction" scope="session" />
5 <%
6 // Desired size of the image to return
7 int heigth = Integer.parseInt(request.getParameter("heigth"));
8 int width = Integer.parseInt(request.getParameter("width"));
9
10 // Each item can have up to 6 images (ordered by id), this indicates wich of one we have to return
11 int imageIndex = Integer.parseInt(request.getParameter("imageIndex"));
12 byte[] imgData = coverImage.getItemImageAction(request.getParameter("itemId"), request,heigth, width, imageIndex );
13 response.setContentType("image/jpeg");
14 OutputStream o = response.getOutputStream();
15 o.write(imgData);
16 o.flush();
17 out.clearBuffer();
18 o.close();
%> getImageAction is my DAO class that actually reads the image data from the DB, when I use this 'getImage.jsp' inside any other jsp in the app it works, but when used as described in the first post the request parameter in the line 12 doesn't have the session info, apparently creates a new session or something and since I use information in the session to create the DAO factory I can't connect to the DB and get this error..
pls tell me if I explained my self or I'm just talking non sense
regards -
Retrieving Images from Mysql with PHP
Hi I have been trying to work this out with no success so some help would be really appreciated.
I have two tables in Mysql,
IMAGES AND EXHIBITORS
IMAGES
`image_id` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT ,
`filename` VARCHAR(255) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL ,
`mime_type` VARCHAR(255) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL ,
`file_size` INT(11) NOT NULL ,
`file_data` LONGBLOB NOT NULL ,
`user_id` VARCHAR(50) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL ,
`accom_id` INT(5) NOT NULL ,
`exhibitors_exhib_id1` INT(5) NOT NULL ,
PRIMARY KEY (`image_id`, `exhibitors_exhib_id1`) ,
INDEX `user_id` (`user_id` ASC) ,
INDEX `accom_id` (`accom_id` ASC) ,
INDEX `fk_images_exhibitors2` (`exhibitors_exhib_id1` ASC) ,
CONSTRAINT `fk_images_exhibitors2`
FOREIGN KEY (`exhibitors_exhib_id1` )
REFERENCES `christmas_shopping`.`exhibitors` (`exhib_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
AUTO_INCREMENT = 7
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_bin
EXHIBITORS
`exhib_id` INT(5) NOT NULL AUTO_INCREMENT ,
`exhib_name` VARCHAR(50) CHARACTER SET 'latin1' COLLATE 'latin1_bin' NOT NULL ,
`exhib_years` SET('2010', '2009') NULL ,
PRIMARY KEY (`exhib_id`) )
ENGINE = InnoDB
AUTO_INCREMENT = 3
DEFAULT CHARACTER SET = latin1
COLLATE = latin1_bin
PACK_KEYS = DEFAULT
I think I am happy with the Mysql, and I have read the various arguments about storing images in mysql but for my purpose I wanted to store the image in the database.
I have already created the upload and the images have uploaded correctly and I can see the data in the database, however I just have been able to retrieve the images back into a webpage.
I have a .php file which is merging these to tables correctly but the image is displayed as
o¿9®áŸÇ½G_ŒÁ%×Úoíø$M©7ûiè Óµ|Mn.˨â=Ž2Z ¥<º½Hs/¸úfŠÇðïˆ-üE`· ¯üq÷C[ öTªÂ´ Jnéžl¢âÜdµ (¢µ$(¢Š�(¢Š�(¢Š�(¢Š�(¢Š�(¢Š�CÅ Š:šZ�(¢Š�(¢Š�) -! ¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¢Š(�¯ ý¤Z_ x^óÐK2ZJ»¦ò>ô»NJ ûç¥{6½©.‘£ÝÞ ÆZ¼*-Sûz"$pÌ]$þ%5ù¿ æ•0˜xa©;9êý O›=¼³ ªÍÔžÈøžþ t·[c*¦À T?wøQ·/?ίøWÅ×z]Ü r츌þæLôoâVþð¯jøÍð¶O Y½Îœ¨Œ›–k4OšWþê·mß1÷/ Abž<[Þ¢þþÕŠþ÷û۝}nCžÏ*š¡]Þ“ü?¯ëÏ‹ …X¨óÇIþgÔÔVf‹¬Ûë¶)snÙVê½Á:ý¶ H©ÁÝ=–iÅÙî QEh ¢Š(�¢Š(�¢Š(�¢Š(�¤4´‚€ Š( Š( Š( Š( qKHh Ð ÑE �QE �QE �QE �V^½ª¦‡¥^²ï .í¾µ©^kñÿ�Z Ã]NmÛY“
The code I have in the page is as follows. After many hours of trying to work it out I just cant see what I am missing and would really appreciate some help. I have highlighted where the echo is that relates to my image.
<?php require_once('../Connections/christmas.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_christmas, $christmas);
$query_Recordset1 = "SELECT exhibitors.exhib_name, images.file_size, images.file_data FROM images, exhibitors WHERE images.exhib_id = exhibitors.exhib_id";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $christmas) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php $pagetitle="The Christmas Shopping Fayre"?>
<html xmlns="http://www.w3.org/1999/xhtml" >
<meta http-equiv="Content-Type" content="; charset=" />
<link href="../public/CSSFiles/oneColElsCtrHdr.css" rel="stylesheet" type="text/css" />
<link href="../public/CSSFiles/whitebackground.css" rel="stylesheet" type="text/css"/>
<link href="../public/CSSFiles/shoppingonline.css" rel="stylesheet" type="text/css"/>
<link rel="icon" type="image/x-icon" href="http://www.gravatar.com/avatar/c4dac336c5be729fc542c12bfbb50099.png" />
<!--[if IE]>
<style type="text/css">
a { zoom: 1;}
</style>
<![endif]-->
<script type="text/javascript">
<!--
function MM_showHideLayers() { //v9.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3)
with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
//-->
</script>
</head>
<body id="shoppingonline" class="oneColElsCtrHdr">
<p> </p>
<?php include("includes/header.php"); ?>
<br />
<br />
<div id="bannersp"> </div>
<h1>Welcome to <?php echo $pagetitle?></h1>
<p>
</p>
<form method="post" name="form1" id="form1">
<p> </p>
<table border="1" cellpadding="5" cellspacing="5">
<tr>
<td>exhib_name</td>
<td>file_size</td>
<td>file_data</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['exhib_name']; ?></td>
<td><?php echo $row_Recordset1['file_size']; ?></td>
<td><?php echo $row_Recordset1['file_data']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
<?php include("includes/footer.php"); ?>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>Hi Murray
You must despair with beginers like me, attachments showed as having been
sent so lets try again.
I have been able to find a tutorial that works well all the way through, I
can even see the images in the browser!! but only shows images individually
on a page.
http://www.phpriot.com/articles/storing-images-in-mysql/7
However, what I want to do is to have a page that links my images table and
another table, all of which I have set up and is working other then showing
the images. All was very straight forward until sorting out the image. If
I can work out what to take from the above tutorial that works into my page,
I am sure all will be fab.
Storing them in the mysql was my preferred method as there are not alot and
they can be low resolution and I thought it would be fairly straight
forward!! however finding out that I am having to adapt code as dreamweaver
doesn't support the blob attribute is getting me out of my knowledge.
All the best
Gilly
Attachments inserted
show_image.php
<?php require_once('../Connections/getImage.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$colname_Recordset1 = "-1";
if (isset($_GET['image_id'])) {
$colname_Recordset1 = $_GET['image_id'];
mysql_select_db($database_getImage, $getImage);
$query_Recordset1 = sprintf("SELECT image_id, mime_type, file_data FROM images WHERE image_id = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $getImage) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
header('Content-type: ' . $row_getImage['mime_type']);
echo $row_getImage['file_data'];
mysql_free_result($Recordset1);
?>
view.php
<?php require_once('../Connections/getImage.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
return $theValue;
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
mysql_select_db($database_getImage, $getImage);
$query_Recordset1 = "SELECT * FROM images";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $getImage) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table border="1" cellpadding="5" cellspacing="5">
<tr>
<td>image_id</td>
<td>filename</td>
<td>mime_type</td>
<td>file_size</td>
<td>file_data</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['image_id']; ?></td>
<td><?php echo $row_Recordset1['filename']; ?></td>
<td><?php echo $row_Recordset1['mime_type']; ?></td>
<td><?php echo $row_Recordset1['file_size']; ?></td>
<td><?php echo $row_Recordset1['file_data']; ?></td>
<td><img src="show_image.php?image_id=<?php echo
$row_getdetails['image_id']; ?>" alt="Image from DB" />
</td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?> -
I want to store and retrieve images from a oracle datrabase's BLOB type
Hi all
I am using WebLogic and Oracle 10g.I have to store images and retrieve them from a BLOB type.
Please help .Please have a look to the Database Application Developer's Guide - Large Objects
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14249/toc.htm -
Problem in Retrieve Image from DB and display in the JSP page
Hi All,
I did one JSP Program for retriveing image from DB and display in the JSP Page. But when i run this i m getting "String Value" output. Here i have given my Program and the output. Please any one help to this issue.
Database Used : MS Access
DSN Name : image
Table Name: image
Image Format: bmp
Output : 1973956
Sample Program:_
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="java.io.*" %>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:image");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT images FROM image");
String imgLen="";
if(rs.next()){
imgLen = rs.getString(1);
out.println(imgLen.length());
if(rs.next()){
int len = imgLen.length();
byte [] rb = new byte[len];
InputStream readImg = rs.getBinaryStream(1);
int index=readImg.read(rb, 0, len);
System.out.println("index"+index);
st.close();
response.reset();
response.setContentType("image/jpg");
response.getOutputStream().write(rb,0,len);
response.getOutputStream().flush();
}catch(Exception ee){
out.println(ee);
%>
Thanks,
Senthilkumar Svishruta wrote:
<%
%>Using scriptlets is asking for trouble. Java code belongs in Java classes. Use a Servlet.
out.println(imgLen.length());Your JSP was supposed to write an image to the output and you wrote some irrelevant strings to the output before? This will corrupt the image. It's like opening the image in a text editor and adding some characters before to it.
byte [] rb = new byte[len];Memory hogging. Don't do that.
out.println(ee);You should be throwing exceptions and at least printing its trace, not sending its toString() to the output.
You may find this article useful to get an idea how this kind of stuff ought to work: [http://balusc.blogspot.com/2007/04/imageservlet.html]. -
How to Retrieve Images from mysql on JSF page
Hi,
I want to retrieve all the images which are in my database(mysql) using Netbeans 6.9.1 on a JSF 2.0 page.
How can i do so? I am using backing bean, i use backing bean methods in JSF.
Pls help me...
thanx...Hi
Please first read this
http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-mysql-windows-server-2008r2/
You can remote control your MySQl and get data by connection string
My Blog
Please use Make as Answer if my post solved your problem and use
Vote As Helpful if a post was useful. -
How to retrieve image from a document
Hi
I am a beginner to Adobe InDesign SDK (CS4) and was needing some help. Here is the sceneario
I have a simple InDesign document with an image in it. I am trying to retrieve the image and do some proprietory actions on it.
I am wondering if there is an InDesign API which can retrieve image on a document. What is the return value from such an API. (e.g does the API return a pointer to the image object or maybe location of the image on the filesystem ? ). What I am trying to do is once I can get a "handle" to the returned image, I would like to manipulate it and save it in a proprietory format.
Any pointers on this would be highly appreciated
thanks!
SamHi,
You can get the path of the linked image file and then you can manipulate this image.
I think ILinkUtils and ILink will certainly help.
You can also check (for better understanding) CHM->PortingGuide->Links Archtecture.
Thanks.
Maybe you are looking for
-
Account Suspended for 6 Days and Counting. Skype ...
My account has been suspended for 6 mind numbing days. I've filled out the "reactivation form" numerous times. *I had to open a new Skype account just to post on this forum.* I am at wit's end. The customer service reps. are useless, clueless aut
-
WORKFLOW, organisational unit name
Hi, I am making use of FM 'SAP_WAPI_WORKITEM_RECIPIENTS' with input as workitem id and user name. I am getting the organisational unit, but the problem is it gives only the number of the organisational unit. Is there any FM which after giving the org
-
How do I get rid of a rest in my score?
Hi, A couple of posts ago I asked how to make a grace note. Since getting response I successfully made a grace note attached to an eighth note. Unfortunately there is an eighth rest sitting in the background that I have no idea how to get rid of. (I
-
Client Install Fails - Unable to get Win32_OperatingSystem object
I have a PC that won't install the SCCM client via Client Push. In the CCM.Log file on the site server, it connects to the IPC$ and admin$ shares using my client installation account, but then it comes back with this error: ---> Unable to get Win32_
-
I don't remember now if this happened after an upgrade or not. I first noticed it on bankofamerica.com and thought it was specific to that site. But it seems to be that way on numerous sites. Maybe it has something to do with the coding version on so