473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

upload a text file into database

Hi,
I want to save a file into databse how can it is possible ?

Can any one help me to make codes in jsp. the codes require for upload a text file into database

Rgds
SanJay
Aug 4 '06 #1
7 10152
dis jsp code help u for uploading text into database

<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title></title>
</head>
<body>
<%
try
{
String name;
String address;
String path;
name=request.getParameter("name");
address=request.getParameter("address");
File image=new File(request.getParameter("image"));
path=request.getParameter("image");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sushikha","root","root");
PreparedStatement pstmt=con.prepareStatement("insert into pro(name,address,data,path) values(?,?,?,?)");
pstmt.setString(4,path);
pstmt.setString(1,name);
pstmt.setString(2,address);
InputStream is=new FileInputStream(image);
//FileReader is = new FileReader(image);

pstmt.setBinaryStream(3, is, (int)(image.length()));
int s=pstmt.executeUpdate();
if(s>0)
{
out.println("Uploaded");
}
else
{
%>
unsucessfull
<%}
is.close();
pstmt.close();
}
catch(Exception e)
{
}%>
</body>
</html>

neha..................
May 18 '07 #2
dmjpro
2,476 2GB
thanxxxx nehacredo u solved the problem.

first of all this is JS/AJAX forum so u should suggest the sanjay_scjp to post the code to JAVA forum.

one more thing ..... u should not send the whole code like this.
let him or her do it first.... then where he or she facing problem just to that point u should help.
actually i also in the begining .. requested for code but the experts told me that do it first urself then come here with ur particular problem.
because in this way i learnt a lot from this site.
thanx to TSDN to help me......
sorry to say .. but that's true story frnd.

kind regards.
dmjpro.
May 18 '07 #3
acoder
16,027 Expert Mod 8TB
Moved to Java forum.
May 18 '07 #4
hi guys i will like to know how to upload a file and save into the database phpmyadmin but its really getting me confused..and also want to view the content of the file saved.
thanks
jeffponder
Jul 23 '08 #5
i want to know how to upload a text file into the database and also view the content been saved
Jul 23 '08 #6
please i really need an asistance on how to upload a text file into the database where phpmyadmin is the database i use and also view the content..please if any solution it should be sent to my mail [DELETED]
thanks
Jul 23 '08 #7
RedSon
5,000 Expert 4TB
jeffponder,

Do not post your email in threads. Do not hijack another person's thread with your own problems/questions. If you have a similar question you can create another thread and link to this one.

Please read the posting guidelines located at the top of the screen under help.

-RedSon
Jul 23 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
1
by: Daniel | last post by:
I have looked everywhere on the web for an answer to this and the only thing I can find is converting the image format when the file is present on the local filesystem. What I want to do is use a...
5
by: Seok Bee | last post by:
Dear Experts, I currently trying to use the FileUpload control from asp.net 2.0 to upload files. The uploading of the file I would like to store it in the Access Database. Unfortunately, I've no...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
2
by: hotflash | last post by:
Hi Master CroCrew, I found a good PURE ASP that will allow you to upload 10MB file to the server and the file contents such as Network, Author, Title, etc... will insert to MS Access at the same...
3
by: shapper | last post by:
Hello, I need to upload a file. Can I only do this with the File Upload control? I also need the following: - Send upload info, upload percentage, continuously to a JavaScript function so...
4
by: MoroccoIT | last post by:
Greetings - I saw somewhat similar code (pls see link below) that does mupltiple files upload. It works fine, but I wanted to populate the database with the same files that are uploaded to...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.