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



Home Answers Viewqa Java-Beginners Read data again

Have Programming Question? Ask it here!
 
 
 


hendra
Read data again
3 Answer(s)      5 years and 8 months ago
Posted in : Java Beginners



Advertisement
View Answers

February 5, 2009 at 5:12 AM


Table:tes_aja

CREATE TABLE `tes_aja` (
`kd_div` varchar(30) default NULL,
`nm_div` varchar(30) default NULL,
`dep` varchar(30) default NULL,
`jab` varchar(30) default NULL,
`cab` varchar(30) default NULL,
`ket` varchar(30) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1

divisi.txt:

d00001;Operation;Finance;Finance Head;Kantor; Pusat;
d00001;Operation;Acct-Tax;Account Receivable;Kantor; Pusat;
d00001;Operation;Acct-Tax;Account Payable;Kantor; Pusat;
d00001;Operation;Operation;Operation Manager;Kantor; Pusat;


February 5, 2009 at 5:13 AM


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

public class ReadDataTxtFileAndInsertIntoDatabase
{
public static void main(String[] args)
{
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("C:\\divisi.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;

Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://192.168.10.75:3306/textdata","root","root";);

//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
String strar[] = strLine.split(";");
String query="";

try{
Statement st = con.createStatement();
System.out.println(strar[5]);
query = "INSERT into tes_aja (kd_div,nm_div,dep,jab,cab,ket) VALUES('"+strar[0]+"','"+strar[1]+"','"+strar[2]+"','"+strar[3]+"','"+strar[4]+"','"+strar[5]+"')";

int val = st.executeUpdate(query);
System.out.println("1 row affected");
}
catch (SQLException s){
System.out.println("SQL statement is not executed!");
}

}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}


Thanks
Vinod kumar


February 14, 2011 at 3:28 PM


Tks Vinod Kumar,

and how if create file in pdf and call from database?. thank you before



Related Tutorials/Questions & Answers:
Read data again - Java Beginners
Read data again  Hey, i want to ask again about how to read data...), jab varchar(35), cab varchar(15), ket varchar(30) My data in txt file is://i want this read to DB d00001;Operation;Finance;Finance Head;Kantor Pusat
Read data again - Java Beginners
Read data again  sir, i still hav a problem,first your code will be change like this : in netbeans out message error 5. Can you help me again. My... = DriverManager.getConnection("jdbc:odbc:hyt","root","suprax"); //Read File Line By Line
Advertisements
Read data again - Java Beginners
Read data again  OK my problem some like my first question.First i... varchar(15), cab varchar(15), ket varchar(30) then i have a data from txt file... Pusat; i want data from txt file save to database like my DB with one button.but
Read RFID data
Read RFID data  how to read RFID data using java
Data read. - XML
Data read.  How to store or read data in XML from Struts.Plz give me example. Thanx
when refreshing the page the data is stored in data base again
when refreshing the page the data is stored in data base again  Hi, In my application, I am adding form data in database on click of submit button.But the problem is, when user refreshes the page, the data added one more time
the last data entered into database is getting stored again after refreshing
the last data entered into database is getting stored again after refreshing  hey all i made a shout box using php and mysql but the last data entered into the DB is getting retrieved again as i refresh the page.. even
READ DATA - Java Beginners
READ DATA  i still don't understand, i have a data like...; Data in the up is my problem how to get this and save into database and ; must dissapear.then data go to values in database. d00002 go to kd_div,Marketing go
read data from Excel sheet
read data from Excel sheet  Hi, How to read data from an excel sheet using JSP. Thank you
to read data stored in ArrayList - Struts
to read data stored in ArrayList  this is regarding struts2, i have... them from database. Now i want to read the data of all 4 User objects from jsp file using struts2 tag. i have done the following thing, but i am getting data
a little problem in read data - Java Beginners
a little problem in read data  ok Vinod Kumar and friend, i already use this code. but is data null, this code will error5 again. How the data can go to database with null data. ex: value = (d00001;Operation;Finance;Finance Head
read excel data from jsp - JSP-Servlet
read excel data from jsp  Hi how to read excel file from jsp? Excel file is created manually entered data having many sheets? and read the entire...)excel.jsp: Read And Edit Excel File  continue
There and Back Again
There and Back Again       The weblog of Joshua Eichorn, AJAX, PHP and Open Source Read full Description
read text file and store the data in mysql - JDBC
read text file and store the data in mysql  when we store the data in mysql table from text file its store the data from new line to new column. how to store the data in different column from a single line of text file. 
Read Excel data using JSP and update MySQL databse
Read Excel data using JSP and update MySQL databse  HOw to read excel data using JSP and update MySQl database
How to read data dynamically from keyboard to array in flex
How to read data dynamically from keyboard to array in flex  How to read data dynamically from keyboard to array in flex
how read data from doc file in same formate in jsp
how read data from doc file in same formate in jsp  how we can read and display data on jsp page, from doc file with the same formatting
Read specific column data from text file in java
Read specific column data from text file in java  My question is if my text file contain 15 columns and i want read specific column data from that text file then what code i should do
How to read excel data and store it in database - Java Beginners
How to read excel data and store it in database  Hi, I want a java code to read data from excel and store it in Ms Access database.I tried the code... read data into database.So please give me some sample code. Thanks
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data... for scientific research analysis. My team members sends research data in excel file format and I need to update MySQL tables with new experimental data. How can I
How to read the data in text file seperated by by ',' in java using IO Operations
How to read the data in text file seperated by by ',' in java using IO Operations  in Text file data like raju 45,56,67 ramu 46,65,78 raji 34,23,56 this is the student marks in text file.this data read and calculate
how read excel data into database using struts2 with hibernate
how read excel data into database using struts2 with hibernate   hi friends, i am venkat i am started learning struts 2, please help me how to read excel data into database using struts2 with hibernate, please show me
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page ... the data from this .properties file and display it in table format. Ex:by using... = DEDCHGG_PWDP and goes on... I have to create a jsp page to show these data
Read data from Excel and insert in to DB and export data from DB to Excel
Read data from Excel and insert in to DB and export data from DB to Excel  Read data from Excel and insert in to DB and export data from DB to Excel Hi, I need to read the data from excel and I need to insert the same in to DB
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  import java.io.BufferedReader; import java.io.BufferedWriter; import...) { //read from start original file String arry[] = sCurrentLine.split
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  import java.io.BufferedReader; import java.io.BufferedWriter; import...) { //read from start original file String arry[] = sCurrentLine.split
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  import java.io.BufferedReader; import java.io.BufferedWriter; import...) { //read from start original file String arry[] = sCurrentLine.split
again with xml - XML
again with xml  hi all i am a beginner in xml so pls give me the details regarding the methods used in it. wat will return the methods... Antony Read this page and related link. http://www.informit.com/library
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 help me again ,my problem right know is how to read data from txt file then data... this. Thank's very much   Hi friend, code to read a file import
again java - Java Beginners
again java  i will ask iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse that image...-data") >= 0)) { DataInputStream in = new DataInputStream
again java - Java Beginners
again java  Hi, i will ask iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse.../form-data") >= 0)) { DataInputStream in = new DataInputStream
java again - Date Calendar
java again  I can't combine your source code yesterday, can you help me again. My problem is how we get result jtextfield2 from if jtexfield1 we enter(jTextfield keypressed) then the result out to jTextfield2, This my jFrame
How to read every cell of an excel sheet using Apache POI and insert those data into a DB?
How to read every cell of an excel sheet using Apache POI and insert those data into a DB?   i have an excel sheet, whose data in each cell has to be read and those data has to be inserted in the DB. This has to happen for all
JPA read data from database example
JPA read data from database example   ... data from database using JPA. Create a "JPARead.java" file and follows the following steps to reading data from database. Again, you create
how to read 100 text files from a folder or directory and write the data into a single file.using java programming?
how to read 100 text files from a folder or directory and write the data... column value that keeps on changing for every file.i have read the data from all... files which has data in the form of intgers consisting of 3 columns and app..3000
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which... a browse button which can upload a excelfile and after uploading the data should
matching database again - Java Beginners
matching database again  Dear experts, So happy I get through this ask a question page again. Thank God. I want to say "A BIG THANK YOU" for helping me about the matching codes. It is working now after fine tuning
Hi..Again Doubt .. - Java Beginners
Hi..Again Doubt ..  Thank u for ur Very Good Response...Really great.. i have completed that.. If i click the RadioButton,,ActionListenr should get call. It should add to the MS Acess table..Plz check this out.... hope u ill
doesnt run again - Java Beginners
the soltion   Hi I am sending u again the code, this code run in my
Hi .Again me.. - Java Beginners
Hi .Again me..  Hi Friend...... can u pls send me some code on JPanel.. JPanel shoul have 1pic 1RadioButton .. Like a Voter List... REsponse me..  Hi friend, import java.io.*; import java.awt.
call frame again - Java Beginners
read from jbutton1 in FrameA to FrameB,then i write "JAVA" in Jtextfield1(FrameB
JPA read data from database example
JPA read data from database example       In this section, you will learn how to retrieve data... the following steps to reading data from database. Create "JPARead" class
Java read multiple files
Java read multiple files In this section you will learn how to read the data of multiple files. Here we have created four files that includes information of students of a class. Each file contains a student's name, email, school and hobby
How to read a byte.
Description In the given Example,  you will see how to use read method of CheckedInputStrem class. It reads single byte of data from the input stream and updates the checksum from that byte data which it read. When data transmit
I have one small doubt , does this code read Microsoft Office suit file format data such as .doc , .docx etc ?
I have one small doubt , does this code read Microsoft Office suit file format data such as .doc , .docx etc ?  import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class ReadFileExample
How To Read File In Java
How To Read File In Java In this section we will discuss about about how data of a file can be read in Java. A file can contain data as bytes, characters, binary data etc. To read a file in Java we can use following of the classes
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.  I am reading the file using BufferedReader, then writing the output like this: String
Drop Down Reloads again in IE..How to prevent this?
Drop Down Reloads again in IE..How to prevent this?  Hi i was using two drop down box..One for Displaying date followed by another for Dispalying Month..If i Select/Change Month from the 2nd drop down then the 1st drop down
xl read
xl read  hi, i have read excel sheet data using poi api and printed on console, now i have to store the same data which is printed on the console...: Insert excel file data into database Read Excel File
help again plz sorry - Java Beginners
help again plz sorry  Thanks for giving me thread code but i have a question this code is comletelly right and i want to make it runs much faster for that i made 5 threads but 2 things i dont understand 1- with one
Advertisements
 

 

 

DMCA.com