Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa SQL code save word file in 10g database
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


vishu
code save word file in 10g database
1 Answer(s)      5 years and 4 months ago
Posted in : SQL



Advertisement
View Answers

September 10, 2009 at 2:10 PM


Hi Friend,

Try the following code:

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

public class InsertFile {

public static Connection getConnection() throws Exception {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:3306:test","root", "root"); return conn;
}

public static void main(String[] args)throws Exception {
String id = "001";
String fileName = "C:\\New.doc";

FileInputStream fis = null;
PreparedStatement pstmt = null;
Connection conn = null;
try {
conn = getConnection();
conn.setAutoCommit(false);
File file = new File(fileName);
fis = new FileInputStream(file);
pstmt = conn.prepareStatement("insert into file( file, file_data) values ( ?, ?)");
//pstmt.setString(1, id);
pstmt.setString(1, fileName);
pstmt.setAsciiStream(2, fis, (int) file.length());
pstmt.executeUpdate();
conn.commit();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
e.printStackTrace();
} finally {
pstmt.close();
fis.close();
conn.close();
}
}
}

Hope that it will be helpful for you.
Thanks


Related Tutorials/Questions & Answers:
code save word file in 10g database - SQL
code save word file in 10g database  I am not having any idea to save the whole word document in Oracle 10g. Please help me.   Hi Friend, Try the following code: import java.io.*; import java.sql.*; public
Text field save as word file
Text field save as word file  Dear experts At run how to save set of text field contains text into single Word file. To save in our desktop computer. Solve my problem
Advertisements
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
android connection to database oracle 10g
android connection to database oracle 10g  Hello, How i can connect my android application to my oracle 10g database
i am getting the problem when i am downloading the pdf file from oracle 10g database - Struts
i am getting the problem when i am downloading the pdf file from oracle 10g database  if i created the pdf file from pdf machine,it is storing into datbase and download the pdf file from database. but when i created the pdf file
Java save file to database
Java save file to database In this section, you will learn how to insert file to database. Description of code: Firstly, we need to establish a connection...(); } } Through the above code, you can insert any file into the database
How i upload file and save that record in database using JSP?
How i upload file and save that record in database using JSP?  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail form
Problem reading word file
Problem reading word file  Deepak you provide me code for extarcting equation from a word file and also to write in a word file.But when I again want to read preveously created word file(created by your code) it gives an error
How to read data from txt file and save to database MySql - Java Beginners
How to read data from txt file and save to database MySql  Please... save to database from JButton.Please give me a tutorial and source code this. Thank's very much   Hi friend, code to read a file import
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
upload and save the file
upload and save the file  upload and save a file from a computer to specific location of remote computer using jsp
Compare two word file
Compare two word file  How to compare two word file using Java
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
click a word and search it from a file
click a word and search it from a file  i want to link a word with a file and search it form the file by clicking it. what could the code for this process
save excel file with save and open dilog box
save excel file with save and open dilog box  following is my jsp code it is working correct.. i want to save excel file throgh jsp bt not by hard...");) user should have freedom to save the file in any location so plz give me
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..
Unable to connect servet, jsp to oracle 10g database.. Unable to retrieve data..  I have a class file AbstractDataAccessObject with the below code... for the connection to the database is specified in the Web-inf >> config
error in uploading image from jsp to oracle 10g database
error in uploading image from jsp to oracle 10g database  ... try to insert into the image into the database i got the above error please advice how to get rid of error   JSP upload image in Mysql database
save text file - Java Beginners
save text file  hi i have just start programming in java.please guide me if i want to read a text file in java.then the text file is save in which directory
stop word removal from text file
stop word removal from text file  i need java source code for stop word removal from a text file
how to save uploaded image in database using javascript
how to save uploaded image in database using javascript  Please can you tell me how to store uploaded image in database using java I'll use the upload code as extArray = new Array(".gif", ".jpg", ".png"); function LimitAttach
How to save database data into excelsheet using hibernate
How to save database data into excelsheet using hibernate  How to save database data into excelsheet using hibernate
Save a pdf with spring as below code
Save a pdf with spring as below code   c:/report.pdf All work in the same way, but never save the report to disk. How to solve this problem? please reply me
Counting specific word occurences in a file
Counting specific word occurences in a file  Hello I have a log file from the proxy which consists all the browsing history with date,time,url,ip address etc as fields.Now i need to take only main part of the url like the domain
Which extension i use for save hibernate file.
Which extension i use for save hibernate file.   Please give me answer that which extension i use for save the hibernate file and how i run that file... the class object to the database table. Another is the hibernate configuration file
SQL database parameters should save at where?
SQL database parameters should save at where?  Hi, Currently... the script will be running for very long time, I like to move the SQL database parameters to the file and read using JAVA I/O and allow user to edit the file
how to search a word on entire database? - SQL
how to search a word on entire database?  hi, I want to search a word into the entire database.. note: not from particular table.. using php and mysql. any way to find this? thanks in advance
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
Save file on Client Machine - Development process
Save file on Client Machine  Hi my application is running on main... from his machine try to save the file it gets saved in the serve machine i want to save the file created by my application on the client machine how can i do
why java file save as its class name
why java file save as its class name  hi,this is subbareddy vajrala.my doubt is why java files save as its class names
Export Database table to CSV File
Export Database table to CSV File In this tutorial, you will learn how to retrieve data from database and save it to CSV File. The Comma-separated values... as writing into a CSV file. Here is a database table is to be extracted: Example
Advertisements
 

 

 

DMCA.com