Insert picture in MySQL using Netbeans 5.5

Can anyone help me how to insert a picture in MySQL database by using Netbeans 5.5?
I understand that we need to use BLOB as the data type, but how to make MySQL read the location of the picture?
As an example, in table cars,
I have set the datatype VARCHAR for carid, name, vendor and type.
While for pic, I selected BLOB as its datatype.
How I insert data into the table?
I choose Execute Command at carid(primary key) and enter the information.
insert into cars (carid, name, vendor, type,pic) values ('N1','Skyline GT-R','Nissan','4WD',C:\\Documents and Settings\\My Document\\car1.jpeg)
However, I got wrong in term of assigning the value for pic. What should I do?
Please help me.
Thank you in advance.

May I know what do you mean by binary data of the
picture?
I really don't get it.We can see that.
First of all, you do not, as you were trying, just give MySQL a filepath and have it do some magic. That won't work to store the actual image contents in the database.
So what should you do? Create a PreparedStatement. Get the content of the image file (using some sort of stream). Bind the content of the image to your PreparedStatement. Execute the insert.

Similar Messages

  • Problem in Inserting string in mysql databse

    Hi all,
    I am trying to insert string in mysql using java query.As I have taken field varchar,that should be in single quotes,whereas string is having double quotes...so as I am trying to insert data that gives null value all the time.
    I did like:
    String name=jTextFieldname.getText();
    String sql="insert into record_master values (name,orderno,email,dob,address,mobile)";Any pointers are appreciable.
    Regards,
    Palak

    Oh I got the sollution...Tat was something like:
    String sql = "INSERT INTO record_master (name, orderno,email,dob,address,mobile,imeino) " +
    "VALUES('" + name + "', '" + orderno + "','" + email + "','" + dob +"','" + address +"','" + mobile + "','" + imei + "')";
    Regards,
    Palak

  • How to insert data into mysql database using GUI?

    HI there,
    I have created a GUI application using Netbeans 6.7.1 in which there are three jtextfields. Now from those text fields i have to insert data in the mysql database. I have already connected to mysql using drivers and URL which is used to connect to DB. So what code should i write in the source of these text fields. Please help me and give the code to it.
    I actually don't know what code to be written in the source of a text field.
    Thank You.

    Yo buddy i didn't mean that. I wanted to say that if you see my project then it will be easy for you to help me. okay have a look at this code and tell me i have just created my gui
    This is Main.java -->
    package bookdatabase2;
    import java.sql.*;
    import java.awt.*;
    import javax.swing.*;
    * @author Mohd Azeem
    public class Main {
    * @param args the command line arguments
    public static void main(String[] args)throws Exception {
    // TODO code application logic here
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/books","root","");
    //PreparedStatement state=con.prepareStatement("select * from titles");
    //ResultSet result=state.executeQuery();
    //while(result.next()){
    // System.out.println(result.getString(1)+" "+result.getString(2)+" "+result.getString(3)+" "+result.getString(4));
    This the gui i have created
    BookDatabase.java -->
    package my.bookdatabase;
    import java.sql.*;
    import javax.swing.*;
    public class BookDatabase extends javax.swing.JFrame {
    public BookDatabase()throws Exception {
    Class.forName("com.mysql.jdbc.Driver");
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/books","root","");
    initComponents(); }
    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    // TODO add your handling code here:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
    public static void main(String args[])throws Exception {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    try{
    new BookDatabase().setVisible(true);}
    catch(Exception e){}
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    // End of variables declaration
    Now tell me what to do?
    i have only created the gui but unable to run it
    when i click on run only main.java is being executed
    but bookdatabase.java is not getting executed?
    what should i do please help?

  • HT5361 When inserting pictures in a new mail message using the " photo browser" button I can view and select photos but the " choose "  button is gone. What have I done wrong?

    When inserting pictures in a new mail message using the " photo browser" button I can view and select photos but the " choose "  button is gone. What have I done wrong?

    Hi Liz,
    Sorry to hear you are having a similar problem.  Last night I went to the tool bar at the top of iphoto, clicked on "File",  then clicked "Browse Backups" in the drop down menu.    I have an external hard drive that is set up to Time Machine.   The Browse Backups  opened the iphoto pages in the Time Machine.  I selected a date one day ahead of the day I performed the now infamous update, and it showed my iphoto library as it had existed that day.   I then clicked  "Restore Library" at the bottom right corner of the Time Machine screen.   Roughly 2 hours later my iphoto was back to normal.   When I opened iphoto there was a message saying I need to upgrade my program to be compatible with the new version of iphoto(version 9.2.1).  I clicked "Upgrade" and within seconds it had done whatever upgrading it needed to do. 
    The only glitch in the restoration was that it restored the library as it appeared last week, so I no longer had photos I had imported this past weekend.   I simply went back to the Browse Backups in the drop down menu,  when Time Machine opened I selected the page showing my pictures from this weekend and again said to Restore Library.   Roughly 45 minutes later the library was restored including the most recent photos.  
    I am now a happy camper. 
    I don't know if any of this will be of help to you because your email says you are having trouble with photos imported after the upgrade was performed.   Have you had any pop up notices when you first open iphoto,  that tell you you need an upgrade to be compatible with the new iphoto?     If so have you clicked "upgrade"? 
    Good luck Liz,  if you have Time Machine running as a back up to your library, maybe you wil be able to get help there, by following my instructions above.   Otherwise,   good luck with your investigations.   I'd be interested in hearing how you make out.
    Karen

  • Inserting Picture (from Web- through Webdav) to Word document using VSTO code

    Hi,
    I have been trying to insert an image/picture to current selection in word. with help of code -
    Microsoft.Office.Interop.Word.InlineShape s = this.Application.Selection.InlineShapes.AddPicture(
    @"http://127.0.0.1:9001/test/myimage.png", true, true, Type.Missing);
    This code works fine if image is on desktop or network shared location but some issues for URL exposed through Webdav.
    On inserting the picture word shows - "The linked image cannot be displayed....." message. If we close and open word document again then image appears properly.
    Some observations:
    1. If we use same option through Ribbon  "Insert -> Picture -> Enter path and click on "Link to File" then we get Prompt for Wevdav password (Only once, later Word caches it) and linked images appear properly.
    2. Updating the shape explicitly wouldnt help. 
    s.LinkFormat.Update();
    What we are looking for is, Does Ribbon "Insert" functionality do something additional to prompt Webdav authentication to cache? if we want to achieve the same? what needs to be invoked before we make call to AddPicture API?
    Thanks
    H

    Thanks for the response.. 
    No, when document is opened again, then you dont need to enter the password. 
    Somehow on document open event MS word knows how to retreive password from cookie for given domain.
    When you insert the image using ribbon -> insert picture option, 
    MS Word first looks into cache if the domain cokkie already available then bypass authentication/password prompt
    Otherwise it would show the prompt and store the cookie in cache again.
    The mystry is how MS-Word interacts with this "cached cookies"
    while doing more reading on this, it seems MS Word has been using Klink.dll for this kind of functionality https://support.microsoft.com/en-us/kb/899927 but it would be great if you can provide more pointers.
    >>Could you share an image link of Webdav?
    Since, it's my local webdav server, you would not be able to access the image link, may be you can upload an image to sharepoint (as sharepoint also supports webdav) and use that for reproducing this problem at your end.
    Thanks
    H

  • Creating mysql schema from pojo with hibernate using netbeans

    I have been fortunate in finding some good tutorials on how to create POJOs from database schema using hibernate (e.g. http://netbeans.org/kb/docs/web/hibernate-webapp.html).
    Does anyone know of tutorials on creating database schemas from POJOs -- preferable using netbeans? Even the very smallest tutorial with one table or two related tables will do.

    961389 wrote:
    I have been fortunateNot really, that is not rare information.
    Does anyone know of tutorials on creating database schemas from POJOs -- preferable using netbeans? Even the very smallest tutorial with one table or two related tables will do.Netbeans has little to do with the creation of the schema, it's the container that's usually configured to do it. You can use the "hibernate.hbm2ddl.auto" property to control whether the DDL is created from the entities automatically.

  • How to insert picture into Jframe?

    sorry... can someone teach me how to insert picture(gif,jpeg) into Jframe?
    besides, where can i get tutorials about NetBeans?
    Thank you very much~~!

    It can't be done using java.

  • Insert pictures and video

    Hello,
    How can I insert videocuts into a show I recorded myself? I am in the studio, presenting a show and during the presentation I want to show pictures and video to the audience.
    * I wil first record the show in our studio
    * And then I insert pictures and video on certain places in the recorded show.
    Is this possible in Imovie 8 or in one of the older imovies.
    Or must I use finalcut for this?
    Thanks! Richard - The Netherlands

    Hello, Richard,
    I have not used iMovie 8 much, so don't know about doing this in that version, but you can easily do this in iMovie HD 6.
    I am not sure exactly how you want to do this. It depends on whether you want to place those photos and other video clips OVER the recorded show, so that the audio from the recorded show plays while the photos and videos are displayed, or if you want to have them ADDED in the midst of the recorded show.
    If you just want to insert photos and videos in the midst of your recorded show, first import your recorded show into iMovie6. Put it in the timeline. Move the playhead to the point where you want the first photo, and do a 'split video at playhead' command, drag the photos/videos to the time line there. They will be added between the split video clips. Repeat for all the photos/videos.
    It sounds as if the option you want is 'Paste Over at Playhead' which allows the photos and videos you add to be seen over the recorded show, so that the audio plays continually. In tv and movies this is done when someone is talking about something and then there is a 'cut-away' to a photo or video clip of whatever the person is describing so the audience can visualize what he is saying while he is speaking.
    Here are instructions for doing that from iMovie HD6 Help:
    *Inserting video clips or photos in a passage while maintaining running audio*
    +You can paste a new video clip or photo over an existing clip while retaining the audio from the original clip. The video cuts away to a new picture, but you continue to hear the sound from the original clip.+
    +To replace images in a clip while maintaining running audio:+
    +Choose iMovie HD > Preferences, and then click General.+
    +Select the "Extract audio when using Paste Over at Playhead" checkbox.+
    +Select the video or photo that you want to insert.+
    +Choose Edit > Cut or Copy.+
    +Do one of the following:+
    +To paste the entire video you selected in step 3, position the playhead at the first frame to be replaced. When you paste the clip, it will replace a portion of video equal to its length.+
    +To paste over a specific segment of your movie, select the part of the video clip you want to paste over. (To learn more about selecting part of a video clip, see Related Topics below.)+
    +If the video you're pasting is longer than the selected frame range, the excess video will not be pasted. If the video you're pasting is shorter than the selected frame range, the extra space will be filled with a color clip (or the still image, if you paste a still image).+
    +Choose Advanced > "Paste Over at Playhead."+
    +The audio track of the original video is retained and appears in audio track 1 of the timeline viewer.+
    Post back if this does not address what you are trying to do.

  • Insert picture and sound without external sources

    how can we insert pictures and sound without using external sources??
    i mean , i want to make the picture somehow embeded inside the program, not from external source,
    can any1 help?/

    I sense that what you need to do is create a Jar (java archive) file for your code and images and any other resources. Do a search on the forum for the terms -- jar pictures getresource -- and you'll get a ton of helpful threads. Also check Google. Some useful links:
    http://java.sun.com/docs/books/tutorial/deployment/jar/
    http://forum.java.sun.com/thread.jspa?forumID=54&threadID=5183949
    http://www.cs.princeton.edu/introcs/85application/jar/jar.html

  • How to include the insert picture option in the PDF form?

    Hi, Can some one please help How to include the insert picture option in the PDF form? I am using acrobat XI pro and trying to use an evaluation form which requires to insert product pictures.

    Here's a link to a previous topic where this was discussed: http://forums.adobe.com/message/6050458

  • Inserting Pictures in an email

    Can someone help me figure out what the procedure is for getting the second window to come up for inserting a picture into your email.
    I hold my finger down on the screen until the copy paste panel appears with an arrow at the right side which is supposed to take you to the
    second screen where the insert picture is but most of the time it just disappears and you have to keep trying until it finally shows up.

    If you're using Mail on your iPhone, your best bet is to do this:
    Go into your photo stream, or camera roll, by selecting "Photos" from your apps.
    Press "Select" in the upper righthand corner of the screen.
    Tap each picture you want to include in the email, which will place a blue and white checkmark on each photo selected.
    When you've finished selecting the photo(s) you want to email, tap the icon in the lower lefthand corner of your screen, which looks like a box with an up arrow in it.  From the options that come up, choose "Mail" or "Email" (I don't recall offhand which it is).
    This will allow you to create a new email message with the selected photo(s) attached.
    If your'e trying to use a different email application, or email the photos in a different fashion, please provide me with more details so I can try to help you.

  • Perform as pdf form with the ability to insert pictures

    How to perform as pdf form. with the ability to insert pictures?

    You want your users to be able to insert images into a PDF form? That is only possible if they're either using Acrobat, or if they're using the latest version of Reader (XI) and the image is in PDF format.

  • Problem connecting to Mysql using JDBC

    Hi Everyone,
    I am trying to connect Mysql ad java applet and I am using the Mysql jdbc connector.
    I Took the mysql-connector-java-5.0.8-bin.jar file and put that in the library of jdk.
    Now i used the following code to connect to the database using Netbeans.
    package testmysql;
    import java.sql.*;
    public class Main
    public static void main (String[] args)
    Connection conn = null;
    try
    String userName = "root";
    String password = "";
    String url = "jdbc:mysql://localhost/rpms";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    conn = DriverManager.getConnection (url, userName, password);
    System.out.println ("Database connection established");
    catch (Exception e)
    System.err.println ("Cannot connect to database server");
    finally
    if (conn != null)
    try
    conn.close ();
    System.out.println ("Database connection terminated");
    catch (Exception e) { /* ignore close errors */ }
    But it displays Cannot connect to database server
    thoughMysql server is running.
    Can anyone tell me wats the prob in this.
    thanks

    String url = "jdbc:mysql://localhost/rpms";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    Is rpms the MySQL database?
    Is the database on the default port 3306?
    Is the MySQL JDBC JAR file in the classpath of the applet?
    newInstance() is not required to be invoked unless using <= JDK 2.0
    Replace:
    catch (Exception e)
    System.err.println ("Cannot connect to database server");
    with:
    catch (Exception e)
    System.err.println (e.getMessage());
    Edited by: dvohra09 on Apr 10, 2009 10:54 PM
    Edited by: dvohra09 on Apr 10, 2009 10:55 PM
    Edited by: dvohra09 on Apr 10, 2009 10:58 PM

  • Contribute CS4 +Blogger and inserting pictures

    I'm not fluent in Contribute, but I used to be able to insert
    pictures when I published to Blogger. I checked my connection,
    etc., and everything works with text; however, when I hit the
    button for inserting a picture, it is grayed out. When I went back
    to Contribute CS3 and tried the same thing, I inserted the picture
    but I got a message saying the document couldn't be published
    because it included pictures that were local. I had no success with
    pictures from the option of the internet, either.
    I tried signing in to Blogger, but the screen I got was the
    Blogger editor.
    I'd appreciate any help as I really want to use Contribute
    but I'm at a standstill as to what to do. According to what I've
    seen, inserting a picture should be as simple as dragging from an
    application -

    I appreciate your answer to my question. I have purchsed several books on Flash CS4, including Adobes own Classroom in a Book for Flash CS4.  The problem is that none of them show a tutorial on how to do this. I am hoping that you can give a more lengthy description of how to accomplish this task. I'm having a problem invisioning how the movieclip is created with my page. For instance, imagine that my primary page size is 1000 X 750. I want to create a scrollable page that includes text and photos. That page might be 800 X 2000. Therefore it would have a verticle scroll. How do I begin to arrange the text and pictures on such a long page? Do I create a completely different Flash CS4 page that is sized to 800 X 2000? Then insert all of my text and pictures. Do a "select all" and save a s a movieclip? Then this becomes the source for the scrollpane? I've searched all day yesterday on the net and cannot find a tutorial on this subject. It is a staic page by the way. Nothing will ever change or get loaded. Thanks for the help!

  • How to insert pictures into Excel?

    Hi, all
    I want to insert pictures with hyperlinks into excel files. Could you give me some sample code of this function? The code used abap ole, to insert pictures into excel.  ^ - ^   Thank you very much~~~
                                                                                    Voldemort.

    Hi, I had referred these code before, but it seems I still could not solve my problem...
    I could not understand the line:
    CALL METHOD OF gs_cells 'Select' = select.
    Is it used for insert picture? It does not seems to be...
    And in my program, the SY-SUBRC is 4 after run:
    CALL METHOD OF gs_picture 'Insert'
    EXPORTING
    #1 = 'C:\TEMP\Picture.bmp'.
    Of course my file path is correct, and the picture path is in my own coumputer rather than SAP server. Is that the problem?

Maybe you are looking for