Solved

Insert to database from text file

Posted on 2004-04-06
10
168 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
  • 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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:mayankeagle
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:mayankeagle
ID: 10958438
Since points are too less to split, accept CEHJ's comment as answer.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

746 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now