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



Home Answers Viewqa Development-process fetching data from cosole
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


prashant
fetching data from cosole
1 Answer(s)      4 years and 5 months ago
Posted in : Development process


Hi Deepak,
i hv parsed the pdf file into the console (using Pdfbox). output is proper.now i want that console data into the database?
how can i parse that console data and save it into the database? please your help is appreciated.

Prashant.


Advertisement
View Answers

June 19, 2010 at 5:50 PM


Hi Friend,

We have used itext api. Here is the code:

import java.io.*;
import java.sql.*;
import java.util.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;

public class ReadPDF {
public static void main(String[] args) throws IOException {
try {
Document document = new Document();
document.open();
PdfReader reader = new PdfReader("file.pdf");
PdfDictionary dictionary = reader.getPageN(1);
PRIndirectReference reference = (PRIndirectReference) dictionary
.get(PdfName.CONTENTS);
PRStream stream = (PRStream) PdfReader.getPdfObject(reference);
byte[] bytes = PdfReader.getStreamBytes(stream);
PRTokeniser tokenizer = new PRTokeniser(bytes);
StringBuffer buffer = new StringBuffer();
while (tokenizer.nextToken()) {
if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
buffer.append(tokenizer.getStringValue());

}

}
String test = buffer.toString();
System.out.println(test);
String arr[]=test.split(" ");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root";);
Statement st=con.createStatement();
int i=st.executeUpdate("insert into data(name,address) values('"+arr[0]+"','"+arr[1]+"')");
} catch (Exception e) {
}
}
}

Thanks


Related Tutorials/Questions & Answers:
fetching data from cosole - Development process
fetching data from cosole  Hi Deepak, i hv parsed... that console data into the database? how can i parse that console data and save... into data(name,address) values('"+arr[0]+"','"+arr[1]+"')"); } catch (Exception e
Data fetching from JSP or HTML - JSP-Servlet
Data fetching from JSP or HTML  Hi Deepak, Can u pls help me as i have a problem with jsp/html frameset. my question is how can i fetch the data from frameset which is in html format.pls help me. Thanks
Advertisements
Fetching the exact data from file using java
Fetching the exact data from file using java  **hi ... i am having one .lst file.. that file consists of instructions and opcodes.. now i want to fetch only the opcode from that file.. could u pls anyone guide me this using java
iphone storing and fetching data
iphone storing and fetching data  How to store and fetch data in an iphone application
fetching data using servlets - SQL
for fetching data from a ORACLE10g database using SERVLETS.   Hi Friend...fetching data using servlets  I have successfully made connection.... But the codes that i have tried for fetching the data are not working even
Fetching image from database
Fetching image from database  I have uploaded image path and image name in database so, now how can i display that image using JSP or HTML page(is it possible to display using tag using concatination). image path i have stored
Fetching data from excel file on other website and display in interactive graph form
Fetching data from excel file on other website and display in interactive graph form  Hello, I am making a website using HTML and CSS, I am done... pull data data from those and generate graphs out of it? I really need it urgently
autocompletion in textfield fetching from database in jsp
autocompletion in textfield fetching from database in jsp  hi i want to retrieve country name from mysql db to textfield.. maeans if anyone type first letter of the name it should show the corresponding names in the list
how to create a bar chart in jsp by fetching value from oracle databse?
how to create a bar chart in jsp by fetching value from oracle databse?  i want to show the population of various states in a bar chart in my jsp page by fetching the data from my oracle table. i am using my eclipse as my IDE
Fetching database field from servlet to jsp page ?
Fetching database field from servlet to jsp page ?  Hello Java... field. I wanted to pass some of the database field from servlet to jsp... (i... ArrayList<String>(); String sql = "select * from country
Java Cosole not Displaying Greek letters - WebSevices
Java Cosole not Displaying Greek letters  Hello Team, I developed a webservice which reads data from xml string and stores in the data base, i got a new requirement to read Greek and Arabic characters from the xml and store
how to refresh google map using ajax by fetching lat long from database
how to refresh google map using ajax by fetching lat long from database ... the route travelled by it will be displayed on the google map by fetching the lat long from db. Now, i need to refresh the map using ajax.Pls help me how to do
JSP Get Data Into Dropdown list From Database
JSP Get Data Into Dropdown list From Database In this section we will discuss.... This tutorial explains you that how to fetch data from database and set... fetching of data into the dropdown list in JSP using Eclipse IDE and the Tomcat 7
What is lazy fetching in hibernate
What is lazy fetching in hibernate  Hi, What is lazy fetching in hibernate Thanks
Database fetching problem
Database fetching problem  I have multiple database table and want to get all records in one object how can i do this.Pls guide
Select data from diplicated data
Select data from diplicated data  hello i have table location... location FROM (".$is.") WHERE sub_cat=('".$id."')"; $result = mysql_query($SQL...++) { $SQL = "SELECT duration FROM core_network WHERE location=('".$location_c[$k
extract data from HTML
extract data from HTML  how to write the coding for to extract data from html tags like(h3,p) and then extracted data should be stored in data base? can anybody tell me how to write the coding
Data from multiple ResultSets?
Data from multiple ResultSets?  hello, How can I get data from multiple ResultSets?   Hi, You can iterate the ResultSet separately and get the required data. Thanks
selecting data from database
selecting data from database  how to select data from database using Dao in struts   Hi, You have to load the data from database using hibernate and send the data in a Java file object to jsp page. Please read at http
retrive data from database
retrive data from database   hi.. i made a application form. it's have attribute s.no,name,roll no and i enter a few records. now i want to view all record not in database access sheet i want to view it at any another
Insert Data From File
Insert Data From File       Insert Data From File is  used to insert data from file... to insert data from file. To understand this example, we create a table 'Stu_Table
retrive data from database?
retrive data from database?  hellow i have a database sheet name as db1. it's contain sixty(60) sn,name ,rollno(primary key),father's name etc... from db1 and enter value in text box according there name,rollno and save
to bring checked data from one page to another
fetching data from the database on second jsp page with checkbox corresponding each...to bring checked data from one page to another  thanks for your help... on save button then the two rows data should print on first jsp page without making
Insert Data From File
Insert Data From File       Insert Data From File is  used to insert data from file... to insert data from file. To understand this example, we create a table 'Stu_Table
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to retrieve data from database ?????/
how to retrieve data from database ?????/  how to retrieve data from database
how to fetch data from servlet ????
how to fetch data from servlet ????  how to fetch data from servlet
fetch data from database in javascript
fetch data from database in javascript   How to fetch data from database in JavaScript when it is a leap year
Data fetch from multiple SQL tables - Hibernate
example of HQL fetching data from multiple tables would be a help. I have tried...Data fetch from multiple SQL tables   I am in the process of writing my first hibernate application. I have a sql query that fetches data from
Advertisements
 

 

 

DMCA.com