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?....
Technology Partners: 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
null output 3 59
maven module vs maven project 3 120
difference between sorce folder and folder in eclipise 3 65
using executorService 3 25
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

710 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