About MYSQL

About MYSQL

is it possible to upload the video on mysql database

View Answers

April 13, 2011 at 5:16 PM

1)page.jsp:

<%@ page language="java" %>
<HTML>
<HEAD><TITLE>Display file upload form to the user</TITLE></HEAD>
<BODY> <FORM ENCTYPE="multipart/form-data" ACTION="upload.jsp" METHOD=POST>
<br><br><br>
<center>
<table border="0" bgcolor=#ccFDDEE>
<tr>
<center>
<td colspan="2" align="center"><B>UPLOAD THE FILE</B><center></td>
</tr>
<tr>
<td colspan="2" align="center">&nbsp;</td>
</tr>
<tr>
<td><b>Choose the file To Upload:</b></td>
<td><INPUT NAME="file" TYPE="file"></td>
</tr>
<tr>
<td colspan="2" align="center">&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Send File"> </td>
</tr>
<table>
</center>
</FORM>
</BODY>
</HTML>

2)upload.jsp:

<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.zip.*"%>
<%
String saveFile="";
String contentType = request.getContentType();
if((contentType != null)&&(contentType.indexOf("multipart/form-data") >= 0)){
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while(totalBytesRead < formDataLength){
byteRead = in.read(dataBytes, totalBytesRead,formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
saveFile = file.substring(file.indexOf("filename=\"") + 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
File ff = new File(saveFile);
FileOutputStream fileOut = new FileOutputStream(ff);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
%><Br><table border="2"><tr><td><b>You have successfully upload the file:</b>
<% out.println(saveFile);%></td></tr></table>
<%
Connection connection = null;
String connectionURL = "jdbc:mysql://localhost:3306/test";
ResultSet rs = null;
PreparedStatement psmnt = null;
FileInputStream fis;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "root");
File f = new File(saveFile);
psmnt = connection.prepareStatement("insert into file(file_data) values(?)");
fis = new FileInputStream(f);
psmnt.setBinaryStream(1, (InputStream)fis, (int)(f.length()));
int s = psmnt.executeUpdate();
if(s>0){
System.out.println("Uploaded successfully !");
}
else{
System.out.println("Error!");
}
}
catch(Exception e){e.printStackTrace();}
}
%>









Related Tutorials/Questions & Answers:
About MYSQL
About MYSQL  is it possible to upload the video on mysql database   1)page.jsp: <%@ page language="java" %> <HTML> <... connectionURL = "jdbc:mysql://localhost:3306/test"; ResultSet rs = null
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
Advertisements
MySQL NOT IN
MySQL NOT IN In this section we will read about how to use the NOT IN function in MySQL with a simple example. MySQL NOT IN() function specifies... which will demonstrate you about how to use MySQL not in() function
MySQL Cast
MySQL Cast       Here, you will learn about the MySQL CAST() function.  CAST... employee;) Here, you will learn about the MySQL CAST() function.  ADS
About jsp
About jsp  Read Excel data using JSP and update MySQL databse
MySQL Configuration
MySQL Configuration       In this lesson you will read about the configuration of MySQL... with MySQL quickly without having to make many decisions about server
MySQL Commands
MySQL Commands       In this section, we are going to read about the mysql commands. Each statement is sent to the server for the execution by MySQL. MySQL provides lots
ABOUT Jtable
ABOUT Jtable  My Project is Exsice Management in java swing Desktop Application. I M Use Netbeans & Mysql . How can retrive Data in Jtable from Mysql Database in Net Beans
Mysql Table
Mysql Table       MySQL Create Table Here, you will read the brief description about the MySQL create table.    Mysql Add
doubt about J2EE connetivity
doubt about J2EE connetivity  steps to connect J2EE components with MYSQL
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
About Database
About Database  in my database i enter the date of birth as Birth_Date date but i dont know in which format we can mention the date of birth   In MySQL database, date should be entered in the following format: yyyy-mm
About Jsp
About Jsp  Hello sir, I am developing online Quiz project in jsp using MySql Database. I want to know that How I will show Questions from database One by One on Same page and also want to calculate Result for the User
MySQL By Date
MySQL By Date       In this section, you will learn about how to fetch the data in order by date in MySQL. We can arrange the data through the ORDER BY clause. In the following
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
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.ADS_TO_REPLACE_1
MySQL Training ? Online Free MySQL Training
want to know about MySQL, we are starting from installation to the development...; MySQL Configuration In this lesson you will read about... will learn about describing the allowable syntax for identifiers in MySQL
PDO MySQL
PDO MySQL: MySQL is one of the most popular open source database, in this current tutorial we will come to know how to connect MySQL with PHP using PDO. Most of the web developers use MySQL with PHP, and most of the examples in our
Check PHP MySQL Connectivity
Check PHP MySQL Connectivity: The first step of any kind of connectivity... can connect a PHP page with MySQL server.ADS_TO_REPLACE_1 Following piece... with MySQL server or not. Code 1: <?phpADS_TO_REPLACE_2 $con=mysql
MYSQL Database
MYSQL Database  Can any one brief me about how to use MYSQL Database... about creating table and using MYSQL, just follow the below link and it will provide you extensive knowledge about your query. http://www.roseindia.net/mysql
About struts
About struts  How will we configure the struts
MySQL Convert
MySQL Convert       This section describes about the MySQL convert. It provides a way for converting..._TO_REPLACE_4 In the following query we will use MySQL convert() function. 
About java
About java   how we insert our database data into the jTable in java or how we show database content into the JTable... = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root
Mysql Time Zone Conversion
Mysql Time Zone Conversion       The Tutorial illustrate you an example from 'Mysql Time Zone Conversion' that describes you about the time zone conversion. SYNTAX
About Java
About Java  Hi, Can anyone tell me the About Java programming language? How a c programmer can learn Java development techniques? Thanks   Hi, Read about java at http://www.roseindia.net/java. Thanks
about java
about java  how to get the value from the user like c, c++ program pls explain with example for me
about jquery
about jquery  i want to put already made dropdown menu code which is in internet into my website.but how to put
MySQL Coalesce
MySQL Coalesce       In this section, you will learn about MySQL Coalesce. It selects the first non-null value of its arguments. Syntax: coalesce(value,..): It returns the first
About Java2
About Java2  sir i want to a develop one text editor but the problem is that i m not able to save our file as text formet or any formet Sir plz guide me
about java1
about java1  Sir, i want to know how we develop 3d button ,lable,textfield etc. in java . sir plz give one program as well Thank you
About Main
About Main  can u create the object of one interface ? But i can able to create the abstract class through anonimous inner class.similarly can i
About Main
About Main  can u create the object of one interface ? But i can able to create the abstract class through anonimous inner class.similarly can i
about connectivity
about connectivity  hello i am basavaraj,will any one tell me how to use hibernate in struts.   Please visit the following link: Struts Hibernate Integration
MySQL Cursor
MySQL Cursor       Here we are going to describe about the MySQL cursor and how to declare, open... of MySQL cursor: Asensitive : Server may or may not make a copy
About Constructor
About Constructor  How many objects are create when this code will execute... String string = new String("Java is best Lang."); tell me the number of object of string which will create . All are those are eligible for garbage
about session
about session  hey i want to insert userid and username of the user who have currently loggedin in servlet using prepared statement   Please visit the following link: http://www.devmanuals.com/tutorials/java/servlet
About Project
About Project  Hello friends i want to make a project on face reconization this is my first projct so please help me that how i start my projct please tell me some working with image codeing. thanks
Welcome to the MySQL Tutorials
that you want to know about MySQL, we are starting from installation... In this lesson you will read about the configuration of MySQL... In this section you can learn about the uses of MySQL String
MySQL Create Table
MySQL Create Table       Here, you will read the brief description about the MySQL create table...; There are following way to create MySQL table:ADS_TO_REPLACE_1      ADS
about a program
about a program  hi can anyone suggest program for this question.. it wil really be helpful.its based on *servlet programming* 1. First page should display a dropdown of mathematical operation (Add, Subtract, Multiply, Divide
About RoseIndia.net
About RoseIndia.Net RoseIndia.Net  is global services ...) programming, ASP, C#, PHP, Perl, J2ME, XML, relational databases (MySQL, Oracle..., MySQL Operating Systems: Windows, Unix, Linux
MySQL By Week
MySQL By Week       In this section, you will learn about the MySQL By Week. If you want to get...(): MySQL has the function WEEK() which returns a week number. ADS
about form
about form  how to dynamically increase the textbox in the 2nd form when i gave any value in textbox of form1 . if i gave 5 in the textbox of form1 , totally 5textbox have to be created in form2.   import javax.swing.
About BufferedReader
About BufferedReader   I have created FileInputStream fstream = new FileInputStream("E:\\TE MODULE\\Main Workspace\\OS PHASE 1\\input.txt"); DataInputStream in = new DataInputStream(fstream); BufferedReader bfr = new
About this tutorial
About this tutorial     ... for their organization.   Information about setting up Simple Cart Information about how features are implemented and explains basic API related
How To Store Image Into MySQL Using Java
How To Store Image Into MySQL Using Java In this section we will discuss about... explains you about all the steps that how to store image into MySQL database... you about how to store image into database using Java. We will use the MySQL
About Webservice - WebSevices
About Webservice  I wanted to know about WebServices
About the project
About the project       Shopping cart application is an open source project written in Java ,Struts and Hibernate. This  helps  people that want to develop

Ads