Insert to database from text file

Posted on 2004-04-06
Last Modified: 2010-03-31
How can i insert into an access database using sql which gets the values from a text file?
Question by:johnbert_99
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
LVL 86

Accepted Solution

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());
LVL 14

Expert Comment

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

Author Comment

ID: 10768450
can u maybe explain more?....
Industry Leaders: 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

ID: 10768460
Please give the format of the text file
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:
LVL 30

Expert Comment

by:Mayank S
ID: 10772057
Reading from a text-file:

(you can also have a look at the "Related Examples" and at:

Inserting a row into a database-table:
LVL 30

Expert Comment

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

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

632 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