Insert to database from text file

How can i insert into an access database using sql which gets the values from a text file?
johnbert_99Asked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Read as tokens, insert as fields

int fieldNum = 0;
StringTokenizer st = new StringTokenizer(fileLine);
while ( st.hasMOreTokens()) {
  ps.setString(++fieldNum, st.nextToken());
}
0
 
Tommy BraasCommented:
ps in CEHJ's example is a PreparedStatement.
0
 
johnbert_99Author Commented:
can u maybe explain more?....
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
CEHJCommented:
Please give the format of the text file
0
 
Tommy BraasCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
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
 
Mayank SAssociate Director - Product EngineeringCommented:
Since points are too less to split, accept CEHJ's comment as answer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.