Home Answers Viewqa Java-Beginners Read data again

 
 


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

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 Pages:
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
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
There and Back Again
There and Back Again       The weblog of Joshua Eichorn, AJAX, PHP and Open Source Read full Description
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
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
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
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
call frame again - Java Beginners
read from jbutton1 in FrameA to FrameB,then i write "JAVA" in Jtextfield1(FrameB
read data from Excel sheet
read data from Excel sheet  Hi, How to read data from an excel sheet using JSP. Thank you
Read PDF file
of StringBuffer,it will again converted into string and display the data on the command...Read PDF file Java provides itext api to perform read and write operations with pdf file. Here we are going to read a pdf file. For this, we have used
i written the program in the files but in adding whole file is writing once again - Java Beginners
for Show Data...; Display record display data Display Record.... ---------------------------------------- Read for more information. http
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
Plz chk it and reply again - Java Beginners
Plz chk it and reply again  Hi Deepak, Thanks for fast reply,your application is good,u write this code for user click the view database then all data would be display in next page whose data are stored in the database
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 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
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
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
Read Write
Read Write  Hi; How can I read certain line of say 10 text files and write to one text file   Java Read Multiple Files and store the data... and stored the data into another text file. import java.io.*; import
read xml
read xml   hi all, i want to ask about how to read an xml in java ME.. here is the xml file <data> <value> <struct>... of the first value node after the data node, i just can get only 1 struct but not 2, how
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. 
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE...+"')"); out.println("Data is successfully inserted
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE...+"')"); out.println("Data is successfully inserted
read xml elements
read xml elements  i want read xml data using sax parser in java. but is there any classes or methods to read xml elements
read xml elements
read xml elements  i want read xml data using sax parser in java. but is there any classes or methods to read xml elements
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
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 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 Issue itext
Read Issue itext  Hello, I m using itext to read data from pdf file... In variable whole page data there... so i want to read data line by line so is der any way to read line by line data using itext so dat i can process
Read Issue itext
Read Issue itext  Hello, I m using itext to read data from pdf file... In variable whole page data there... so i want to read data line by line so is der any way to read line by line data using itext so dat i can process
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 the File
the data is read in form of a byte through the read( ) method. The read... Read the File       As we have read about  the BufferedInputStream 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
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
read xml using java
;   Please visit the following link: Read XML data...read xml using java  <p>to read multiple attributes... of the actual data depends on the concrete actuation controller the actual value
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