Uploading images in access database using jsp

Hi, am using jsp with access database and want to upload as in a profile picture for any profile on the site[i mean depending on the user's convenience] ..
I just have a code which helps select the image from the client's machine n gets its address..but then how to use it in a form or something so that it can be submitted and inserted in the database?
Any idea? I d prefer not using servelet.. but if it just cannot be done without servelet then ok can suggest with that too.
Here is the code of Browsing to obtain the picture:
<form name=uploadForm action="uploadpic.jsp" method=post enctype="multipart/form-data" >     <input type="file" > <input type="submit" name="submit"  />     </form>

silversurface wrote:
Hi, am using jsp with access database and want to upload as in a profile picture for any profile on the site[i mean depending on the user's convenience] ..
bad. Don't put business logic in JSP, and that includes accessing databases.
Any idea? I d prefer not using servelet.. but if it just cannot be done without servelet then ok can suggest with that too.
Don't put business logic in JSP. That's what servlets are for (and EJB).

Similar Messages

  • How to upload the image and diplay the image in the browser using jsp

    How to upload the image and diplay the image in the browser using jsp
    thanks
    shan

    i'll suggest looking for sample code or tutorial with a relevant query in google, which as far more time than us to answer this type of reccurent question

  • Upload data from Access Database to Oracle Database In oracle 8i

    hi everybody
    i am trying upload data from Access database to Oracle Database
    i have TT(F1,F2,F3) table in Access Databsse
    and emp(ename,ecode,sal) in oracle Database
    db_ac is my datasource name
    when i connect to Access Database thru this command this show following error
    SQL> connect a/a@odbc:db_ac;
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    Error accessing PRODUCT_USER_PROFILE
    Warning: Product user profile information not loaded!
    You may need to run PUPBLD.SQL as SYSTEM
    Server not available or version too low for this feature
    ORA-00022: invalid session id; access denied
    Connected.
    when i am trying copy data as this command it show error and data not copied.
    SQL> COPY FROM A/A@ODBC:DB_AC TO test/test@ora INSERT EMP USING SELECT F1,F2,F3 FROM TT;
    Array fetch/bind size is 15. (arraysize is 15)
    Will commit when done. (copycommit is 0)
    Maximum long size is 80. (long is 80)
    ORA-00022: invalid session id; access denied
    ERROR:
    OCA-00022: general OCA error
    can help me .
    with thanx

    Hi there,<br>
    <br>
    Please kindly use instead the Database Forum at:-<br>
    General Database Discussions<br>
    <br>
    ... to place your question as this is for the Oracle Portal product Export / Import functionality.<br>
    <br>
    <br>
    Kind regards,<br>
    Pedro.

  • How do I open a pdf stored in a Microsoft Access database using Visual Basic studios 2012

    Currently I am unable to find a valid method of being able to open a pdf stored in a Microsoft Access database using Visual Basic studios 2012. I've tried displaying the entire database on a form, but when I do this all the other columns show up with
    the correct data besides the one containing the pdf's, it just displays <binary data> in each row down the column. I also tried another method with which you use the database as a dataset and can drag and drop the rows and columns into the form, which
    again works for all the other columns besides the one containing the pdf's but this time I'm unable to interact with the column  at all. 
    Not too sure if this is in the correct place, but any answers or help would be appreciated. Cheers.

    Alex,
    This forum is dedicated to Project and Project Server. You might get better response, if you post to a Visual Basic forum. Here are couple I could find. 
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral%2Cvblanguage&filter=alltypes&sort=lastpostdesc
    Cheers,
    Prasanna Adavi, Project MVP
    Blog:
      Podcast:
       Twitter:   
    LinkedIn:
      

  • Setting System DSN for MS Access Database using Java Code

    How to set the system DSN for Access database using Java Code at runtime....???
    Replies are deeply appreciated...

    I found a 3rd Party MS Access JDBC Driver from a Google search. I downloaded and tried the free trial version. It worked fine but we opted not to purchase the full version and went a different route. If you don't find it, let me know and I'll see if I can track down the name of the product we tested.

  • Hi can anyone explain me how to  syncronize two database using jsp?

    Hi can anyone explain me how to syncronize two database using jsp?

    I thinking than you really need the jsp page for calling the java methods whith sincronize the database.You think wrong.
    You wrote a bad question.What was bad about it?
    You need a java method for sincronize the two databases using a jsp page.No you don't, see my answer.

  • Error trying to run the Sample Code Virtual Private Database using JSP's

    Hi.
    I`ve downloaded the Virtual Private Database using JSP's example from the Oracle9iAS Security - Sample Corner (http://otn.oracle.com/sample_code/deploy/security/9i_security.html)
    I ran the SQL script just fine. I�ve Opened the JDeveloper Flile (security.jws) and tried to Make it (following step 2 on "Run the Application using JDeveloper Environmentinstructions" in the README ) but i get this error:
    Error: unable to copy to output directory, web.xml not found
    It seems that i need the web.xml to run this application, but in the zip file i cannot find any XML file.
    What can i do?.
    Thanks in advance for your help

    Hi,
    the problem seems not to be within your application but in missing files on your embedded OC4J. Just try and unzip the JDeveloper 10.1.3 install again.
    Frank

  • How to store and retrieve blob data type in/from oracle database using JSP

    how to store and retrieve blob data type in/from oracle database using JSP and not using servlet
    thanks

    JSP? Why?
    start here: [http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html]

  • Integrate 300 MS Access Databases using ODI

    Hi All,
    I am trying to integrate data between 300 similar MS Access databases using ODI. All the source databases have exactly the same data structures. I have done a POC for 3 databases by creating interfaces and could integrate the data between them successfully.
    Now that the project is approved ; Going forward I need to integrate data from 297 MS Access databases, so I need to run the same set of Interfaces on 297 source MS Access Databases with Target DB being the same.
    This integartion work could be labourious as I need to copy 7 interfaces on 297 databases - IS THERE ANY EASY SOLUTION FOR THIS PROBLEM.
    Some one suggested me to use Dynamic Variables in the TOPOLOGY to access all the MS Access databases - BUT NOT SURE IF THAT WORKS.
    APPRECIATE your suggestions.
    Thanks & Regards
    Kay

    The issue you face here is that the Access database is connected to through the JDBC-ODBC bridge to the Access ODBC database driver. You will need to have a separate DSN defined for each of the access databases, if you want to address each individually.
    An alternative approach is to have one DSN set up, one entry in ODI's topology, one interface etc, and each file you wish to use, you rename to a given name first. Thus, when ODI tries to access the database, the ODBC driver finds the then current file. Note that ODI keeps the database connection for the duration of a SESSION, so if you wanted to process all 300 files sequentially, then you would need to run separate sessions for each of the file executions.
    I think this will give you the solution you require without resorting to variables.

  • 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

  • Using MS-Access database in JSP application

    Hi, all. I am new in JSP world. I have an Access database and I�d like to access it in my JSP Application.
    Does anybody know I could do this?
    TIA
    Fernando

    Define your database as an ODBC source and then use the JDBC/ODBC bridge. It's actually only a few lines of code - see http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html

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

  • Viewing Images from Database using JSP/ SQLJ

    Dear Friends,
    I could manage to write an image into a BLOB Field in the Oracle
    Database. I could even manage to read that image from the
    database but i am doing it by reading the BLOB data and writing
    it into a file with 'gif' or 'jpeg' extension.
    I would like to know how to read the BLOB data dynamically in
    cache and display it on the JSP page in the browser without
    creating a file on the disk.
    Thanking you,
    Sarwottam

    Thanks for replying,
    Can you please elaborate on your suggestions ?
    If possible can you provide a sample code that would help me understand better?
    Thanks again.
    Sarwottam

  • Upload image into mysql database residing on  remote server is not working?

    hello to all,
    i need ur help,we hav online site .
    i have to upload image(which can b from any pc) into mysql database residing on remote server of which we (don't hav actual path of that server).
    the solution i'm using is working correctly on local bt when transfer it to server it shows
    java.io.FileNotFoundException: (No such file or directory)
    i have used multipartRequest to access parameter of file type input.
    all variables and related packages r imported properly.no prblm in that.
    code is here....................................
    try {
    MultipartRequest multi = new MultipartRequest(request, ".", 500000 * 1024);
    File f = multi.getFile("uploadfile");
    out.println(f.getName());
    filename = f.getName();
    String type = multi.getContentType(f.getName());
    fis=new FileInputStream(filename);
    byte b[]=new byte[fis.available()];
    fis.read(b);
    fis.close();
    Blob blob=new SerialBlob(b);
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://10.1.52.206:3306/test?user=root&password=delhi");
    String query="insert into uploads (FILENAME,BINARYFILE,) values (?,?)";
    pstmt=con.prepareStatement(query);
    pstmt.setString(1,filename);
    pstmt.setBlob(2,blob);
    int i=pstmt.executeUpdate();
    if(i>0)
    out.println("Image Stored in the Database");
    else
    out.println("Failed");
    } catch (Exception ex) {
    out.print("*******************"+ex);
    ex.printStackTrace();
    please suggest me the way to upload image to remote server** not on local server.
    its urgent.
    Edited by: JavaDevS on Jul 28, 2008 11:41 AM

    i need ur help,we hav online site .Please don't use these juvenile abbreviations. It's impolite when you're asking for assistance not to make the effort to spell out all of the words. Moreover in a forum with an international readership the use of standard English will reduce the possibility of confusion.
    I presume that your file upload is being placed in a different directory from that which you were expecting. I would suggest logging all paths (specifically filename) to see if this is an unexpected value.
    Please explain further what you mean by "local" - is this a stand-alone application, or merely running a copy of the server on your local machine and doing the transfer (via the browser) to that? Are there any other differences such as the browser used?

  • How to upload images to MySql database.

    Hey guys so i created a insert form in dreamweaver to add to a database, its workin fine but i want to add another field to browse for and add a small image of the item. I created my insert form with a wizard and I'm not sure how to add an image uploader to it. I have a blob field in my database called "image" I'm just not sure how to add to it from my form.  Here is the code for my insert page so far:
    <?php require_once('../Connections/cbdb.php'); ?>
    <?php require_once('Zend/Date.php'); ?>
    <?php
    if (!isset($_SESSION)) {
      session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
    // *** 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 == "") && true) {
          $isValid = true;
      return $isValid;
    $MM_restrictGoTo = "login.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":
          if ($theValue == "")
        $theValue = "NULL";
       else
        $zendDate = new Zend_Date($theValue, "d/M/yyyy");
        $theValue = "'" . $zendDate->toString("yyyy-MM-dd") . "'";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    // *** Redirect if username exists
    $MM_flag="MM_insert";
    if (isset($_POST[$MM_flag])) {
      $MM_dupKeyRedirect="stock_already_exist.php";
      $loginUsername = $_POST['registration'];
      $LoginRS__query = sprintf("SELECT registration FROM stock WHERE registration=%s", GetSQLValueString($loginUsername, "text"));
      mysql_select_db($database_cbdb, $cbdb);
      $LoginRS=mysql_query($LoginRS__query, $cbdb) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      //if there is a row in the database, the username was found - can not add the requested username
      if($loginFoundUser){
        $MM_qsChar = "?";
        //append the username to the redirect page
        if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
        $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
        header ("Location: $MM_dupKeyRedirect");
        exit;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO stock (make, model, `year`, cc, fuel, doors, body, `date`, registration, keywords) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['make'], "text"),
                           GetSQLValueString($_POST['model'], "text"),
                           GetSQLValueString($_POST['year'], "text"),
                           GetSQLValueString($_POST['cc'], "text"),
                           GetSQLValueString($_POST['fuel'], "text"),
                           GetSQLValueString($_POST['doors'], "text"),
                           GetSQLValueString($_POST['body'], "text"),
                           GetSQLValueString($_POST['date'], "date"),
                           GetSQLValueString($_POST['registration'], "text"),
                           GetSQLValueString($_POST['keywords'], "text"));
      mysql_select_db($database_cbdb, $cbdb);
      $Result1 = mysql_query($insertSQL, $cbdb) or die(mysql_error());
      $insertGoTo = "stock_added.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    mysql_select_db($database_cbdb, $cbdb);
    $query_rsStock = "SELECT * FROM stock ORDER BY stockId ASC";
    $rsStock = mysql_query($query_rsStock, $cbdb) or die(mysql_error());
    $row_rsStock = mysql_fetch_assoc($rsStock);
    $totalRows_rsStock = mysql_num_rows($rsStock);
    ?>

    supersham101 wrote:
    Hey guys so i created a insert form in dreamweaver to add to a database, its workin fine but i want to add another field to browse for and add a small image of the item. I created my insert form with a wizard and I'm not sure how to add an image uploader to it. I have a blob field in my database called "image" I'm just not sure how to add to it from my form.
    Storing images in a database is generally not a good idea. Apart from bloating your database and increasing the risk of table fragmentation when images are updated or deleted, you cannot display an image directly from a database. However, if you want to do it, you will find instructions here: http://cookbooks.adobe.com/post_Upload_images_to_a_MySQL_database__PHP_-16609.html.
    The more common (and efficient) approach is to use the database to store details of the image, such as filename and caption. Then upload the image to your website's file system.
    I give step-by-step instructions how to do this in my book, "Adobe Dreamweaver CS5 with PHP: Training from the Source", but if you have reasonable skill at using PHP, you can learn how to handle file uploads from the PHP Manual at http://docs.php.net/manual/en/features.file-upload.php.

Maybe you are looking for