Subject | Re: importing datas |
---|---|
Author | Roman Rokytskyy |
Post date | 2002-10-02T11:52:04Z |
Hi,
pick up any tool you find and provide JDBC driver for FireBird
(InterClient or JBird). It should work. I never met something like
isql in Java. However, it should not be hard to implement this
program yourself:
LineNumberReader reader = new LineNumberReader(new FileReader
("c:/my_file.txt"));
PreparedStatement stmt = connection.prepareStatement(
"INSERT INTO my_table(col1, col2, ...) VALUES(?, ?, ...)");
String line;
while((line = reader.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line, ",");
int counter = 1;
while(st.hasMoreTokens()) {
String value = st.nextToken();
// strip quotes here
if (value.length() > 0)
value = value.substring(1, value.length() - 1);
stmt.setString(counter, value);
counter++;
}
stmt.executeUpdate();
}
stmt.close();
BDE and ODBC and was part of Delphi. Ask in IB-Support group
(http://groups.yahoo.com/group/IB-Support).
Best regards,
Roman Rokytskyy
> Anyone can tell me, how can I import datas in a table from textIf you are intersted in importing that data using Java, you should
> files with this format :
>
> (Sample)
>
> 'stds','Standard','Estándar','Standard',,0,,,,
> ...
> 'trip','Triple','Triple','Triple',,0,,,,
>
> I know with other isql clients it possible to use :
> "INPUT" and
> "LOAD"
>
> But with the isql of Firebird
> "LOAD" doesn't exist and
> "INPUT" can import .sql files but not import text files with only
> datas
pick up any tool you find and provide JDBC driver for FireBird
(InterClient or JBird). It should work. I never met something like
isql in Java. However, it should not be hard to implement this
program yourself:
LineNumberReader reader = new LineNumberReader(new FileReader
("c:/my_file.txt"));
PreparedStatement stmt = connection.prepareStatement(
"INSERT INTO my_table(col1, col2, ...) VALUES(?, ?, ...)");
String line;
while((line = reader.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line, ",");
int counter = 1;
while(st.hasMoreTokens()) {
String value = st.nextToken();
// strip quotes here
if (value.length() > 0)
value = value.substring(1, value.length() - 1);
stmt.setString(counter, value);
counter++;
}
stmt.executeUpdate();
}
stmt.close();
> Have you acknowledgement of a program who copy structure and datasBorland had some kind of such program called DataPump, it worked with
> of a "sysbase" file to a "firebird" file ?
BDE and ODBC and was part of Delphi. Ask in IB-Support group
(http://groups.yahoo.com/group/IB-Support).
Best regards,
Roman Rokytskyy