Read data again

Read data again

View Answers

December 30, 2008 at 12:05 AM

Hi friend,

Code to help in solving the problem :

import java.io.*;
import java.sql.*;
class FileReadLine
{
public static void main(String args[])
{
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";;
String db = "jdbctutorial";
String driver = "com.mysql.jdbc.Driver";

try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("readData.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
Class.forName(driver);
con = DriverManager.getConnection(url+db,"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();
query = "INSERT employee VALUES('"+strar[0]+"','"+strar[1]+"','"+strar[2]+"'";
int val = st.executeUpdate(")");
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









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
Data read. - XML
Data read.  How to store or read data in XML from Struts.Plz give me example. Thanx
Read RFID data
Read RFID data  how to read RFID data using java
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
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
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
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
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. 
There and Back Again
There and Back Again       The weblog of Joshua Eichorn, AJAX, PHP and Open Source Read full DescriptionADS_TO_REPLACE_1
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 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
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
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 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
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
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 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
With PySpark read list into Data Frame
? The Data  Frame is Spark Data Structure which is again a distributed...Reading a list into Data Frame in PySpark program The Spark SQL comes with extensive libraries for working with the different data sets in Apache Spark
ModuleNotFoundError: No module named 'again'
ModuleNotFoundError: No module named 'again'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'again' How to remove the ModuleNotFoundError: No module named 'again'
ModuleNotFoundError: No module named 'again'
ModuleNotFoundError: No module named 'again'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'again' How to remove the ModuleNotFoundError: No module named 'again'
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
JDBC Video tutorial - How to read Data from MySQL Database?
JDBC Beginners tutorial for reading the data from MySQL database - RoseIndia.Net In this tutorial you will learn the code to read the data from the MySQL... { public static void main(String[] args) { System.out.println("Read Data
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
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
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 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
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
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
ModuleNotFoundError: No module named 'lambada-again'
ModuleNotFoundError: No module named 'lambada-again'  Hi, My... 'lambada-again' How to remove the ModuleNotFoundError: No module named 'lambada-again' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'lambada-again'
ModuleNotFoundError: No module named 'lambada-again'  Hi, My... 'lambada-again' How to remove the ModuleNotFoundError: No module named 'lambada-again' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'lambada-again'
ModuleNotFoundError: No module named 'lambada-again'  Hi, My... 'lambada-again' How to remove the ModuleNotFoundError: No module named 'lambada-again' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'n-again'
ModuleNotFoundError: No module named 'n-again'  Hi, My Python...-again' How to remove the ModuleNotFoundError: No module named 'n-again... to install padas library. You can install n-again python with following command
ModuleNotFoundError: No module named 'nested_again'
ModuleNotFoundError: No module named 'nested_again'  Hi, My Python... 'nested_again' How to remove the ModuleNotFoundError: No module named 'nested_again' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'showit-again'
ModuleNotFoundError: No module named 'showit-again'  Hi, My Python... 'showit-again' How to remove the ModuleNotFoundError: No module named 'showit-again' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'testpay-again'
ModuleNotFoundError: No module named 'testpay-again'  Hi, My... 'testpay-again' How to remove the ModuleNotFoundError: No module named 'testpay-again' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'testpay-again'
ModuleNotFoundError: No module named 'testpay-again'  Hi, My... 'testpay-again' How to remove the ModuleNotFoundError: No module named 'testpay-again' error? Thanks   Hi, In your python
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
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
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

Ads