Solved

Insert to database from text file

Posted on 2004-04-06
10
199 Views
Last Modified: 2010-03-31
How can i insert into an access database using sql which gets the values from a text file?
0
Comment
Question by:johnbert_99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
10 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 30 total points
ID: 10767392
Read as tokens, insert as fields

int fieldNum = 0;
StringTokenizer st = new StringTokenizer(fileLine);
while ( st.hasMOreTokens()) {
  ps.setString(++fieldNum, st.nextToken());
}
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10767508
ps in CEHJ's example is a PreparedStatement.
0
 

Author Comment

by:johnbert_99
ID: 10768450
can u maybe explain more?....
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 10768460
Please give the format of the text file
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10768585
A PreparedStatement is an easy  way to add content to a query statement or update/insert statement.

You can find the Javadocs here: http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10772057
Reading from a text-file: http://www.javaalmanac.com/egs/java.io/ReadLinesFromFile.html

(you can also have a look at the "Related Examples" and at: http://www.javaalmanac.com/cgi-bin/search/find.pl?words=file)

Inserting a row into a database-table: http://www.javaalmanac.com/egs/java.sql/InsertPs.html
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10958438
Since points are too less to split, accept CEHJ's comment as answer.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jboss 7.1 start up error 1 60
servlet and mdb, jms error 1 56
restrict decimal places for double datatype 10 29
Website checklist for browser compatibility? 2 37
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question