Share on Google+Share on Google+

paparao
mysql problem
1 Answer(s)      7 years ago
Posted in : JDBC

Ads

View Answers

August 31, 2009 at 4:17 PM


Hi Friend,

Create a database table image(image_id(bigint),image(blob))and use the following code:

import java.sql.*;
import java.io.*;

public class InsertVideo{
public static void main(String[]args){
String connectionURL = "jdbc:mysql://localhost:3306/test";;
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(connectionURL, "root", "root");
PreparedStatement ps = con.prepareStatement("INSERT INTO image VALUES(?,?)");
File file = new File("C://CHIMES.WAV";);
FileInputStream fs = new FileInputStream(file);
ps.setInt(1,3);
ps.setBinaryStream(2,fs,fs.available());
int i = ps.executeUpdate();
ps.close();
con.close();
}
catch(Exception e){
System.out.println(e);
}
}
}

Thanks









Related Tutorials/Questions & Answers:
mysql problem - JDBC
mysql problem   hai friends i have some problem with image storing in mysql. i.e while i am using image(blob) for insert the image it says... of creation of table in mysql. it will take any image and store in database
MySql date problem
MySql date problem  with a mysql query, how can you get records of previous week dynamically, starting from sunday and ending on saturday? I don't want records from current date, just the previous week
Advertisements
mysql installation problem - JDBC
mysql installation problem  Hi, when i installing mysql server on my pc in MySQL Server Instance Configuration Wizard,I enter the root pw... information. http://www.roseindia.net/mysql/mysql5/Installing-MySQL-on-Windows.shtml
mysql 4.x to 5.x upgrade problem
mysql 4.x to 5.x upgrade problem  mysql 4.x to 5.x upgrade problem
mysql problem - JDBC
mysql problem  hai friends please tell me how to store the videos in mysql plese help me as soon as possible thanks in advance   ... = "jdbc:mysql://localhost:3306/test"; Connection con=null; try
Charset problem upon publishing PHP + MySQL website
Charset problem upon publishing PHP + MySQL website  Charset problem upon publishing PHP + MySQL website
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... have no problem in saving the image in the folder, my problem is it can't save the record to mysql database. heres my code... index.jsp <%@ page
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... have no problem in saving the image in the folder, my problem is it can't save the record to mysql database. heres my code... index.jsp <%@ page language
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database
problem connect jsp and mysql - JSP-Servlet
problem connect jsp and mysql  hello, im getting an error while connecting jsp and mysql. I have downloaded the driver mysql-connector... Software Foundation\Tomcat 5.5\common\lib\mysql-connector-java-2.0.14.jar
problem in selecting second arraylist from mysql database
problem in selecting second arraylist from mysql database  Hi... in mysql database. In the below program , i have hard-coded that second list... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); Statement stmt
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database
Null pointer exceptation-Java Servlet web application,Problem connecting with MYSQL database  Hi everyone i would like to ask few question here,since i try to configure this out for 1 week,i dont find any solution for my problem
MYSQL
MYSQL  How to create time and date based trigger in mysql   MySQL Time Trigger
mysql
mysql  how to open\import table in .dbf format in mysql
MySql
MySql  what is default password of mySql, and how i configure mySql.   Hi, If you are installing MySQL on windows then you will have to provide the Password for the user root at the installation time. You may try
mysql
you need to download the mysql-connector jar file for connecting java program from mysql database.......   Hi friend, MySQL is open source database... is the link for the page from where you can understand how to Download and Install MySQL
mysql
mysql  want the code for mysql nested select query with single where condition.want to select data from more than one table
php problem
php problem  Hello!! I have a problem ,i want to display the data... not connect: ' . mysql_error()); } $sql = 'SELECT * FROM users WHERE username="'.$username.'" LIMIT 1'; $result = mysql_query( $sql); if(! $result) { die('Could
problem on php
problem on php   l have five tables and build them as forms and link between them php and database and i want to build query between them plz help me soon   PHP MySQL Tutorials
MySQL
MySQL In this section we will read about what is MySQL, MySQL distribution, MySQL features, MySQL architecture etc. MySQL unofficially, pronounced as My... the database. The development, distribution, and support of MySQL is done
mysql - SQL
mysql  hi i am using mysql. i want to create simple table... the problem : CREATE TABLE parent (id INT NOT NULL, PRIMARY...=INNODB; For more information MySql visit to : http://www.roseindia.net
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost
Mine Problem
Mine Problem  how to view a row from a table created in mysql in a java swing application
uploading problem
about file into database lib. i use navicat Mysql ... i use this code... <...(); } } } } %> my problem...: firstly.... then problem solved... bt real problem is when i upload files fusing mozilla
solve this problem
in table please tell me the solution for thid problem import java.io.*; import..."); PrintWriter out = response.getWriter(); String url = "jdbc:mysql...("text/html"); PrintWriter out = response.getWriter(); String url = "jdbc:mysql
Servlet problem
problem from last three month and now i hope rose india developers... connectivity code it works but problem is with servlet page. My servlet code...;"; Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://127.0.0.1
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter please help me this problem
problem in validation
problem in validation  sir/madam, i m using struts-1.3.10. i m getting a problem my properties file is not found.... while i hav configuired it in struts-config.xml file, like thanks n regards himanshu
Tutorials   
Java Spring Hibernate Struts Training how to retrieve text and images from mysql database and show on html page using jsp servlet How to install Neo4j on Ubuntu 15.10? please help me in these prog MYSQL - mysql copy table to another table example by creating new table solution for mapping hibernate and pojos from net beans through database Connect GWT application with Oracle inventory System of Medical Store inventory System of Medical Store inventory System of Medical Store inventory System of Medical Store This code have created jTable that connected with a database.every cell of last column have a button.But this button doesn't work properly.Where is the error java program Java Database Program jdbc Database connection class in a live project ..?? What is JDBC architecture? Unable to Create DSN for excel to ms access importing data and edit that data Database Scrolling Buttons how to use foreign key in java How to delete content of a log file from linux terminal? JSP-Oracle connectivity Student Management System Java code for Saving Marathi (Indian local language ) in Mysql and retrieving the same crud operations with foreign key constraint. I really need help with this assignment question Please help me out Please Backup Failed Mysqldump Got Errno 28 On Write Upgrade MySQL 5.1 to 5.5 in cpanel mysqldump all databases com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'jpa.sequence' doesn't exist persistence xml class element persistence.xml for MySQL MySQL JDBC Driver pom dependency code Blob column jdk6 and oracle 8i connexion oracle 8i et jdk6 java [ cannot retrive date from sql ] why?? Order Entry System How to threow timeout exception when DB is not responding How to threow timeout exception when DB is not responding This is the employee form to add data to mysql database but I got error of NullPointerException, Is this write code please give me feedback as soon as possible make a method which takes user name & pwd as parameter & validate them against the database. If the corresponding user exist return true otherwise false. prabhakar validating credentials and displaying error message in login .jsp if not valid JDBC jdbc jdbc code register servlet vibhu connectiondetails from vibhu

Ads

 
Advertisement null

Ads