Results 1 to 5 of 5
- 05-27-2011, 12:38 PM #1
Newbies
- Join Date
- May 2011
- Posts
- 2
- Rep Power
- 0
How to read from text file and insert into database using java
Hi all,
Please somebody help me, i am newbie in Java. i have questions about java programing, how to read from text file and insert into database.
I have text file let's say like
Header
A123445
U156664
A734355
U835353
A535355
Footer
I wanna be able to read the text file and skip the header and footer, String A means i have to insert the data and String U means i have to update the previous record in database. And i have to parse every string after string A or U. There are 6 strings after A or U. so i want to put into 6 fields in database.
Please somebody help me. Can we do those things in Java?
Thanks
Warmly regards,
Ryan
- 05-27-2011, 02:05 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
Java Code:while read a line from file if line isn't header or footer if first letter is A then process Add else process Update
- 05-27-2011, 03:19 PM #3
Newbies
- Join Date
- May 2011
- Posts
- 2
- Rep Power
- 0
- 05-27-2011, 04:11 PM #4
So what have you done so far? We don't know where to begin to help you, since you have not provided us with any code. Can we assume you know how to make a java class, main method, regular class & instance methods, understand return types, etc etc?hi sir. thanks so sir. i know the algorithm but i cannot translate that into java code or class.
If so, then the first thing you will need is a database connector. The one for MySQL is MySQL :: Download Connector/J
and the one for oracle is JDBC/UCP Download Page
Once you have a JDBC driver, add it to your project, and then you can establish connections using methods described in this tutorial:Establishing a Connection (The Java™ Tutorials > JDBC(TM) Database Access > JDBC Basics)
- 05-27-2011, 04:13 PM #5
Similar Threads
-
How can we read text file in java 1.4
By javasaravanan in forum Advanced JavaReplies: 4Last Post: 11-30-2009, 03:28 PM -
how to insert sql file into database using swing
By ravi.virgoo@gmail.com in forum AWT / SwingReplies: 1Last Post: 11-22-2009, 03:01 AM -
Insert text records from text file into a DB
By nicedad in forum JDBCReplies: 8Last Post: 11-06-2009, 06:52 AM -
how to insert date field read from Excel using JExcel to database
By saran123 in forum JDBCReplies: 1Last Post: 10-10-2008, 08:47 AM -
How to read a text file from a Java Archive File
By Java Tip in forum Java TipReplies: 0Last Post: 02-08-2008, 09:13 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks