code save word file in 10g database

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... 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
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 notepad file into Ms word file in 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
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
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
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
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
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 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
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
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 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
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
How to save file in vi editor?
:w to save the file Type :wq to save and quit Type :q! to quit without saving...How to save file in vi editor?  Hi, I am trying to find commands to save the file in the vi editor? Can anyone show me the example and explain me
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:ADS
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
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
Searching a word file on server in JSP - JSP-Servlet
Searching a word file on server in JSP  Seacrhing a word file on server side using JSP. I am Apache Tomcat Server. Please help me Sir
Insert Image into Mysql Database through Simple Java Code
simple java code that how save image into mysql database. Before running this java code you need to create data base and table to save image in same database... Insert Image into Mysql Database through Simple Java Code
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
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
how to match the key word from a text file
how to match the key word from a text file  p>Hi all, I have the code to match the key word and from the text. I have input like this reader.txt... code is as follows **import java.io.*; import java.io.BufferedReader
Count repetitions of every word from an input file
Count repetitions of every word from an input file  Hello..i got to know how can i count the repetitions of every word present in a specific input file?For suppose if i have a url log file which have time,url's,ip address etc
how to import excel sheet into mysql database and save it as a table in database
how to import excel sheet into mysql database and save it as a table in database  sir, i want to import an excel sheet into a MySQL database and after importing it i want to store the excel sheet as a table in database
Save JRadioButton Text in to database - Java Beginners
Save JRadioButton Text in to database   Hello Sir I have Two JaradioButtons 1)Semwise Course 2)Yearwise Course I want To Save Text from... the following code: import java.sql.*; import javax.swing.*; import
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database... occurred processing JSP page /upload.jsp at line 27 24: String file
download code from database
download code from database  how to download files from database
save switch data into database - Java Beginners
save switch data into database  switch(menu) { case 1://add a student System.out.print("Enter student ID: "); int ID = scan.nextInt...;  Hi Friend, Try the following code: import java.sql.*; import
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
ModuleNotFoundError: No module named 'komica-save-file'
ModuleNotFoundError: No module named 'komica-save-file'  Hi, My... named 'komica-save-file' How to remove the ModuleNotFoundError: No module named 'komica-save-file' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'komica-save-file'
ModuleNotFoundError: No module named 'komica-save-file'  Hi, My... named 'komica-save-file' How to remove the ModuleNotFoundError: No module named 'komica-save-file' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'odoo8-addon-save-translation-file'
ModuleNotFoundError: No module named 'odoo8-addon-save-translation-file' ...: ModuleNotFoundError: No module named 'odoo8-addon-save-translation-file' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-save-translation-file'
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
How to upload and save a file in a folder - Java Beginners
How to upload and save a file in a folder  Hi How to upload and save a file in a folder? for example Agreement.jsp File: So when... should be able to access the file. Can u please tell me the code..  
How to save JPanel as gif or jpeg file
How to save JPanel as gif or jpeg file  i draw polygons , rectangles, lines on jpanel using draw line method drawpolygon methods etc, now i want save the data of jpanel which is drawn by me(lines,polygons) as a gif or jpeg file
How to save JPanel as gif or jpeg file
How to save JPanel as gif or jpeg file  i draw polygons , rectangles, lines on jpanel using draw line method drawpolygon methods etc, now i want save the data of jpanel which is drawn by me(lines,polygons) as a gif or jpeg file
Java search word from text file
Java search word from text file In this tutorial, you will learn how to search a word from text file and display data related to that word. Here, we have... to find details: "); String word=input.next(); File f=new File("c
How to Open Text or Word File on JButton Click in Java - Java Beginners
How to Open Text or Word File on JButton Click in Java  How to Open Text or Word File on JButton Click in Java
Merge multiple jasper file to one word Doc using java
Merge multiple jasper file to one word Doc using java   how to Merge multiple jasper file to one word Doc using java