Insert large Image object into Database

Hello
I have a large (!MB) image which needs to be stored in a database BLOB column, and I'm running out of memory with my naive code..
Nothing other than the code is within my control. I cannot change my heap size; I have no file-system, so cannot write the image.
The awt.Image is created and drawn elsewhere in the application. My thought was to create a byte stream and have that inserted chunk-by-chunk, but I just can't find out how to do this in a limited time.
Any help would be much appreciated.
Lee

leegee23 wrote:
Thanks for your help. Have tried this:
ImageInputStream is = ImageIO.createImageInputStream(gif);But got null. The docs read:
Returns an ImageInputStream that will take its input from the given Object. The set of ImageInputStreamSpis registered with the IIORegistry class is queried and the first one that is able to take input from the supplied object is used to create the returned ImageInputStream. If no suitable ImageInputStreamSpi exists, null is returned.
Am I barking up the wrong tree?I think you're on the right track. A quick browse found that an ImageWriter (GIFImageWriter) can be used to write an image to an output stream (use ImageIO.createImageOutputStream()), and then you can probably use PipedInputStream/PipedOutputStream to obtain an inputStream that you can pass to your JDBC driver to store the blob.
That's just from reading Javadocs though, I'm not sure how to connect the dots.
And also, make sure you post a reference to this thread on the new one you created. You wouldn't want people to waste time answering that thread if there's an answer here already, or vice versa.
Edit: I was thinking specifically of using a GifImageWriter constructed with a OutputStreamImageOutputStreamSpi that was passed in a PipedOutputStream which you would in turn connect to a PipedInputStream which you would pass in to the JDBC method.
But I'm not sure, it looks like even then it either uses a memory cache or a file cache. When you have compression, the writer will typically need to have access to all the bytes of the image before starting to write. It would be a two-pass algorithm, most likely. Which basically means you might have memory issues anyway.
Edited by: endasil on 22-Sep-2009 1:12 PM

Similar Messages

  • How to insert large xml data into database tables.

    Hi all,
    iam new to xml. i want to insert data in xml file to my database tables.but the xml file size is very large. performance is also one of the issue. can anybody please tell me the procedure to take xml file from the server and insert into my database tables.
    Thanks in advance

    Unfortunately posting very generic questions like this in the forum tends not to be very productive for you, me or the other people who read the forum. It really helps everyone if you take a little time to review existing posts and their answers before starting new threads which replicate subjects that have already been discussed extensively in previous threads. This allows you to ask more sensible questions (eg, I'm using this approach and encountering this problem) rather than extremely generic questions that you can answer yourself by spending a little time reviewing existings posts or using the forum's search feature.
    Also in future your might want to try being a little more specific before posting questions
    Eg Define "very large". I know of customers who thing very large is 100K, and customers who think 4G is medium. I cannot tell from your post what size your files are.
    What is the content of the file. Is it going to be loaded into a single record, or a a single table, or will it need to be loaded into multiple records in a single table or multiple records in multiple tables ?
    Do you really need to load the data into exsiting relational tables or could your application work with relational views of the XML Content.
    Finally which release of the database are you working with.
    Define performance. Is it reasonable to expect to process this kind of document on this machine (Make, memory, #number of CPUs, CPU Speed, number of discs) in this period of time.
    WRT to your original question. If you take a few minutes to search this forum you will find a very large number of threads with very similar titles to yours. These theads document a number of different approaches that can be used to solve this problem.
    I suggest you start by looking for threads that cover topics like DBMS_XMLSTORE, XMLTable(), Relational Views of XML content, loading XML content in relational tables.

  • 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 file

    Hi 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;
       }

  • Insert an image from a Database

    Hi - I am trying to insert an image from a database into a webpage.  Basically when clients register on the site they upload their logo which i want to come up when they look at their account details and when they post a job.  When I test the file upload the file name is in an "image" field in my database and the image is in the website files on the server but I am having problems trying to get the logo to shop up on the webpage.  I have one table called Recruiters where all the client's contact details (and logo upload goes) and a table called jobs where all the job details go when they post a job (this does not hold the logo upload). 
    At the moment i am trying to insert the image into the Recruiter account Details page where all the clients contact details are and all this information comes from the Recruiter table (including the image) but the image does not appear.  the query in my recordset is:-
    SELECT *
    FROM recruiters
    WHERE RecruiterID = colname
    (colname = $_GET['RecruiterID'])
    <?php require_once('../Connections/laura.php'); ?>
    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
    // ** Logout the current user. **
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      $_SESSION['MM_Username'] = NULL;
      $_SESSION['MM_UserGroup'] = NULL;
      $_SESSION['PrevUrl'] = NULL;
      unset($_SESSION['MM_Username']);
      unset($_SESSION['MM_UserGroup']);
      unset($_SESSION['PrevUrl']);
      $logoutGoTo = "../index.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
    ?>
    <?php
    if (!isset($_SESSION)) {
      session_start();
    $MM_authorizedUsers = "Recruiter";
    $MM_donotCheckaccess = "false";
    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
      // For security, start by assuming the visitor is NOT authorized.
      $isValid = False;
      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
      // Therefore, we know that a user is NOT logged in if that Session variable is blank.
      if (!empty($UserName)) {
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
        // Parse the strings into arrays.
        $arrUsers = Explode(",", $strUsers);
        $arrGroups = Explode(",", $strGroups);
        if (in_array($UserName, $arrUsers)) {
          $isValid = true;
        // Or, you may restrict access to only certain users based on their username.
        if (in_array($UserGroup, $arrGroups)) {
          $isValid = true;
        if (($strUsers == "") && false) {
          $isValid = true;
      return $isValid;
    $MM_restrictGoTo = "../Unavailablepage.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
      $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo);
      exit;
    ?>
    <?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_rsAccountDetails = "-1";
    if (isset($_GET['RecruiterID'])) {
      $colname_rsAccountDetails = $_GET['RecruiterID'];
    mysql_select_db($database_laura, $laura);
    $query_rsAccountDetails = sprintf("SELECT * FROM recruiters WHERE RecruiterID = %s", GetSQLValueString($colname_rsAccountDetails, "int"));
    $rsAccountDetails = mysql_query($query_rsAccountDetails, $laura) or die(mysql_error());
    $row_rsAccountDetails = mysql_fetch_assoc($rsAccountDetails);
    $totalRows_rsAccountDetails = mysql_num_rows($rsAccountDetails);
    ?>
    <!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>Nursery and Childcare Jobs in the UK</title>
    <link href="../CSS/Global.css" rel="stylesheet" type="text/css" />
    <script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <link href="../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
    <!-- google adwords -->
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-6435415-4']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    </script>
    </head>
    <body>
    <div class="container">
      <div class="header"><!-- end .header --><a href="../index.php"><img src="../Images/Logo.png" width="900" height="200" alt="Logo" /></a></div>
       <ul id="MenuBar1" class="MenuBarHorizontal">
          <li><a href="../index.php">Home</a>      </li>
          <li><a href="#" class="MenuBarItemSubmenu">Recruiters</a>
            <ul>
              <li><a href="recruiterbenefits.php">Benefits</a></li>
              <li><a href="recruiterfees.php">Fees</a></li>
              <li><a href="recreg.php">Register</a></li>
              <li><a href="reclogin.php">Login </a></li>
            </ul>
          </li>
          <li><a class="MenuBarItemSubmenu" href="#">Jobseekers</a>
            <ul>
              <li><a href="../Jobseekerarea/jobseekerbenefits.php">Benefits</a>          </li>
              <li><a href="../Jobseekerarea/jobseekerreg1.php">Register</a></li>
              <li><a href="../Jobseekerarea/jslogin.php">Login</a></li>
            </ul>
          </li>
          <li><a href="../contactus.php">Contact Us</a></li>
      </ul>
      <div class="sidebar1">
        <p> </p>
        <div class="recruitsidebar">
          <ul id="MenuBar2" class="MenuBarVertical">
            <li><a href="postajob.php">Post a Job</a></li>
            <li><a href="recruiterjobs1.php">My Jobs</a></li>
            <li><a href="recAccdetails.php?RecruiterID=<?php echo $row_rsAccountDetails['RecruiterID']; ?>">My Details</a></li>
            <li><a href="Saferrecruitment.php">Safer Recruitment</a></li>
            <li><a href="Interview1.php" class="MenuBarItemSubmenu">Interviewing Staff</a>
              <ul>
                <li><a href="recInterviewquestions.php">Nursery Staff Interview Questions</a></li>
              </ul>
            </li>
            <li><a href="Nurseryjobsdescriptions.php">Nursery Job Descriptions</a></li>
            <li><a href="recruiterarea.php">Recruiter Home</a></li>
    <li><a href="<?php echo $logoutAction ?>">Log Out</a></li>
          </ul>
          <p> </p>
        </div>
    </div>
      <div class="content">
        <h1>Account Details</h1>
        <p>Below are the details you have provided us with about your nursery/setting.</p>
        <p> </p>
        <form id="accountdetailsform" name="accountdetailsform" method="post" action="recUpdate.php?RecruiterID=<?php echo $row_rsAccountDetails['RecruiterID']; ?>">
          <table width="580" border="0" cellpadding="3" cellspacing="3" id="accountdetails">
            <tr>
              <td width="212" scope="col">Nursery/Setting Name</td>
              <td width="347" scope="col"><?php echo $row_rsAccountDetails['client']; ?></td>
            </tr>
            <tr>
              <td>Contact Name</td>
              <td><?php echo $row_rsAccountDetails['contactname']; ?></td>
            </tr>
            <tr>
              <td>Setting Type</td>
              <td><?php echo $row_rsAccountDetails['settingtype']; ?></td>
            </tr>
            <tr>
              <td>Nursery/Setting</td>
              <td><?php echo $row_rsAccountDetails['Setting']; ?></td>
            </tr>
            <tr>
              <td>Building Name/Number</td>
              <td><?php echo $row_rsAccountDetails['buildingnumber']; ?></td>
            </tr>
            <tr>
              <td>Street Name</td>
              <td><?php echo $row_rsAccountDetails['streetname']; ?></td>
            </tr>
            <tr>
              <td>Address</td>
              <td><?php echo $row_rsAccountDetails['address3']; ?></td>
            </tr>
            <tr>
              <td>Town/City</td>
              <td><?php echo $row_rsAccountDetails['town']; ?></td>
            </tr>
            <tr>
              <td>Post Code</td>
              <td><?php echo $row_rsAccountDetails['postcode']; ?></td>
            </tr>
            <tr>
              <td>Region</td>
              <td><?php echo $row_rsAccountDetails['region']; ?></td>
            </tr>
            <tr>
              <td>Telephone</td>
              <td><?php echo $row_rsAccountDetails['telephone']; ?></td>
            </tr>
            <tr>
              <td>Email</td>
              <td><?php echo $row_rsAccountDetails['email']; ?></td>
            </tr>
            <tr>
              <td>Website</td>
              <td><?php echo $row_rsAccountDetails['WebAddress']; ?></td>
            </tr>
            <tr>
              <td>Password</td>
              <td> </td>
            </tr>
            <tr>
              <td>Logo</td>
              <td><img src="<?php echo $row_rsAccountDetails['Image']; ?>" alt="Logo" /></td>
            </tr>
            <tr>
              <td>Date Registered</td>
              <td><?php echo $row_rsAccountDetails['dateregistered']; ?></td>
            </tr>
          </table>
          <p>
            <input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_rsAccountDetails['RecruiterID']; ?>" />
          </p>
          <p>
            <input type="submit" name="Update" id="Update" value="Update Details" />
          </p>
          <p> </p>
        </form>
        <p> </p>
        <table width="600" border="0" cellpadding="3" cellspacing="3" class="postform">
          <tr>      </tr>
          <tr>      </tr>
          <tr>      </tr>
        </table>
        <p> </p>
    <p> </p>
    </div>
      <div class="sidebar2">
        <h4> </h4>
        <!-- end .sidebar2 --></div>
      <div class="footer">
        <p><a href="../index.php">Home</a> | <a href="../contactus.php">Contact us</a> | <a href="../PrivacyPolicy.php">Privacy</a> | <a href="../termsandconditions.php">Terms of Business</a></p>
        <p>&copy; theNurseryJobSite.com 2011</p>
        <!-- end .footer --></div>
      <!-- end .container --></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>
    <?php
    mysql_free_result($rsAccountDetails);
    ?>

    Hi
    You were right – I had to insert full path and it has worked so thanks.
    Would you be able to help me out with inserting the logo into a job post page and  the recordset I will need to insert the logo?
    Basically I want to add the logo that is uploaded when a client registers on the site onto a job info page.  To access the the details about a job, jobseekers just click on the job that interests them which takes them to the job details page which pulls all the information from the "Job" table in the database.  However, the logo is stored in the "image" field in the "Recruiter" table in the database.   I have tried setting up a recordset as:-
    SELECT Image
    FROM recruiters
    WHERE RecruiterID = colname
    (colname = $_GET['RecruiterID'])
    <?php require_once('../Connections/laura.php'); ?>
    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
    // ** Logout the current user. **
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      $_SESSION['MM_Username'] = NULL;
      $_SESSION['MM_UserGroup'] = NULL;
      $_SESSION['PrevUrl'] = NULL;
      unset($_SESSION['MM_Username']);
      unset($_SESSION['MM_UserGroup']);
      unset($_SESSION['PrevUrl']);
      $logoutGoTo = "../index.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
    ?>
    <?php
    if (!isset($_SESSION)) {
      session_start();
    $MM_authorizedUsers = "Recruiter";
    $MM_donotCheckaccess = "false";
    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
      // For security, start by assuming the visitor is NOT authorized.
      $isValid = False;
      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
      // Therefore, we know that a user is NOT logged in if that Session variable is blank.
      if (!empty($UserName)) {
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
        // Parse the strings into arrays.
        $arrUsers = Explode(",", $strUsers);
        $arrGroups = Explode(",", $strGroups);
        if (in_array($UserName, $arrUsers)) {
          $isValid = true;
        // Or, you may restrict access to only certain users based on their username.
        if (in_array($UserGroup, $arrGroups)) {
          $isValid = true;
        if (($strUsers == "") && false) {
          $isValid = true;
      return $isValid;
    $MM_restrictGoTo = "../Unavailablepage.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
      $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo);
      exit;
    ?>
    <?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_rsDetails = "-1";
    if (isset($_GET['JobID'])) {
      $colname_rsDetails = $_GET['JobID'];
    mysql_select_db($database_laura, $laura);
    $query_rsDetails = sprintf("SELECT * FROM jobs WHERE JobID = %s", GetSQLValueString($colname_rsDetails, "text"));
    $rsDetails = mysql_query($query_rsDetails, $laura) or die(mysql_error());
    $row_rsDetails = mysql_fetch_assoc($rsDetails);
    $totalRows_rsDetails = "-1";
    if (isset($_GET['JobID'])) {
      $totalRows_rsDetails = $_GET['JobID'];
    mysql_select_db($database_laura, $laura);
    $query_rsDetails = sprintf("SELECT recruiters.Image, jobs.JobID, jobs.RecruiterID, jobs.jobtitle, jobs.`Position`, jobs.Nursery, jobs.branchlocation, jobs.ContactName, jobs.JobDescription, jobs.Location, jobs.town, jobs.employmenttype, jobs.Hours, jobs.qualifications, jobs.Salary, jobs.ContactNo, jobs.Email, jobs.dateposted  FROM jobs, recruiters WHERE JobID = %s", GetSQLValueString($colname_rsDetails, "int"));
    $rsDetails = mysql_query($query_rsDetails, $laura) or die(mysql_error());
    $row_rsDetails = mysql_fetch_assoc($rsDetails);
    $totalRows_rsDetails = "-1";
    if (isset($_GET['JobID'])) {
      $totalRows_rsDetails = $_GET['JobID'];
    mysql_select_db($database_laura, $laura);
    $query_rsDetails = sprintf("SELECT recruiters.Image, jobs.JobID, jobs.RecruiterID, jobs.jobtitle, jobs.`Position`, jobs.Nursery, jobs.branchlocation, jobs.ContactName, jobs.JobDescription, jobs.Location, jobs.town, jobs.employmenttype, jobs.Hours, jobs.qualifications, jobs.Salary, jobs.ContactNo, jobs.Email, jobs.dateposted FROM jobs, recruiters WHERE JobID = %s", GetSQLValueString($colname_rsDetails, "int"));
    $rsDetails = mysql_query($query_rsDetails, $laura) or die(mysql_error());
    $row_rsDetails = mysql_fetch_assoc($rsDetails);
    $totalRows_rsDetails = "-1";
    if (isset($_GET['JobID'])) {
      $totalRows_rsDetails = $_GET['JobID'];
    mysql_select_db($database_laura, $laura);
    $query_rsDetails = sprintf("SELECT recruiters.Image, jobs.JobID, jobs.RecruiterID, jobs.jobtitle, jobs.`Position`, jobs.Nursery, jobs.branchlocation, jobs.ContactName, jobs.JobDescription, jobs.Location, jobs.town, jobs.employmenttype, jobs.Hours, jobs.qualifications, jobs.Salary, jobs.ContactNo, jobs.Email, jobs.dateposted FROM jobs, recruiters WHERE JobID = %s", GetSQLValueString($totalRows_rsDetails, "int"));
    $rsDetails = mysql_query($query_rsDetails, $laura) or die(mysql_error());
    $row_rsDetails = mysql_fetch_assoc($rsDetails);
    $totalRows_rsDetails = mysql_num_rows($rsDetails);
    $colname_rsRecruiterID2 = "-1";
    if (isset($_GET['RecruiterID'])) {
      $colname_rsRecruiterID2 = $_GET['RecruiterID'];
    mysql_select_db($database_laura, $laura);
    $query_rsRecruiterID2 = sprintf("SELECT RecruiterID FROM recruiters WHERE RecruiterID = %s", GetSQLValueString($colname_rsRecruiterID2, "int"));
    $rsRecruiterID2 = mysql_query($query_rsRecruiterID2, $laura) or die(mysql_error());
    $row_rsRecruiterID2 = mysql_fetch_assoc($rsRecruiterID2);
    $totalRows_rsRecruiterID2 = mysql_num_rows($rsRecruiterID2);
    $colname_rsRecruiterID = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsRecruiterID = $_SESSION['MM_Username'];
    mysql_select_db($database_laura, $laura);
    $query_rsRecruiterID = sprintf("SELECT RecruiterID FROM recruiters WHERE email = %s", GetSQLValueString($colname_rsRecruiterID, "text"));
    $rsRecruiterID = mysql_query($query_rsRecruiterID, $laura) or die(mysql_error());
    $row_rsRecruiterID = mysql_fetch_assoc($rsRecruiterID);
    $totalRows_rsRecruiterID = mysql_num_rows($rsRecruiterID);
    $colname_Recordset1 = "-1";
    if (isset($_GET['RecruiterID'])) {
      $colname_Recordset1 = $_GET['RecruiterID'];
    mysql_select_db($database_laura, $laura);
    $query_Recordset1 = sprintf("SELECT Image FROM recruiters WHERE RecruiterID = %s", GetSQLValueString($colname_Recordset1, "int"));
    $Recordset1 = mysql_query($query_Recordset1, $laura) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    $query_rsJobs = "SELECT * FROM jobs";
    $rsJobs = mysql_query($query_rsJobs, $laura) or die(mysql_error());
    $row_rsJobs = mysql_fetch_assoc($rsJobs);
    $totalRows_rsJobs = mysql_num_rows($rsJobs);
    $colname_rsJobs = "-1";
    if (isset($_GET['Position'])) {
      $colname_rsJobs = $_GET['Position'];
    $varLocation_rsJobs = "-1";
    if (isset($_GET['Location'])) {
      $varLocation_rsJobs = $_GET['Location'];
    mysql_select_db($database_laura, $laura);
    $query_rsJobs = sprintf("SELECT `Position`, Nursery, Location, Salary, Email, ContactNo, JobDescription, JobID FROM jobs WHERE `Position` = %s AND jobs.Location = %s", GetSQLValueString($colname_rsJobs, "text"),GetSQLValueString($varLocation_rsJobs, "text"));
    $rsJobs = mysql_query($query_rsJobs, $laura) or die(mysql_error());
    $row_rsJobs = mysql_fetch_assoc($rsJobs);
    ?>
    <!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>Nursery and Childcare Jobs in the UK</title>
    <link href="../CSS/Global.css" rel="stylesheet" type="text/css" />
    <script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
    <link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
    <link href="../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
    <!-- google adwards -->
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-6435415-4']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    </script>
    </head>
    <body>
    <div class="container">
      <div class="header"><!-- end .header --><a href="../index.php"><img src="../Images/Logo.png" width="900" height="200" alt="the Nursery Job Site" /></a></div>
      <div class="navbar">  <ul id="MenuBar1" class="MenuBarHorizontal">
          <li><a href="thenurseryjobsite.php">About the Nursery Job Site</a>      </li>
          <li><a href="#" class="MenuBarItemSubmenu">Recruiters</a>
            <ul>
              <li><a href="Recruiterarea/recruiterbenefits.php">Benefits</a></li>
              <li><a href="Recruiterarea/recruiterfees.php">Fees</a></li>
              <li><a href="Recruiterarea/reclogin.php">Login</a></li>
              <li><a href="Recruiterarea/recreg.php">Register</a></li>
            </ul>
          </li>
          <li><a class="MenuBarItemSubmenu" href="#">Jobseekers</a>
            <ul>
              <li><a href="Jobseekerarea/jobseekerbenefits.php">Benefits</a>          </li>
              <li><a href="Jobseekerarea/jslogin.php">Login</a></li>
              <li><a href="Jobseekerarea/jobseekerreg1.php">Register</a></li>
            </ul>
          </li>
          <li><a href="contactus.php">Contact Us</a></li>
        </ul> </div> <!--end navbar div -->
      <div class="sidebar1">
        <p> </p>
        <div class="recruitsidebar">
          <ul id="MenuBar2" class="MenuBarVertical">
            <li><a href="postajob.php">Post a Job</a></li>
            <li><a href="recAccdetails.php?RecruiterID=<?php echo $row_rsRecruiterID['RecruiterID']; ?>">My Details </a></li>
            <li><a href="recruiterjobs1.php">My Jobs</a></li>
            <li><a href="Saferrecruitment.php">Safer Recruitment</a></li>
            <li><a href="Interview1.php" class="MenuBarItemSubmenu">Interviewing Staff</a>
              <ul>
                <li><a href="recInterviewquestions.php">Nursery Staff Interview Questions</a></li>
              </ul>
            </li>
            <li><a href="Nurseryjobsdescriptions.php">Nursery Job Descriptions</a></li>
            <li><a href="recruiterarea.php">Recruiter Home</a></li>
    <li><a href="<?php echo $logoutAction ?>">Log Out</a></li>
          </ul>
          <p> </p>
        </div>
    </div>
      <div class="content">
        <h1> </h1>
    <div class="detailheading" id="detailheading">
          <h1> </h1>
          <table width="564" border="0" align="center" cellpadding="3" cellspacing="3" id="headingtable">
            <tr>
              <td width="89" height="44" align="center" class="headertext"><h1>Nursery:</h1></td>
              <td width="283" class="headertext"><?php echo $row_rsDetails['Nursery']; ?></td>
              <td width="162" rowspan="2"><img src="<?php echo $row_Recordset1['Image']; ?>" alt="" name="nurserylogo" align="right" id="nurserylogo" /></td>
            </tr>
            <tr align="left" class="headertext">
              <td width="89" height="44" align="center"><h1 class="headertext">Job Title:</h1></td>
              <td align="left"><?php echo $row_rsDetails['jobtitle']; ?></td>
            </tr>
          </table>
          <p> </p>
        </div>
        <table width="568" border="0" align="center" cellpadding="3" cellspacing="3" class="detail" id="detailtable">
          <tr>
            <td width="162" scope="col">Job Title</td>
            <td width="381" scope="col"><?php echo $row_rsDetails['jobtitle']; ?></td>
          </tr>
          <tr>
            <td>Nursery</td>
            <td><?php echo $row_rsDetails['Nursery']; ?></td>
          </tr>
          <tr>
            <td>Branch Name/Location</td>
            <td><?php echo $row_rsDetails['branchlocation']; ?></td>
          </tr>
          <tr>
            <td>Location</td>
            <td><?php echo $row_rsDetails['Location']; ?>,<?php echo $row_rsDetails['town']; ?></td>
          </tr>
          <tr>
            <td valign="top">Job Description</td>
            <td><p> </p>
              <p><?php echo $row_rsDetails['JobDescription']; ?></p>
            <p> </p></td>
          </tr>
          <tr>
            <td>Qualifications Required</td>
            <td><?php echo $row_rsDetails['qualifications']; ?></td>
          </tr>
          <tr>
            <td>Employment Type</td>
            <td><?php echo $row_rsDetails['employmenttype']; ?></td>
          </tr>
          <tr>
            <td>Hours</td>
            <td><?php echo $row_rsDetails['Hours']; ?></td>
          </tr>
          <tr>
            <td>Salary</td>
            <td>£<?php echo $row_rsDetails['Salary']; ?></td>
          </tr>
          <tr>
            <td>Contact Number</td>
            <td><?php echo $row_rsDetails['ContactNo']; ?></td>
          </tr>
          <tr>
            <td>Email</td>
            <td><?php echo $row_rsDetails['Email']; ?></td>
          </tr>
          <tr>
            <td>Date Posted</td>
            <td><?php echo $row_rsDetails['dateposted']; ?></td>
          </tr>
          <tr>
            <td>Job ID</td>
            <td><?php echo $row_rsDetails['JobID']; ?></td>
          </tr>
        </table>
        <p><br />
        </p>
        <form id="recruiterjobsform" name="recruiterjobsform" method="post" action="recruiterjobs1.php">
          <input name="RecruiterIDjobs" type="hidden" id="RecruiterIDjobs" value="<?php echo $row_rsDetails['RecruiterID']; ?>" />
          <input type="submit" name="button" id="button" value="return to my jobs" />
        </form>
        <p> </p>
    <script type="text/javascript">
    var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
        </script><script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    <p> </p>
    </div>
      <div class="sidebar2">
        <h4> </h4>
        <!-- end .sidebar2 --></div>
      <div class="footer">
        <p><a href="../index.php">Home</a> | <a href="../contactus.php">Contact us</a> | <a href="../PrivacyPolicy.php">Privacy</a> | <a href="../termsandconditions.php">Terms of Business</a></p>
        <p>&copy; theNurseryJobSite.com 2011</p>
        <!-- end .footer --></div>
      <!-- end .container --></div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    </html>
    <?php
    mysql_free_result($rsDetails);
    mysql_free_result($rsRecruiterID2);
    mysql_free_result($rsRecruiterID);
    mysql_free_result($Recordset1);
    ?>

  • Can I insert the image file into PDF file  in Adobe X Standard ?

    can I insert the image file into PDF file in Adobe X Standard ?

    http://matt.coneybeare.me/how-to-make-an-html-signature-in-apple-mail-for-maveri cks-os-x-10-dot-9/

  • How can I insert an image(JPG) into a SQL database?

    I have written an application to perform some tests in the lab.  After gathering the data I store it into a SQL Server.  I successfully managed to export all my raw numbers and calculations to the DB.  However I have not been able to export a screenshot of the Front panel.  I can write the screenshot to a JPG file just fine.  The problem is putting the image (binary data) into the DB.
    So from what work I've managed to do, two questions come to mind:
    1)  Is there a way to compress the screenshot, using standard JPG compression, without actually writing out to a file.  ie:  Just have a binary stream of the compressed image that I can write to the SQL database.
    2)  Even if I don't use compression, I can't write any kind of data that appears as an image.  What kind of data do I need to be writing from LabView to store it properly in an 'image' or 'binary' type field in a SQL database?  I am not looking for answer "binary data."  Nor do I want the answer that is stated in the Help file for the DB Connectivity Toolkit(type - Data Cluster).  What I need is to know what kind of conversions I need to do on the image data that comes out of the FP.GetScaledImage.
    I am using LabView 8.0 and have the Database connectivity toolkit.  We are running SQL Server 2000 and 2005.

    I also hit this limit.  In the end I just wrote the JPGs to disk, and stored the file path in the DB.  Not the ideal solution, I know.
    I'm trying to remember now, exactly what the problem was.  You're right to say the image data type should handle up to 2GB.  I think in the end, it was an issue of the LabView toolkit not playing well with newer versions of SQL Server, which have the image type.  Re-reading the error though, it sounds like it might be an issue with the ODBC driver.  FYI, 8KB used to be the max size for the largest types in SQL Server (I think binary in 2000).  I suspect this limit was coded into the driver or LabView, and can't handle the newer, larger types.
    That being said, the LabView DB toolkit was either written poorly or written a long time ago.  It has issues with generating SQL queries that have the proper quotes.  For example, if your column names have spaces in them, the toolkit will be unable to generate a valid query, without some modification of the toolkit *.vi's.  Images in a database is not a new concept and not new to me.  I've never used a language where it was more complicated or difficult to get working.  Unless you absolutely have to, I'd work out a way to just store the JPGs to disk, with the path in the DB.  Spending too much time on this defeats the purpose of using LabView.
    If NI decides to update the DB toolkit, then it might be worth giving it a try again.
    In case any NI people are reading this, this is a not so subtle hint that you need to update the DB toolkit to support modern DB features.  Especially, if NI is charging $1000 for it.

  • Dynamic insertion of MIME object into a web dynpro component

    Hi,
    I want to dynamically insert a MIME object of type JPEG or type GIF into my web dynpro component at runtime.
    I was unable to find the database table which contains the list of MIME objects for a particular web dynpro component.
    Can you please help me out with this?
    Thanks in advance,
    Adithya
    Moderator message: wrong forum, please have a look in the "Web Dynpro ABAP" forum.
    Edited by: Thomas Zloch on May 23, 2011 9:55 AM

    Hi Muzammil Bichoo ,
                                   when you copy the wda component, it will be copied and will be in active state, once all the components are activated means, windows, views, everything will be available.
    now create application for your component, if you have more than one window(interface view) select the one which you need for the application.
    Regards
    Sarath

  • How to pass xml data as objects into Database using store procedures

    Hi All,
         I don't have much knowledge on store procedure,can anybody help how to pass the xml as objects in Database using store procedure.
    My Requirement is I have a table with three fields EMPLOYEE is table name and the fields are EMP_ID,EMP_TYPE AND EMP_DET,I have to insert the employees xml data into corresponding fields in the table.
    Input Data
    <ROWSET>
       <ROW>
         <EMP_ID>7000</EMP_ID>
          <EMP_TYPE>TYPE1</EMP_TYPE>
         <EMP_DET>DEP</EMP_DET>
      <ROW>
      <ROW>
         <EMP_ID>7000</EMP_ID>
         <EMP_TYPE>TYPE2</EMP_TYPE>
        <EMP_DET>DEP2</EMP_DET>
    <ROW>
    <ROW>
         <EMP_ID>7000</EMP_ID>
         <EMP_TYPE>TYPE3</EMP_TYPE>
        <EMP_DET>DEP3</EMP_DET>
    <ROW>
    <ROWSET>
    So each row values has to inserted into resp fields in the table.
    Regards
    Mani

    Do you have a similar structure in your stored procedure ?
    In that case you can simply call the procedure from soa using db adapter and do a mapping to assign the values.

  • Inserting large xml data into xmltype

    Hi all,
    In my project I need to insert very large XML data into xmltype column.
    My table:
    CREATE TABLE TransDetailstblCLOB ( id number, data_xml XMLType) XmlType data_xml STORE AS CLOB;
    I am using JDBC approach to insert values. It works fine for data less than 4000 bytes when using preparedStatement.setString(1, xmlData). As I have to insert large Xml data >4000 bytes I am now using preparedStatement.setClob() methods.
    My code works fine for table which has column declared as CLOB expicitly. But for TransDetailstblCLOB where the column is declared as XMLTYPE and storage option as CLOB I am getting the error : "ORA-01461: can bind a LONG value only for insert into a LONG column".
    This error means that there is a mismatch between my setClob() and column. which means am I not storing in CLOB column.
    I read in Oracle site that
    When you create an XMLType column without any XML schema specification, a hidden CLOB column is automatically created to store the XML data. The XMLType column itself becomes a virtual column over this hidden CLOB column. It is not possible to directly access the CLOB column; however, you can set the storage characteristics for the column using the XMLType storage clause."
    I dont understand its stated here that it is a hidden CLOB column then why not I use setClob()? It worked fine for pure CLOB column (another table) then Why is it giving such error for XMLTYPE table?
    I am struck up with this since 3 days. Can anyone help me please?
    My code snippet:
    query = "INSERT INTO po_xml_tab VALUES (?,XMLType(?)) ";
              //query = "INSERT INTO test VALUES (?,?) ";
         // Get the statement Object
         pstmt =(OraclePreparedStatement) conn.prepareStatement(query);
         // pstmt = conn.prepareStatement(query);
         //xmlData="test";
    //      If the temporary CLOB has not yet been created, create new
         temporaryClob = oracle.sql.CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
         // Open the temporary CLOB in readwrite mode to enable writing
         temporaryClob.open(CLOB.MODE_READWRITE);
         log.debug("tempClob opened"+"size bef writing data"+"length "+temporaryClob.getLength()+
                   "buffer size "+temporaryClob.getBufferSize()+"chunk size "+temporaryClob.getChunkSize());
         OutputStream out = temporaryClob.getAsciiOutputStream();
         InputStream in = new StringBufferInputStream(xmlData);
    int length = -1;
    int wrote = 0;
    int chunkSize = temporaryClob.getChunkSize();
    chunkSize=xmlData.length();
    byte[] buf = new byte[chunkSize];
    while ((length = in.read(buf)) != -1) {
    out.write(buf, 0, length);
    wrote += length;
    temporaryClob.setBytes(buf);
    log.debug("Wrote lenght"+wrote);
         // Bind this CLOB with the prepared Statement
         pstmt.setInt(1,100);
         pstmt.setStringForClob(2, xmlData);
         int i =pstmt.executeUpdate();
         if (i == 1) {
         log.debug("Record Successfully inserted!");
         }

    try this, in adodb works:
    declare poXML CLOB;
    BEGIN
    poXML := '<OIDS><OID>large text</OID></OIDS>';
    UPDATE a_po_xml_tab set podoc=XMLType(poXML) WHERE poid = 102;
    END;

  • Inserting data from Textarea into database

    I am collecting data from a html form which has textarea and processing it through servlet.
    If I enter text in textarea without breaks(without pressing enter tab) it is being collected and correctly put into database.
    If I enter text with breaks (with pressing enter tabs for entering in separate lines) it is being collected correctly but only one line goes into database.
    How to insert entire text from textarea into database.
    bye
    Kaushik

    problem is not yet solved.
    i am able to print in the sql query and is displayomg all the chars. but missing while executing the statement.
    mysql - 3.23, driver is org.mm..mysql driver
    Can u please look at this another problem:
    I have a keyword and need to search against a table containing 100 fileds.
    select * from table where keyword like '%"+keyword+"%'
    searches only in one field. If I want the search to be performed against all the fields in the table, Is there any solution.
    What I am doing at present is putting all the fields data in a new field and performing like operation on that field.
    but this is very slow.
    thanks and regards
    Kaushik

  • Save an Image object into a XML text document

    ello:
    I have a problem with saving an image. I need to encapsulate it into two XML tags:
    <Image> xxxxxx </Image>
    The "xxxx" must be a String that represents my Image object.
    In J2ME I haven't serialization, and all the examples about "manual serialization" works with primitive types :(
    I've already read that I can do .getRGB() over my Image object, and obtain an array of int, wich represent each pixel. Ok, I can transform the array into a String, and write it in my XML text document, but later: how I obtain my array from that String?
    Thak you very much

    private Image img;
    byte rgb[] = null;
    private rgbLength; // get lenth of your string
    rgb = new byte(rgbLength);
    rgb = ... //load data from string to this array
    img = createRGBImage(rgb, int width, int height, false) ;You must know length of your string and must encapsulate in to XML width and height of this image;

  • Unable to insert large blob data into DB

    Hi,
    I have written a piece of code which serializes a java object and writes it into a blob in DB.
    It works pretty fine for small objects of around 3 to 4 KB size, but I start getting trouble with larger objects.
    Here's my piece of code -
    private final static String QUERY_INSERT_AUDIT_DATA = "INSERT INTO " +
    "KAAS_AUDIT_DATA(object_id, object_type_cd, create_by, summary_data) VALUES (?, ?, ?, ?)";
    byte [] byteArray;
    bos = new ByteArrayOutputStream();
    oos = new ObjectOutputStream(bos);
    oos.writeObject(summaryData);
    oos.flush();
    oos.close();
    byteArray = bos.toByteArray();
    bos.close();
    ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
    BufferedInputStream buffInputSteam = new BufferedInputStream(bais);
    trace("addAuditSummary() : byteArray " + byteArray.length);
    trace("addAuditSummary() : buffInputSteam.available " + buffInputSteam.available());
    trace("addAuditSummary() : Calling Query to populating data");
    statement = conn.prepareStatement(QUERY_INSERT_AUDIT_DATA);
    statement.setString(1, objectId.toUpperCase());
    statement.setInt(2, objectType);
    statement.setString(3, createdBy);
    statement.setBinaryStream(4, buffInputSteam, buffInputSteam.available());
    statement.executeUpdate();
    statement.close();
    Basically, I am converting the object to BufferedInputStream to sent it to the BLOB(summary_data).
    The error I get is -
    ][30 Nov 2007 10:38:08] [ERROR] [com.hns.iag.kaas.util.debug.DebugDAO] addAuditSummary() : SQL exception occured while adding audit summary data for Object: BUSINESS_SO_BASE_DEAL
    ]java.sql.SQLException: Io exception: Connection reset by peer.
    at oracle.jdbc.dbaccess.DBError.throwSqlException(Ljava/lang/String;Ljava/lang/String;I)V(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(ILjava/lang/Object;)V(DBError.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(Ljava/io/IOException;)V(DBError.java:334)
    at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(Ljava/io/IOException;)V(TTC7Protocol.java:3675)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(BBI[B[Loracle/jdbc/dbaccess/DBType;[Loracle/jdbc/dbaccess/DBData;I[Loracle/jdbc/dbaccess/DBType;[Loracle/jdbc/dbaccess/DBData;I)V(Optimized Method)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(Loracle/jdbc/dbaccess/DBStatement;B[BLoracle/jdbc/dbaccess/DBDataSet;ILoracle/jdbc/dbaccess/DBDataSet;I)I(TTC7Protocol.java:1141)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout()V(Optimized Method)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate()I(Optimized Method)
    at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate()I(PreparedStatement.java:94)
    at com.hns.iag.kaas.util.debug.DebugDAO.addAuditSummary(Ljava/lang/String;ILjava/lang/Object;Ljava/lang/String;)V(DebugDAO.java:794)
    at com.hns.iag.kaas.servlets.sdm.action.SummaryAction.perform(Lcom/hns/iag/kaas/servlets/sdm/core/Event;Lcom/hns/iag/kaas/servlets/sdm/core/UserContext;)Ljava/lang/String;(SummaryAction.java:246)
    at com.hns.iag.kaas.servlets.sdm.SDMControllerServlet.process(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V(SDMControllerServlet.java:213)
    at com.hns.iag.kaas.servlets.sdm.SDMControllerServlet.doPost(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V(SDMControllerServlet.java:128)
    at javax.servlet.http.HttpServlet.service(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run()Ljava/lang/Object;(ServletStubImpl.java:971)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;Lweblogic/servlet/internal/FilterChainImpl;)V(ServletStubImpl.java:402)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run()Ljava/lang/Object;(WebAppServletContext.java:6354)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Lweblogic/security/subject/AbstractSubject;Ljava/security/PrivilegedAction;)Ljava/lang/Object;(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(Lweblogic/security/acl/internal/AuthenticatedSubject;Lweblogic/security/acl/internal/AuthenticatedSubject;Ljava/security/PrivilegedAction;)Ljava/lang/Object;(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(Lweblogic/servlet/internal/ServletRequestImpl;Lweblogic/servlet/internal/ServletResponseImpl;)V(WebAppServletContext.java:3635)
    at weblogic.servlet.internal.ServletRequestImpl.execute(Lweblogic/kernel/ExecuteThread;)V(ServletRequestImpl.java:2585)
    at weblogic.kernel.ExecuteThread.execute(Lweblogic/kernel/ExecuteRequest;)V(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run()V(ExecuteThread.java:170)
    at java.lang.Thread.startThreadFromVM(Ljava/lang/Thread;)V(Unknown Source)
    I would really appreciate any help.
    Thanks
    Saurabh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

    I would say, most likele BufferedInputStream.available() returns an incorrect length. available() does not return the length of the InputStream. See the javadocs for the details
    Additionally: it doesn't make sense at all to wrap the ByteArrayInputStream with a BufferedInputStream, the array is in memory already, so there is no need to buffer the read access to it (you are simply adding more overhead).
    Remove the BufferedInputStream (passing the bais directly to the setBinaryStream() method) and use byteArray.length to indicate the length of the data

  • Inserting new table data into database

    Hi, im trying to find out if i can insert a row of data into a mdb table. basically i have a List of Client objects for an application, and im iterating through this list. Now i take out an object and my aim is to place the details of that Client into the relevant cells in the database. But, it is giving me a "General error" exception. Here is my code...
    Iterator i = listOfClients.iterator();
    while(i.hasNext()){
    Client c = (Client)i.next();//get the client object
    if(c!=null){
    st.executeUpdate("INSERT INTO CLIENTS("+
    "CLIENT_NO,"+
    "CLIENT_NAME,"+
    "CLIENT_DESC,"+
    "CLIENT_ADDRESS,"+
    "CLIENT_PHONE,"+
    "CLIENT_EMAIL,CLIENT_NOTES) "+
    "VALUES('"+c.getClientNumber()+
    "','"+c.getClientName()+
    "','"+c.getClientDescription()+
    "','"+c.getClientAddress()+
    "','"+c.getClientTelephone()+
    "','"+c.getClientEmail()+
    "','"+c.additionalNotes+"')");
    Can someone please tell me where the error is in this sql statement, im really gettin agitated.
    thanx

    dw i fixed it using that PreparedStatement class.

  • Inserting blob images in a database

    Hi there can anyone tell me how to insert a blob image into a table; can you actually give me an example
    thanks

    use DBMS_LOB.LOADFROMFILE.
    PROCEDURE LOADFROMFILE
    Argument Name                  Type                    In/Out Default?
    DEST_LOB                       BLOB                    IN/OUT
    SRC_LOB                        BINARY FILE LOB         IN
    AMOUNT                         NUMBER(38)              IN
    DEST_OFFSET                    NUMBER(38)              IN     DEFAULT
    SRC_OFFSET                     NUMBER(38)              IN     DEFAULT

  • How can i insert  more clob objects into oracle9i?

    my env:
    os: windows server 2003 ent sp2
    php:=5.2.3
    oracle : 9.0.0.8
    i look at this article :
    http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/fuecks_lobs.html
    but ,i want insert two clob into the oracle ....
    Inserting a LOB
    To INSERT an internal LOB, you first need to initialize the LOB using the respective Oracle EMPTY_BLOB or EMPTY_CLOB functions—you cannot update a LOB that contains a NULL value.
    Once initialized, you then bind the column to a PHP OCI-Lob object and update the LOB content via the object's save() method.
    The following script provides an example, returning the LOB type from the INSERT query:
    <?php
    // connect to DB etc...
    $sql = "INSERT INTO
    mylobs
    id,
    mylob
    VALUES
    mylobs_id_seq.NEXTVAL,
    --Initialize as an empty CLOB
    EMPTY_CLOB()
    RETURNING
    --Return the LOB locator
    mylob INTO :mylob_loc";
    $stmt = oci_parse($conn, $sql);
    // Creates an "empty" OCI-Lob object to bind to the locator
    $myLOB = oci_new_descriptor($conn, OCI_D_LOB);
    // Bind the returned Oracle LOB locator to the PHP LOB object
    oci_bind_by_name($stmt, ":mylob_loc", $myLOB, -1, OCI_B_CLOB);
    // Execute the statement using , OCI_DEFAULT - as a transaction
    oci_execute($stmt, OCI_DEFAULT)
    or die ("Unable to execute query\n");
    // Now save a value to the LOB
    if ( !$myLOB->save('INSERT: '.date('H:i:s',time())) ) {
    // On error, rollback the transaction
    oci_rollback($conn);
    } else {
    // On success, commit the transaction
    oci_commit($conn);
    // Free resources
    oci_free_statement($stmt);
    $myLOB->free();
    // disconnect from DB etc.
    ?>

    Use something like:
    sql = "INSERT INTO mylobs (id, mylob1, mylob2) VALUES
    (mylobs_id_seq.NEXTVAL, EMPTY_CLOB(), EMPTY_CLOB()) RETURNING
    mylob1, mylob2 INTO :mylob_loc1, :mylob_loc2";
    You'll need to allocated two lob descriptors and bind both to the statement.
    -- cj

Maybe you are looking for

  • How can I create more than one different signatures for one account or for one address?

    I want to vreate 2 jr more signatures for one account. For example, in different languages, with different text, etc.

  • Movie Playing on HD TV via HDMI plays to fast

    Hi everyone, I have a Mid 2011 Mac Mini with 8G of RAM and it is connected to a Sony Bravia 55' Full HD TV via HDMI. When I play a movie from the mac mini , there is a clear " fast going " effect , the video plays faster than natural but the sound is

  • Kernel Problems

    When rendering out HD video in multiple formats, I begin having computer problems. I have a brand new 17" Macbook Pro with 4gig Ram. Sometimes the ram fills up and the graphics card freaks out. Everything on my mac becomes garbled and I have to force

  • Cannot uninstall Quicktime 7.02!!!

    Hi, I cannot uninstall QuickTime 7.02 from my computer. As a result, I cannot access my itunes, because version 6.0 requires QT 7.03!! Please help!! Without music!!

  • CA02 Routing change with /SAPMP/BAPI_ROUTING_PROCESS

    Hello , I am using /SAPMP/BAPI_ROUTING_PROCESS BAPI to change Standard values VGW02 field , I m getting the below errors , Operation cannot be locked (lock management error) Operation cannot be locked (lock management error) Please advise about what