csvtosql-cvs Mailing List for csvtosql (Page 5)
Brought to you by:
davideconsonni
You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(3) |
Apr
(106) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(73) |
Nov
(20) |
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(7) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: consonni d. <dav...@us...> - 2006-10-11 18:23:24
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/oracle In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13942/src/net/sf/csv2sql/grammars/oracle Modified Files: GrammarFactory.java OracleFieldDate.java OracleFieldNumber.java OracleFieldVarchar.java Log Message: no message Index: OracleFieldDate.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/oracle/OracleFieldDate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OracleFieldDate.java 25 Apr 2005 10:53:18 -0000 1.1 --- OracleFieldDate.java 11 Oct 2006 18:23:18 -0000 1.2 *************** *** 1,18 **** /* ! Copyright (C) 2004 Davide Consonni <dco...@en...> ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.oracle; --- 1,18 ---- /* ! Copyright (C) 2006 Davide Consonni <dav...@us...> ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! You should have received a copy of the GNU Lesser General Public ! License along with this library; if not, write to the Free Software ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package net.sf.csv2sql.grammars.oracle; *************** *** 29,33 **** /** * @see AbstractField ! * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class OracleFieldDate extends AbstractField { --- 29,33 ---- /** * @see AbstractField ! * @author <a href="mailto:dav...@us...">Davide Consonni</a> */ public final class OracleFieldDate extends AbstractField { Index: OracleFieldVarchar.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/oracle/OracleFieldVarchar.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OracleFieldVarchar.java 25 Apr 2005 10:53:18 -0000 1.1 --- OracleFieldVarchar.java 11 Oct 2006 18:23:18 -0000 1.2 *************** *** 1,18 **** /* ! Copyright (C) 2004 Davide Consonni <dco...@en...> ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.oracle; --- 1,18 ---- /* ! Copyright (C) 2006 Davide Consonni <dav...@us...> ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! You should have received a copy of the GNU Lesser General Public ! License along with this library; if not, write to the Free Software ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package net.sf.csv2sql.grammars.oracle; *************** *** 26,30 **** /** * @see AbstractField ! * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class OracleFieldVarchar extends AbstractField { --- 26,30 ---- /** * @see AbstractField ! * @author <a href="mailto:dav...@us...">Davide Consonni</a> */ public final class OracleFieldVarchar extends AbstractField { Index: OracleFieldNumber.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/oracle/OracleFieldNumber.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OracleFieldNumber.java 25 Apr 2005 10:53:18 -0000 1.1 --- OracleFieldNumber.java 11 Oct 2006 18:23:18 -0000 1.2 *************** *** 1,18 **** /* ! Copyright (C) 2004 Davide Consonni <dco...@en...> ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.oracle; --- 1,18 ---- /* ! Copyright (C) 2006 Davide Consonni <dav...@us...> ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! You should have received a copy of the GNU Lesser General Public ! License along with this library; if not, write to the Free Software ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package net.sf.csv2sql.grammars.oracle; *************** *** 26,30 **** /** * @see AbstractField ! * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class OracleFieldNumber extends AbstractField { --- 26,30 ---- /** * @see AbstractField ! * @author <a href="mailto:dav...@us...">Davide Consonni</a> */ public final class OracleFieldNumber extends AbstractField { Index: GrammarFactory.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/oracle/GrammarFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GrammarFactory.java 25 Apr 2005 10:53:18 -0000 1.1 --- GrammarFactory.java 11 Oct 2006 18:23:18 -0000 1.2 *************** *** 1,18 **** /* ! Copyright (C) 2004 Davide Consonni <dco...@en...> ! This program is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.oracle; --- 1,18 ---- /* ! Copyright (C) 2006 Davide Consonni <dav...@us...> ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Lesser General Public ! License as published by the Free Software Foundation; either ! version 2.1 of the License, or (at your option) any later version. ! This library is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! Lesser General Public License for more details. ! You should have received a copy of the GNU Lesser General Public ! License along with this library; if not, write to the Free Software ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package net.sf.csv2sql.grammars.oracle; *************** *** 28,32 **** /** * @see net.sf.csv2sql.grammars.AbstractGrammarFactory AbstractGrammarFactory ! * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class GrammarFactory extends AbstractGrammarFactory { --- 28,32 ---- /** * @see net.sf.csv2sql.grammars.AbstractGrammarFactory AbstractGrammarFactory ! * @author <a href="mailto:dav...@us...">Davide Consonni</a> */ public final class GrammarFactory extends AbstractGrammarFactory { |
|
From: Vano <jj...@us...> - 2006-10-11 14:21:55
|
Update of /cvsroot/csvtosql/csvtosql/src/net/sf/csv2sql/grammars/mysql In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21796/src/net/sf/csv2sql/grammars/mysql Modified Files: MysqlFieldChar.java Log Message: Index: MysqlFieldChar.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql/src/net/sf/csv2sql/grammars/mysql/MysqlFieldChar.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** MysqlFieldChar.java 12 Mar 2005 12:34:32 -0000 1.19 --- MysqlFieldChar.java 11 Oct 2006 14:21:44 -0000 1.20 *************** *** 47,50 **** --- 47,53 ---- //get value String strValue = ((String)value); + if ("null".equalsIgnoreCase(strValue)) { + return getDefaulNullValue(); + } //render |
|
From: consonni d. <dav...@us...> - 2006-04-06 15:29:36
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22436/doc Modified Files: README.txt Log Message: no message Index: README.txt =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/doc/README.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README.txt 25 Apr 2005 10:51:09 -0000 1.1 --- README.txt 6 Apr 2006 15:29:30 -0000 1.2 *************** *** 40,44 **** Roberto Chiaretti <rob...@az...> Dana Cordes <blo...@us...> ! Licensing --- 40,44 ---- Roberto Chiaretti <rob...@az...> Dana Cordes <blo...@us...> ! Daniel Marek <dan...@qb...> Licensing |
|
From: consonni d. <dav...@us...> - 2006-04-06 15:29:17
|
Update of /cvsroot/csvtosql/csvtosql/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22022/doc Modified Files: README.txt Log Message: no message Index: README.txt =================================================================== RCS file: /cvsroot/csvtosql/csvtosql/doc/README.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** README.txt 12 Mar 2005 11:28:37 -0000 1.9 --- README.txt 6 Apr 2006 15:29:07 -0000 1.10 *************** *** 40,44 **** Roberto Chiaretti <rob...@az...> Dana Cordes <blo...@us...> ! Licensing --- 40,44 ---- Roberto Chiaretti <rob...@az...> Dana Cordes <blo...@us...> ! Daniel Marek <dan...@qb...> Licensing |
|
From: consonni d. <dav...@us...> - 2006-04-06 15:25:33
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/writers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25222/src/net/sf/csv2sql/writers Modified Files: JdbcBatchWriter.java JdbcWriter.java Log Message: Hi Davide, we found some bugs in csvtosql package in JdbcWriter.java and JdbcBatchWriter.java. We tried to use csvtosql to import some data directly to Oracle9i database, but Exception ORA-00911: invalid character occurs ... Problem is, that JdbcWriter/JdbcBatchWriter gets SQL statements from storage and puts them directly into stmt.executeUpdate method. Every SQL statement (String) contains as last character semicolon (as delimiter of SQL statements), however stmt.executeUpdate() method expect this SQL statement without any delimiter. Quick and dirty patch is to remove last character of every statement, for example ... Here is diff between csvtosql_jdk50\src\net\sf\csv2sql\writers\JdbcWriter.java and patched file 95c95,96 < stmt.executeUpdate(getStorage().get(i)); --- > String line = (String) getStorage().get(i); > stmt.executeUpdate(line.substring(0,line.length()-1)); Well, it should be better to test, if last characted is semicolon, if yes, remove it, if no, no action is necessary ... The same problem is in csvtosql package for jdk 1.4. Hope this help, could you please fix this in some next release? Thanks, best regards, Daniel Marek Index: JdbcWriter.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/writers/JdbcWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JdbcWriter.java 25 Apr 2005 10:53:23 -0000 1.1 --- JdbcWriter.java 6 Apr 2006 14:46:16 -0000 1.2 *************** *** 1,15 **** /* Copyright (C) 2004 Davide Consonni <dco...@en...> ! This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software --- 1,15 ---- /* Copyright (C) 2004 Davide Consonni <dco...@en...> ! This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software *************** *** 24,27 **** --- 24,28 ---- import java.sql.Statement; import java.util.HashMap; + import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.utils.DBUtils; *************** *** 35,39 **** */ public class JdbcWriter extends AbstractWriter { ! //mandatory parameters String driver; --- 36,40 ---- */ public class JdbcWriter extends AbstractWriter { ! //mandatory parameters String driver; *************** *** 41,49 **** String username; String password; ! //optional parameters File jdbcJar = null; boolean commit; ! private void init() throws InvalidParameterValueException { --- 42,50 ---- String username; String password; ! //optional parameters File jdbcJar = null; boolean commit; ! private void init() throws InvalidParameterValueException { *************** *** 52,60 **** username = getWriterProperties().getProperty("username"); password = getWriterProperties().getProperty("password"); ! ! //optional set autocommit commit = "true".equalsIgnoreCase(getWriterProperties().getProperty("commit")); ! //optional String strJdbcJar = getWriterProperties().getProperty("jdbcjar"); --- 53,61 ---- username = getWriterProperties().getProperty("username"); password = getWriterProperties().getProperty("password"); ! ! //optional set autocommit commit = "true".equalsIgnoreCase(getWriterProperties().getProperty("commit")); ! //optional String strJdbcJar = getWriterProperties().getProperty("jdbcjar"); *************** *** 63,71 **** if (!jdbcJar.exists()) { throw new InvalidParameterValueException("jdbcjar", ! getWriterProperties().getProperty("jdbcjar")); } } } ! /** * @see AbstractWriter#write --- 64,72 ---- if (!jdbcJar.exists()) { throw new InvalidParameterValueException("jdbcjar", ! getWriterProperties().getProperty("jdbcjar")); } } } ! /** * @see AbstractWriter#write *************** *** 73,84 **** public void write() throws WriterException { ! Connection connection = null; Statement stmt = null; ! try { //get configuration options init(); ! if (jdbcJar!=null) { connection = DBUtils.openConnection(jdbcJar, driver, url, username, password); --- 74,85 ---- public void write() throws WriterException { ! Connection connection = null; Statement stmt = null; ! try { //get configuration options init(); ! if (jdbcJar!=null) { connection = DBUtils.openConnection(jdbcJar, driver, url, username, password); *************** *** 86,104 **** connection = DBUtils.openConnection(driver, url, username, password); } ! stmt = connection.createStatement(); ! //start transaction if (commit) {connection.setAutoCommit(false);} ! for (int i=0; i<getStorage().size(); i++) { ! stmt.executeUpdate(getStorage().get(i)); } ! //stop transaction if (commit) {connection.commit();} ! } catch (StorageException e) { ! throw new WriterException("cannot read data from temporary storage", e); } catch (SQLException e) { throw new WriterException("cannot write statement to database", e); --- 87,107 ---- connection = DBUtils.openConnection(driver, url, username, password); } ! stmt = connection.createStatement(); ! //start transaction if (commit) {connection.setAutoCommit(false);} ! for (int i=0; i<getStorage().size(); i++) { ! //stmt.executeUpdate(getStorage().get(i)); ! String line = (String) getStorage().get(i); ! stmt.executeUpdate(line.substring(0,line.length()-1)); } ! //stop transaction if (commit) {connection.commit();} ! } catch (StorageException e) { ! throw new WriterException("cannot read data from temporary storage", e); } catch (SQLException e) { throw new WriterException("cannot write statement to database", e); *************** *** 111,115 **** } } ! protected HashMap<String, String> requiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); --- 114,118 ---- } } ! protected HashMap<String, String> requiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); *************** *** 119,123 **** return hm; } ! protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); --- 122,126 ---- return hm; } ! protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); *************** *** 127,130 **** return hm; } ! } --- 130,133 ---- return hm; } ! } Index: JdbcBatchWriter.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/writers/JdbcBatchWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JdbcBatchWriter.java 25 Apr 2005 10:53:23 -0000 1.1 --- JdbcBatchWriter.java 6 Apr 2006 14:46:16 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- import java.sql.Statement; import java.util.HashMap; + import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.utils.DBUtils; |
|
From: consonni d. <dav...@us...> - 2006-04-06 14:58:04
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1274/src Modified Files: VERSION Log Message: no message Index: VERSION =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/VERSION,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VERSION 25 Apr 2005 10:52:56 -0000 1.1 --- VERSION 6 Apr 2006 14:57:54 -0000 1.2 *************** *** 1 **** ! 3.0.0 \ No newline at end of file --- 1 ---- ! 3.0.1 \ No newline at end of file |
|
From: consonni d. <dav...@us...> - 2006-04-06 14:57:57
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1274/doc Modified Files: WHATSNEW.txt Log Message: no message Index: WHATSNEW.txt =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/doc/WHATSNEW.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WHATSNEW.txt 25 Apr 2005 21:30:37 -0000 1.2 --- WHATSNEW.txt 6 Apr 2006 14:57:53 -0000 1.3 *************** *** 1,2 **** --- 1,26 ---- + Changes from csvtosql 3.0.0 to csvtosql 3.0.1 + ============================================= + + * Daniel Marek <dan...@qb...> + We tried to use csvtosql to import some data directly to Oracle9i + database, but Exception ORA-00911: invalid character occurs ... + Problem is, that JdbcWriter/JdbcBatchWriter gets SQL statements from + storage and puts them directly into stmt.executeUpdate method. Every SQL + statement (String) contains as last character semicolon (as delimiter of + SQL statements), however stmt.executeUpdate() method expect this SQL + statement without any delimiter. Quick and dirty patch is to remove last + character of every statement, for example ... + Here is diff between + csvtosql_jdk50\src\net\sf\csv2sql\writers\JdbcWriter.java + and patched file + 95c95,96 + < stmt.executeUpdate(getStorage().get(i)); + --- + > String line = (String) getStorage().get(i); + > stmt.executeUpdate(line.substring(0,line.length()-1)); + Well, it should be better to test, if last characted is semicolon, if + yes, remove it, if no, no action is necessary ... + + Changes from csvtosql 2.2.0 to csvtosql 3.0.0 ============================================= *************** *** 14,18 **** ============================================= ! * Dana Cordes <blo...@us... To the JdbcBatchWriter, I've added some additional debug reporting when exceptions are thrown. I've also added a clearBatch() statement after --- 38,42 ---- ============================================= ! * Dana Cordes <blo...@us...> To the JdbcBatchWriter, I've added some additional debug reporting when exceptions are thrown. I've also added a clearBatch() statement after |
|
From: consonni d. <dav...@us...> - 2006-04-06 14:57:37
|
Update of /cvsroot/csvtosql/csvtosql/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1032/src Modified Files: VERSION Log Message: no message Index: VERSION =================================================================== RCS file: /cvsroot/csvtosql/csvtosql/src/VERSION,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** VERSION 12 Mar 2005 11:27:34 -0000 1.10 --- VERSION 6 Apr 2006 14:57:29 -0000 1.11 *************** *** 1 **** ! 2.2.0 --- 1 ---- ! 2.2.1 |
|
From: consonni d. <dav...@us...> - 2006-04-06 14:50:55
|
Update of /cvsroot/csvtosql/csvtosql/src/net/sf/csv2sql/writers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28525/src/net/sf/csv2sql/writers Modified Files: JdbcWriter.java Log Message: Hi Davide, we found some bugs in csvtosql package in JdbcWriter.java and JdbcBatchWriter.java. We tried to use csvtosql to import some data directly to Oracle9i database, but Exception ORA-00911: invalid character occurs ... Problem is, that JdbcWriter/JdbcBatchWriter gets SQL statements from storage and puts them directly into stmt.executeUpdate method. Every SQL statement (String) contains as last character semicolon (as delimiter of SQL statements), however stmt.executeUpdate() method expect this SQL statement without any delimiter. Quick and dirty patch is to remove last character of every statement, for example ... Here is diff between csvtosql_jdk50\src\net\sf\csv2sql\writers\JdbcWriter.java and patched file 95c95,96 < stmt.executeUpdate(getStorage().get(i)); --- > String line = (String) getStorage().get(i); > stmt.executeUpdate(line.substring(0,line.length()-1)); Well, it should be better to test, if last characted is semicolon, if yes, remove it, if no, no action is necessary ... The same problem is in csvtosql package for jdk 1.4. Hope this help, could you please fix this in some next release? Thanks, best regards, Daniel Marek Index: JdbcWriter.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql/src/net/sf/csv2sql/writers/JdbcWriter.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** JdbcWriter.java 6 Apr 2006 14:49:55 -0000 1.30 --- JdbcWriter.java 6 Apr 2006 14:50:51 -0000 1.31 *************** *** 87,91 **** connection = DBUtils.openConnection(driver, url, username, password); } ! stmt = connection.createStatement(); --- 87,91 ---- connection = DBUtils.openConnection(driver, url, username, password); } ! stmt = connection.createStatement(); *************** *** 94,97 **** --- 94,98 ---- for (int i=0; i<getStorage().size(); i++) { + // //stmt.executeUpdate(getStorage().get(i)); String line = (String) getStorage().get(i); |
|
From: consonni d. <dav...@us...> - 2006-04-06 14:50:05
|
Update of /cvsroot/csvtosql/csvtosql/src/net/sf/csv2sql/writers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27781/src/net/sf/csv2sql/writers Modified Files: JdbcWriter.java Log Message: no message Index: JdbcWriter.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql/src/net/sf/csv2sql/writers/JdbcWriter.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** JdbcWriter.java 11 Nov 2004 09:15:15 -0000 1.29 --- JdbcWriter.java 6 Apr 2006 14:49:55 -0000 1.30 *************** *** 1,15 **** /* Copyright (C) 2004 Davide Consonni <dco...@en...> ! This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software --- 1,15 ---- /* Copyright (C) 2004 Davide Consonni <dco...@en...> ! This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software *************** *** 24,27 **** --- 24,28 ---- import java.sql.Statement; import java.util.HashMap; + import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.utils.DBUtils; *************** *** 35,39 **** */ public class JdbcWriter extends AbstractWriter { ! //mandatory parameters String driver; --- 36,40 ---- */ public class JdbcWriter extends AbstractWriter { ! //mandatory parameters String driver; *************** *** 41,49 **** String username; String password; ! //optional parameters File jdbcJar = null; boolean commit; ! private void init() throws InvalidParameterValueException { --- 42,50 ---- String username; String password; ! //optional parameters File jdbcJar = null; boolean commit; ! private void init() throws InvalidParameterValueException { *************** *** 52,60 **** username = getWriterProperties().getProperty("username"); password = getWriterProperties().getProperty("password"); ! ! //optional set autocommit commit = "true".equalsIgnoreCase(getWriterProperties().getProperty("commit")); ! //optional String strJdbcJar = getWriterProperties().getProperty("jdbcjar"); --- 53,61 ---- username = getWriterProperties().getProperty("username"); password = getWriterProperties().getProperty("password"); ! ! //optional set autocommit commit = "true".equalsIgnoreCase(getWriterProperties().getProperty("commit")); ! //optional String strJdbcJar = getWriterProperties().getProperty("jdbcjar"); *************** *** 63,71 **** if (!jdbcJar.exists()) { throw new InvalidParameterValueException("jdbcjar", ! getWriterProperties().getProperty("jdbcjar")); } } } ! /** * @see AbstractWriter#write --- 64,72 ---- if (!jdbcJar.exists()) { throw new InvalidParameterValueException("jdbcjar", ! getWriterProperties().getProperty("jdbcjar")); } } } ! /** * @see AbstractWriter#write *************** *** 73,84 **** public void write() throws WriterException { ! Connection connection = null; Statement stmt = null; ! try { //get configuration options init(); ! if (jdbcJar!=null) { connection = DBUtils.openConnection(jdbcJar, driver, url, username, password); --- 74,85 ---- public void write() throws WriterException { ! Connection connection = null; Statement stmt = null; ! try { //get configuration options init(); ! if (jdbcJar!=null) { connection = DBUtils.openConnection(jdbcJar, driver, url, username, password); *************** *** 86,104 **** connection = DBUtils.openConnection(driver, url, username, password); } ! stmt = connection.createStatement(); ! //start transaction if (commit) {connection.setAutoCommit(false);} ! for (int i=0; i<getStorage().size(); i++) { ! stmt.executeUpdate(getStorage().get(i)); } ! //stop transaction if (commit) {connection.commit();} ! } catch (StorageException e) { ! throw new WriterException("cannot read data from temporary storage", e); } catch (SQLException e) { throw new WriterException("cannot write statement to database", e); --- 87,107 ---- connection = DBUtils.openConnection(driver, url, username, password); } ! stmt = connection.createStatement(); ! //start transaction if (commit) {connection.setAutoCommit(false);} ! for (int i=0; i<getStorage().size(); i++) { ! //stmt.executeUpdate(getStorage().get(i)); ! String line = (String) getStorage().get(i); ! stmt.executeUpdate(line.substring(0,line.length()-1)); } ! //stop transaction if (commit) {connection.commit();} ! } catch (StorageException e) { ! throw new WriterException("cannot read data from temporary storage", e); } catch (SQLException e) { throw new WriterException("cannot write statement to database", e); *************** *** 111,115 **** } } ! protected HashMap requiredParameterList() { HashMap hm = new HashMap(); --- 114,118 ---- } } ! protected HashMap requiredParameterList() { HashMap hm = new HashMap(); *************** *** 119,123 **** return hm; } ! protected HashMap optionalParameterList() { HashMap hm = new HashMap(); --- 122,126 ---- return hm; } ! protected HashMap optionalParameterList() { HashMap hm = new HashMap(); *************** *** 127,130 **** return hm; } ! } --- 130,133 ---- return hm; } ! } |
|
From: consonni d. <dav...@us...> - 2005-05-20 19:55:07
|
Update of /cvsroot/csvtosql/csvtosql/examples/test.excel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15800 Added Files: users.xls Log Message: no message --- NEW FILE: users.xls --- (This appears to be a binary file; contents omitted.) |
|
From: consonni d. <dav...@us...> - 2005-05-20 19:54:35
|
Update of /cvsroot/csvtosql/csvtosql/examples/test.excel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15678 Removed Files: users.xls Log Message: no message --- users.xls DELETED --- |
|
From: consonni d. <dav...@us...> - 2005-05-20 19:53:57
|
Update of /cvsroot/csvtosql/csvtosql/examples/test.excel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15519 Modified Files: users.xls Log Message: no message |
|
From: consonni d. <dav...@us...> - 2005-04-25 21:31:05
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/configuration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3125/src/net/sf/csv2sql/configuration Modified Files: Configurator.java ManualConfigurator.java XmlConfigurator.java Log Message: no message Index: ManualConfigurator.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/configuration/ManualConfigurator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ManualConfigurator.java 25 Apr 2005 10:52:57 -0000 1.1 --- ManualConfigurator.java 25 Apr 2005 21:30:37 -0000 1.2 *************** *** 18,26 **** package net.sf.csv2sql.configuration; import net.sf.csv2sql.configuration.sections.TableStructure; - import net.sf.csv2sql.configuration.sections.WriterList; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.renders.AbstractRender; import net.sf.csv2sql.storage.Storage; /** --- 18,27 ---- package net.sf.csv2sql.configuration; + import java.util.List; import net.sf.csv2sql.configuration.sections.TableStructure; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.renders.AbstractRender; import net.sf.csv2sql.storage.Storage; + import net.sf.csv2sql.writers.AbstractWriter; /** *************** *** 34,38 **** AbstractRender render; TableStructure tableStructure; ! WriterList writerList; Storage storage; --- 35,39 ---- AbstractRender render; TableStructure tableStructure; ! List<AbstractWriter> writerList; Storage storage; *************** *** 102,106 **** } ! public void setWriters(WriterList writerList) throws IllegalArgumentException { if (writerList==null) { --- 103,107 ---- } ! public void setWriters(List<AbstractWriter> writerList) throws IllegalArgumentException { if (writerList==null) { *************** *** 109,113 **** this.writerList = writerList; } ! public WriterList getWriters() throws ConfiguratorException { if (writerList==null) { --- 110,114 ---- this.writerList = writerList; } ! public List<AbstractWriter> getWriters() throws ConfiguratorException { if (writerList==null) { Index: XmlConfigurator.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/configuration/XmlConfigurator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlConfigurator.java 25 Apr 2005 10:52:57 -0000 1.1 --- XmlConfigurator.java 25 Apr 2005 21:30:37 -0000 1.2 *************** *** 19,22 **** --- 19,24 ---- import java.io.File; + import java.util.ArrayList; + import java.util.List; import java.util.Properties; import javax.xml.parsers.DocumentBuilder; *************** *** 26,30 **** import org.w3c.dom.NodeList; import net.sf.csv2sql.configuration.sections.TableStructure; - import net.sf.csv2sql.configuration.sections.WriterList; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.renders.AbstractRender; --- 28,31 ---- *************** *** 40,44 **** private Document document; ! private WriterList writers; private AbstractRender renderer; private AbstractGrammarFactory abstractGrammarFactory; --- 41,45 ---- private Document document; ! private List<AbstractWriter> writers; private AbstractRender renderer; private AbstractGrammarFactory abstractGrammarFactory; *************** *** 185,194 **** } ! public WriterList getWriters() throws ConfiguratorException { try { if (writers!=null) {return writers;} ! writers = new WriterList(); NodeList writerAppenders = document.getElementsByTagName("writerAppender"); --- 186,195 ---- } ! public List<AbstractWriter> getWriters() throws ConfiguratorException { try { if (writers!=null) {return writers;} ! writers = new ArrayList<AbstractWriter>(); NodeList writerAppenders = document.getElementsByTagName("writerAppender"); *************** *** 217,221 **** //finally add it ! writers.addWriter(writer); } --- 218,222 ---- //finally add it ! writers.add(writer); } Index: Configurator.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/configuration/Configurator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Configurator.java 25 Apr 2005 10:52:57 -0000 1.1 --- Configurator.java 25 Apr 2005 21:30:37 -0000 1.2 *************** *** 18,26 **** package net.sf.csv2sql.configuration; import net.sf.csv2sql.configuration.sections.TableStructure; - import net.sf.csv2sql.configuration.sections.WriterList; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.renders.AbstractRender; import net.sf.csv2sql.storage.Storage; /** --- 18,27 ---- package net.sf.csv2sql.configuration; + import java.util.List; import net.sf.csv2sql.configuration.sections.TableStructure; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.renders.AbstractRender; import net.sf.csv2sql.storage.Storage; + import net.sf.csv2sql.writers.AbstractWriter; /** *************** *** 39,43 **** throws ConfiguratorException; ! public WriterList getWriters() throws ConfiguratorException; --- 40,44 ---- throws ConfiguratorException; ! public List<AbstractWriter> getWriters() throws ConfiguratorException; |
|
From: consonni d. <dav...@us...> - 2005-04-25 21:31:03
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/frontends/gui/simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3125/src/net/sf/csv2sql/frontends/gui/simple Modified Files: ThinGui.java Log Message: no message Index: ThinGui.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/frontends/gui/simple/ThinGui.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ThinGui.java 25 Apr 2005 10:53:13 -0000 1.1 --- ThinGui.java 25 Apr 2005 21:30:38 -0000 1.2 *************** *** 35,39 **** import net.sf.csv2sql.configuration.ConfiguratorException; import net.sf.csv2sql.configuration.XmlConfigurator; - import net.sf.csv2sql.configuration.sections.WriterList; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.renders.AbstractRender; --- 35,38 ---- *************** *** 399,403 **** private void jMenuItemWritersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemWritersActionPerformed try { ! WriterList writers = config.getWriters(); Iterator iterator = writers.iterator(); log("[INFO] --- Writers ---"); --- 398,402 ---- private void jMenuItemWritersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemWritersActionPerformed try { ! List<AbstractWriter> writers = config.getWriters(); Iterator iterator = writers.iterator(); log("[INFO] --- Writers ---"); |
|
From: consonni d. <dav...@us...> - 2005-04-25 21:31:03
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3125/doc Modified Files: WHATSNEW.txt Log Message: no message Index: WHATSNEW.txt =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/doc/WHATSNEW.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WHATSNEW.txt 25 Apr 2005 10:51:09 -0000 1.1 --- WHATSNEW.txt 25 Apr 2005 21:30:37 -0000 1.2 *************** *** 1,29 **** Changes from csvtosql 2.1.4 to csvtosql 2.2.0 ! ============================================= ! * Dana Cordes <blo...@us...> ! To the JdbcBatchWriter, I've added some additional debug reporting when ! exceptions are thrown. I've also added a clearBatch() statement after ! each batch is sent. I don't know if that's strictly required, but some ! documentation I was reading suggested that it was. I also added a closing executeBatch() to make sure that the last few queries are executed. ! * Dana Cordes <blo...@us...> ! I've modified the standard StringField grammer to make it more easily ! extensible. Basically, I moved the sting escaping logic out into it's ! own method, to be overridden by decending classes. And I've added a ! truncateValue method that will truncate the string if the field ! properties define a truncatelength. I added the later functionality ! because some of the CSV values that I was being given were longer than their associated DB fields and causing errors. ! ! * Dana Cordes <blo...@us...> ! I've also added a db2 grammer. Currently it decending entirely from the ! standard grammer, except I extend the StringField and override the ! escaping logic to provide escaping appropriate for db2. It's by ! absolutely no means a complete implementation of db2. It's just enough for what I needed at the time. ! ! Changes from csvtosql 2.1.3 to csvtosql 2.1.4 ============================================= --- 1,41 ---- + Changes from csvtosql 2.2.0 to csvtosql 3.0.0 + ============================================= + + * added support for generics + + * removed WriterList, now is a simple List with generics. + + * changed descriptor version, current is now 3 + + * updated all examples. + + Changes from csvtosql 2.1.4 to csvtosql 2.2.0 ! ============================================= ! * Dana Cordes <blo...@us... ! To the JdbcBatchWriter, I've added some additional debug reporting when ! exceptions are thrown. I've also added a clearBatch() statement after ! each batch is sent. I don't know if that's strictly required, but some ! documentation I was reading suggested that it was. I also added a closing executeBatch() to make sure that the last few queries are executed. ! * Dana Cordes <blo...@us...> ! I've modified the standard StringField grammer to make it more easily ! extensible. Basically, I moved the sting escaping logic out into it's ! own method, to be overridden by decending classes. And I've added a ! truncateValue method that will truncate the string if the field ! properties define a truncatelength. I added the later functionality ! because some of the CSV values that I was being given were longer than their associated DB fields and causing errors. ! ! * Dana Cordes <blo...@us...> ! I've also added a db2 grammer. Currently it decending entirely from the ! standard grammer, except I extend the StringField and override the ! escaping logic to provide escaping appropriate for db2. It's by ! absolutely no means a complete implementation of db2. It's just enough for what I needed at the time. ! ! Changes from csvtosql 2.1.3 to csvtosql 2.1.4 ============================================= |
|
From: consonni d. <dav...@us...> - 2005-04-25 21:30:47
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/configuration/sections In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3125/src/net/sf/csv2sql/configuration/sections Removed Files: WriterList.java Log Message: no message --- WriterList.java DELETED --- |
|
From: consonni d. <dav...@us...> - 2005-04-25 21:30:47
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/writers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3125/src/net/sf/csv2sql/writers Modified Files: AbstractWriter.java Log Message: no message Index: AbstractWriter.java =================================================================== RCS file: /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/writers/AbstractWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractWriter.java 25 Apr 2005 10:53:23 -0000 1.1 --- AbstractWriter.java 25 Apr 2005 21:30:38 -0000 1.2 *************** *** 17,24 **** */ package net.sf.csv2sql.writers; - - import java.util.List; - import java.util.ArrayList; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.writers.exceptions.MissingRequiredParameterException; --- 17,22 ---- */ package net.sf.csv2sql.writers; import java.util.HashMap; + import java.util.Iterator; import java.util.Properties; import net.sf.csv2sql.writers.exceptions.MissingRequiredParameterException; |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:54:27
|
Update of /cvsroot/csvtosql/csvtosql_jdk50 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15772 Added Files: build.xml Log Message: no message --- NEW FILE: build.xml --- <?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="all" name="csvtosql"> <!-- LICENSE --> <target name="welcome"> <echo> Copyright (C) 2004 Davide Consonni (dco...@en...) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </echo> </target> <!-- INIT --> <target depends="welcome" name="init"> <property location="src" name="src.dir"/> <property location="classes" name="classes.dir"/> <property location="." name="src.dir"/> <property location="doc/api" name="javadoc.dir"/> <property location="bin/csvtosql.jar" name="jar"/> <property value="${src.dir}/manifest.mf" name="manifest"/> </target> <!-- COMPILE --> <target depends="init" name="compile"> <mkdir dir="${classes.dir}"/> <javac debug="true" deprecation="true" destdir="${classes.dir}" srcdir="${src.dir}"> <classpath> <pathelement path="${classpath}"/> <fileset dir="lib"> <include name="**/*.jar"/> </fileset> </classpath> </javac> </target> <!-- MAKE JAR --> <target depends="init,compile" name="jar"> <echo message="creating jar file .."/> <jar basedir="${classes.dir}" compress="false" jarfile="${jar}" manifest="${manifest}" /> </target> <!-- MAKE ALL --> <target depends="init,jar" description="Build everything." name="all"/> <!-- MAKE JAVADOC --> <target depends="init" description="Javadoc for my API." name="javadoc"> <echo message="creating javadoc .."/> <mkdir dir="${javadoc.dir}"/> <javadoc destdir="${javadoc.dir}" packagenames="*"> <sourcepath> <pathelement location="${src.dir}"/> </sourcepath> <classpath> <pathelement path="${classpath}"/> <fileset dir="lib"> <include name="**/*.jar"/> </fileset> </classpath> </javadoc> </target> <!-- CLEAN --> <target depends="init" description="Clean all build products." name="clean"> <delete dir="${classes.dir}"/> <delete dir="${javadoc.dir}"/> <delete file="${jar}"/> </target> <target depends="clean,jar,javadoc" name="distrib"> </target> </project> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:35
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/utils Added Files: DBUtils.java JarLoader.java Log Message: no message --- NEW FILE: JarLoader.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.utils; import java.io.File; import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; /** * Utility class for jar resources. */ public class JarLoader { private static final Class[] parameters = new Class[]{URL.class}; /** * Add jar to classpath when out of classpath. */ public static void addURL(URL u) throws IOException { URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader(); Class sysclass = URLClassLoader.class; try { Method method = sysclass.getDeclaredMethod("addURL",parameters); method.setAccessible(true); method.invoke(sysloader,new Object[]{ u }); } catch (Throwable t) { t.printStackTrace(); throw new IOException("Error, could not add URL to system classloader"); } } public static void addFile(File f) throws IOException { addURL(f.toURL()); } } --- NEW FILE: DBUtils.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.utils; import java.io.File; import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; /** * Utility class for jdbc resources. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class DBUtils { /** * Open a connection with jdbc resource. * load jdbc driver from file (can be also out of classpath) */ public static Connection openConnection(File jdbcJar, String driverClass, String url, String username, String password) throws SQLException, IOException, ClassNotFoundException { JarLoader.addFile(jdbcJar); Class.forName(driverClass); return DriverManager.getConnection(url,username,password); } /** * Open a connection with jdbc resource. */ public static Connection openConnection(String driverClass, String url, String username, String password) throws SQLException, ClassNotFoundException { Class.forName(driverClass); return DriverManager.getConnection(url,username,password); } /** * Close current connection with jdbc resource. */ public static void closeConnection(Connection conn) { try { if (conn!= null) { conn.close(); conn = null; } } catch(SQLException ex){ throw new RuntimeException(ex); } } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:35
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/renders/splitters In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/renders/splitters Added Files: Simple.java Splitter.java Standard.java Log Message: no message --- NEW FILE: Splitter.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.renders.splitters; import net.sf.csv2sql.renders.exceptions.RendererException; /** * Splitters are used by some renders to split the csv line. * <p> * <b>Extend this class</b> to define a new splitter, you must implement * the <code>split()</code> method, with must return the splitted values. * <p> * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public interface Splitter { public String[] split(String line, String separator) throws RendererException, IllegalArgumentException; } --- NEW FILE: Standard.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.renders.splitters; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.csv2sql.renders.exceptions.RendererException; /** * This implementation of splitter use regular expressions. * Is csv standard compliant. * <p> * IMPORTANT: only <,> can be used as separator. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class Standard implements Splitter { public String[] split(String line, String separator) throws RendererException, IllegalArgumentException { if (!separator.equals(",")) { throw new IllegalArgumentException("not standard csv separator."); } List<String> result = new ArrayList<String>(); Pattern pattern = Pattern.compile("(?m)\\G\r*(\n)?(?:^|,)(?:\"((?:\"\"|[^\"])*)\"([^,\n]*)|([^,\n]*))"); Matcher matcher = pattern.matcher(line); while(matcher.find()) { result.add((matcher.group(4) != null) ? matcher.group(4) : matcher.group(2).replaceAll("\"\"","\"")+matcher.group(3)); } String[] arr = new String[result.size()]; for (int i=0; i<result.size(); i++) { arr[i] = (String)result.get(i); } return arr; } } --- NEW FILE: Simple.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.renders.splitters; import net.sf.csv2sql.renders.exceptions.RendererException; /** * This implementation of Splitter use internal java splitter function * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class Simple implements Splitter { public String[] split(String line, String separator) throws RendererException, IllegalArgumentException { return line.split(separator, -1); } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:35
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/writers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/writers Added Files: AbstractWriter.java JdbcBatchWriter.java JdbcWriter.java SqlFileWriter.java SqlMultipleFileWriter.java StandardOutputWriter.java ThreadedAbstractWriter.java ThreadedStandardOutputWriter.java Log Message: no message --- NEW FILE: StandardOutputWriter.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers; import java.util.HashMap; import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.writers.exceptions.WriterException; /** * Write generated statements to standard output using * <code>System.out.println();</code> method. * @see AbstractWriter AbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class StandardOutputWriter extends AbstractWriter { /** * @see AbstractWriter#write */ public void write() throws WriterException { try { for (int i=0; i<getStorage().size(); i++) { System.out.println(getStorage().get(i)); } } catch (StorageException e) { throw new WriterException("cannot read data from temporary storage", e); } } public HashMap<String, String> requiredParameterList() { return null; } public HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: SqlFileWriter.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.HashMap; import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.writers.exceptions.WriterException; /** * Write a new textfile with generated statements. * @see AbstractWriter AbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class SqlFileWriter extends AbstractWriter { /** * @see AbstractWriter#write */ public void write() throws WriterException { try { File out = new File(getWriterProperties().getProperty("filename")); BufferedWriter output = new BufferedWriter(new FileWriter(out)); for (int i=0; i<getStorage().size(); i++) { output.write(getStorage().get(i)+"\n" ); } output.close(); } catch (StorageException e) { throw new WriterException("cannot read data from temporary storage", e); } catch (IOException e) { throw new WriterException("cannot write statement to file", e); } } protected HashMap<String, String> requiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("filename","output filename where result will be stored."); return hm; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: JdbcWriter.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers; import java.io.File; import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.HashMap; import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.utils.DBUtils; import net.sf.csv2sql.writers.exceptions.InvalidParameterValueException; import net.sf.csv2sql.writers.exceptions.WriterException; /** * Load generated statements in a jdbc resource. * @see AbstractWriter AbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class JdbcWriter extends AbstractWriter { //mandatory parameters String driver; String url; String username; String password; //optional parameters File jdbcJar = null; boolean commit; private void init() throws InvalidParameterValueException { driver = getWriterProperties().getProperty("driver"); url = getWriterProperties().getProperty("url"); username = getWriterProperties().getProperty("username"); password = getWriterProperties().getProperty("password"); //optional set autocommit commit = "true".equalsIgnoreCase(getWriterProperties().getProperty("commit")); //optional String strJdbcJar = getWriterProperties().getProperty("jdbcjar"); if (strJdbcJar!=null && !strJdbcJar.equals("")) { jdbcJar = new File(strJdbcJar); if (!jdbcJar.exists()) { throw new InvalidParameterValueException("jdbcjar", getWriterProperties().getProperty("jdbcjar")); } } } /** * @see AbstractWriter#write */ public void write() throws WriterException { Connection connection = null; Statement stmt = null; try { //get configuration options init(); if (jdbcJar!=null) { connection = DBUtils.openConnection(jdbcJar, driver, url, username, password); } else { connection = DBUtils.openConnection(driver, url, username, password); } stmt = connection.createStatement(); //start transaction if (commit) {connection.setAutoCommit(false);} for (int i=0; i<getStorage().size(); i++) { stmt.executeUpdate(getStorage().get(i)); } //stop transaction if (commit) {connection.commit();} } catch (StorageException e) { throw new WriterException("cannot read data from temporary storage", e); } catch (SQLException e) { throw new WriterException("cannot write statement to database", e); } catch (IOException e) { throw new WriterException("cannot find database driver", e); } catch (ClassNotFoundException e) { throw new WriterException("cannot load database driver", e); } finally { DBUtils.closeConnection(connection); } } protected HashMap<String, String> requiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("driver","jdbc driver classname."); hm.put("url","jdbc database url."); hm.put("username","jdbc username."); return hm; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("password","jdbc password."); hm.put("commit","true or false. specify the use of transactions."); hm.put("jdbcjar","url of jdbc driver (will be load with a custom classloader)."); return hm; } } --- NEW FILE: AbstractWriter.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers; import java.util.List; import java.util.ArrayList; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.writers.exceptions.MissingRequiredParameterException; import net.sf.csv2sql.writers.exceptions.WriterException; import net.sf.csv2sql.storage.Storage; /** * The writer classes write statements on a output resource like * file, or jdbc, xml, ecc.. * <p> * <b>Extend this class</b> to define a new writer, you must implement * the <code>write()</code> method, the argument of this method are the statement * generated from render classes. * <p> * Implement methods * <code>requiredParameterList</code> and <code>optionalParameterList</code> * to return the list of required and the optional parameters * <p> * Options passed to this class (and extended) can be read which * <code>getWriterProperties()</code> getter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public abstract class AbstractWriter { private Properties properties; private Storage storage; /** * write list of statements. * @throws WriterException if data could not be written (for any reason) */ public abstract void write() throws WriterException; public Properties getWriterProperties() { return this.properties; } /** * init writers' parameters * @see MissingRequiredParameterException MissingRequiredParameterException * @throws MissingRequiredParameterException if required parameter is missing */ public void configure(Properties properties, Storage storage) throws MissingRequiredParameterException { this.properties = properties; this.storage = storage; //check for required properties Object[] required = getRequiredParameterList().keySet().toArray(); for (int i=0; i< required.length; i++) { String parameter = (required[i]).toString(); String configParameter = properties.getProperty(parameter); if (configParameter==null) { throw new MissingRequiredParameterException(parameter); } } } protected Storage getStorage() { return this.storage; } public HashMap<String, String> getRequiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.putAll((commonRequiredParameterList()==null ? new HashMap<String, String>() : commonRequiredParameterList())); hm.putAll((requiredParameterList()==null ? new HashMap<String, String>() : requiredParameterList())); return hm; } public HashMap<String, String> getOptionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.putAll((commonOptionalParameterList()==null ? new HashMap<String, String>() : commonOptionalParameterList())); hm.putAll((optionalParameterList()==null ? new HashMap<String, String>() : optionalParameterList())); return hm; } private HashMap<String, String> commonRequiredParameterList() { return null; } private HashMap<String, String> commonOptionalParameterList() { return null; } protected abstract HashMap<String, String> requiredParameterList(); protected abstract HashMap<String, String> optionalParameterList(); } --- NEW FILE: ThreadedAbstractWriter.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers; import net.sf.csv2sql.writers.exceptions.WriterException; /** * An AbstractWriter with thread support. <code>write</code> method * automatically start the thread * @see AbstractWriter AbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public abstract class ThreadedAbstractWriter extends AbstractWriter implements Runnable { float progress; /** * start thread with write list of statements. * @throws WriterException if data could not be written (for any reason) */ public void write() throws WriterException { progress=0; Thread AbstractWriterThread = null; AbstractWriterThread = new Thread(this, "AbstractWriterThread"); AbstractWriterThread.start(); } /** * get the current progress % for writing operation. */ public final float getProgress() { return this.progress; } /** * when progres is 100% the writing operations ends. */ public final boolean isDone() { return progress==100; } protected final void setProgress(float progress) { if (progress>100 || progress<0) { throw new IllegalArgumentException("progress must be between 0 and 100"); } this.progress = progress; } } --- NEW FILE: JdbcBatchWriter.java --- /* Copyright (C) 2004 Radovan Sninsky <sn...@po...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers; import java.io.File; import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import java.util.HashMap; import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.utils.DBUtils; import net.sf.csv2sql.writers.exceptions.InvalidParameterValueException; import net.sf.csv2sql.writers.exceptions.WriterException; /** * Load generated statements in a jdbc resource with batch method. * @author <a href="mailto:sn...@bg...">Radovan Sninsky</a> * @version $Revision: 1.22 $, $Date: 2005/03/12 11:29:22 $ * @since 1.1 */ public class JdbcBatchWriter extends AbstractWriter { //mandatory parameters String driver; String url; String username; String password; int batchCount; //optional parameters int commitBatchCount; File jdbcJar = null; private void init() throws InvalidParameterValueException { driver = getWriterProperties().getProperty("driver"); url = getWriterProperties().getProperty("url"); username = getWriterProperties().getProperty("username"); password = getWriterProperties().getProperty("password"); batchCount = Integer.parseInt(getWriterProperties().getProperty("batchcount", "10")); //optional commitBatchCount = Integer.parseInt(getWriterProperties().getProperty("commitbatchcount", "0")); //optional String strJdbcJar = getWriterProperties().getProperty("jdbcjar"); if (strJdbcJar!=null && !strJdbcJar.equals("")) { jdbcJar = new File(strJdbcJar); if (!jdbcJar.exists()) { throw new InvalidParameterValueException("jdbcjar", getWriterProperties().getProperty("jdbcjar")); } } } /** * @see AbstractWriter#write */ public void write() throws WriterException{ //get configuration options init(); String currentSQL = null; int sqlIndex = 0; try { Connection connection = null; if (jdbcJar!=null) { connection = DBUtils.openConnection(jdbcJar, driver, url, username, password); } else { connection = DBUtils.openConnection(driver, url, username, password); } try { Statement stmt = connection.createStatement(); try { //start transaction if (commitBatchCount != 1) { connection.setAutoCommit(false); } int batchSize = 0; int commitIdx = 0; for (int i=0; i<getStorage().size(); i++) { String sql = getStorage().get(i); stmt.addBatch(sql); sqlIndex++; currentSQL = sql; if (++batchSize == batchCount) { batchSize = 0; stmt.executeBatch(); if (commitBatchCount > 1 && commitBatchCount == ++commitIdx) { connection.commit(); commitIdx = 0; } stmt.clearBatch(); } } //take care of the remaining records. stmt.executeBatch(); stmt.clearBatch(); //stop transaction if (commitBatchCount != 1) { connection.commit(); } } finally { stmt.close(); } } finally { connection.close(); } } catch (StorageException e) { throw new WriterException("cannot read data from temporary storage", e); } catch (SQLException e) { throw new WriterException("cannot write statement to database: " + sqlIndex + "\n" + e.getMessage() + "\n" + currentSQL, e); } catch (IOException e) { throw new WriterException("cannot find database driver", e); } catch (ClassNotFoundException e) { throw new WriterException("cannot load database driver", e); } } protected HashMap<String, String> requiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("driver","jdbc driver classname."); hm.put("url","jdbc database url."); hm.put("username","jdbc username."); hm.put("commitbatchcount","commitbatchcount."); return hm; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("password","jdbc password."); hm.put("commit","true or false. specify the use of transactions."); hm.put("jdbcjar","url of jdbc driver (will be load with a custom classloader)."); hm.put("batchcount","batchcount."); return hm; } } --- NEW FILE: ThreadedStandardOutputWriter.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers; import java.util.HashMap; import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.writers.exceptions.ThreadedInvalidParameterValueException; /** * Write generated statements to standard output using * <code>System.out.println();</code> method. * @see ThreadedAbstractWriter ThreadedAbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class ThreadedStandardOutputWriter extends ThreadedAbstractWriter { private float calculateStopAtProgress() { if (getWriterProperties().getProperty("stopatprogress")==null) {return 101;} float stopAt = 101; try { stopAt = Float.parseFloat(getWriterProperties().getProperty("stopatprogress")); if (stopAt<0||stopAt>100) { stopAt = 101; } } catch (Exception e) { throw new ThreadedInvalidParameterValueException("stopatprogress", getWriterProperties().getProperty("stopatprogress")); } return stopAt; } /** * @see ThreadedAbstractWriter#write */ public void run() { try { setProgress(0); float total= getStorage().size(); float stopAt = calculateStopAtProgress(); for (int i=0; i<getStorage().size(); i++) { if (getProgress()>=stopAt) break; System.out.println(getStorage().get(i));; setProgress((i/total)*100); if ("true".equalsIgnoreCase(getWriterProperties().getProperty("printprogress"))) { System.err.println(getProgress()); } } setProgress(100); } catch (StorageException e) { e.printStackTrace(); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("printprogress","print progress to standard error stream (default false)."); hm.put("stopatprogress","stop printing at this %."); return hm; } } --- NEW FILE: SqlMultipleFileWriter.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.HashMap; import net.sf.csv2sql.storage.exceptions.StorageException; import net.sf.csv2sql.writers.exceptions.InvalidParameterValueException; import net.sf.csv2sql.writers.exceptions.WriterException; /** * Write a new textfile with generated statements. * @see AbstractWriter AbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class SqlMultipleFileWriter extends AbstractWriter { public static String formatSequence(int currentPage, int totalPages) { StringBuffer sb = new StringBuffer(); int zeroToAdd = (String.valueOf(totalPages)).length() - (String.valueOf(currentPage)).length(); for (int i=0; i<zeroToAdd; i++) {sb.append("0");} sb.append(String.valueOf(currentPage)); return sb.toString(); } private int calculateBreakLines() throws InvalidParameterValueException { int breaklines=10; String bl = getWriterProperties().getProperty("breaklines"); breaklines = (bl!=null) ? Integer.parseInt(bl) : 10; if (breaklines <= 0) { throw new InvalidParameterValueException( "breaklines", getWriterProperties().getProperty("breaklines") ); } return breaklines; } /** * @see AbstractWriter#write */ public void write() throws WriterException { try { int breaklines=calculateBreakLines(); int sequence=0; float pages = getStorage().size()/breaklines; if (pages<1) { //only one page File out = new File(getWriterProperties().getProperty("filename")); BufferedWriter output = new BufferedWriter(new FileWriter(out)); for (int i=0; i<getStorage().size(); i++) { output.write(getStorage().get(i)+"\n" ); } output.close(); } else { //more than one page //first n pages for (int i=1; i<=pages; i++) { File out = new File(getWriterProperties().getProperty("filename")+ "_"+ formatSequence(i, (int)pages)); BufferedWriter output = new BufferedWriter(new FileWriter(out)); int from = breaklines*(i-1); int to = (breaklines*(i)); for (int j=from; j<to; j++) { sequence++; output.write(getStorage().get(j) +"\n" ); } output.flush(); output.close(); } //last if exist if (pages!=1) { File out = new File(getWriterProperties().getProperty("filename")+ "_"+ formatSequence((int)pages, (int)pages)); BufferedWriter output = new BufferedWriter(new FileWriter(out)); for (int i=sequence; i<getStorage().size(); i++) { sequence++; output.write(getStorage().get(i) +"\n" ); } output.flush(); output.close(); } } } catch (StorageException e) { throw new WriterException("cannot read data from temporary storage", e); } catch (IOException e) { throw new WriterException("cannot write statement to file", e); } } protected HashMap<String, String> requiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("filename","output filename where result will be stored."); return hm; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("breaklines","number of lines before break the csvfile 10 if not specified."); return hm; } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:34
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/writers/exceptions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/writers/exceptions Added Files: InvalidParameterValueException.java MissingRequiredParameterException.java ThreadedInvalidParameterValueException.java ThreadedWriterException.java WriterException.java Log Message: no message --- NEW FILE: InvalidParameterValueException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers.exceptions; /** * This exception is throwed when one parameter of any subclass * of AbstractWriter is invalid * @see net.sf.csv2sql.writers.AbstractWriter AbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class InvalidParameterValueException extends WriterException { private String parameterName; private String parameterValue; public InvalidParameterValueException(String parameterName, String parameterValue) { super("invalid parameter value.", null); this.parameterName = parameterName; this.parameterValue = parameterValue; } public String getParameterName() { return parameterName; } public String getParameterValue() { return parameterValue; } public String toString() { return "InvalidParameterValueException, "+ "parametername="+getParameterName()+ ", parametervalue="+getParameterValue(); } } --- NEW FILE: WriterException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers.exceptions; /** * This exception is throwed when any exception occured during writing * operation. Is throwed by any subclass of AbstractWriter. * @see net.sf.csv2sql.writers.AbstractWriter AbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class WriterException extends Exception{ public WriterException(String message, Throwable cause) { super(message, cause); } public WriterException(Throwable cause) { super(cause); } } --- NEW FILE: ThreadedInvalidParameterValueException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers.exceptions; /** * This exception is throwed when one parameter of any subclass * of ThreadedAbstractWriter is invalid * @see net.sf.csv2sql.writers.ThreadedAbstractWriter ThreadedAbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class ThreadedInvalidParameterValueException extends ThreadedWriterException { private String parameterName; private String parameterValue; public ThreadedInvalidParameterValueException(String parameterName, String parameterValue) { super("invalid parameter value."); this.parameterName = parameterName; this.parameterValue = parameterValue; } public String getParameterName() { return parameterName; } public String getParameterValue() { return parameterValue; } public String toString() { return "InvalidParameterValueException, "+ "parametername="+getParameterName()+ ", parametervalue="+getParameterValue(); } } --- NEW FILE: MissingRequiredParameterException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers.exceptions; /** * This exception is throwed when one requred parameter of any subclass * of AbstractWriter is missing * @see net.sf.csv2sql.writers.AbstractWriter AbstractWriter * @see net.sf.csv2sql.writers.ThreadedAbstractWriter ThreadedAbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class MissingRequiredParameterException extends Exception { private String parameterName; public MissingRequiredParameterException(String parameterName) { super("missing writer's required parameter : " + parameterName); } public String getMissingParameter() { return parameterName; } } --- NEW FILE: ThreadedWriterException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.writers.exceptions; /** * This exception is throwed when any exception occured during writing * operation. Is throwed by any subclass of ThreadedAbstractWriter. * @see net.sf.csv2sql.writers.ThreadedAbstractWriter ThreadedAbstractWriter * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class ThreadedWriterException extends RuntimeException { public ThreadedWriterException(String message) { super(message); } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:32
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/storage/exceptions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/storage/exceptions Added Files: InvalidParameterValueException.java MissingRequiredParameterException.java StorageException.java Log Message: no message --- NEW FILE: InvalidParameterValueException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.storage.exceptions; /** * throwed when a required renders' parameter has an invalid value. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class InvalidParameterValueException extends StorageException { private String parameterName; private String parameterValue; public InvalidParameterValueException(String parameterName, String parameterValue) { super("invalid parameter value.", null); this.parameterName = parameterName; this.parameterValue = parameterValue; } public String getParameterName() { return parameterName; } public String getParameterValue() { return parameterValue; } public String toString() { return "InvalidParameterValueException, "+ "parametername="+getParameterName()+ ", parametervalue="+getParameterValue(); } } --- NEW FILE: MissingRequiredParameterException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.storage.exceptions; /** * throwed when a required renders' parameter is missing. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class MissingRequiredParameterException extends Exception { private String parameterName; public MissingRequiredParameterException(String parameterName) { super("missing storage's required parameter: " + parameterName); } public String getMissingParameter() { return parameterName; } } --- NEW FILE: StorageException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.storage.exceptions; /** * is throwed when any exception occur during rendering. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class StorageException extends java.lang.Exception { public StorageException(String message, Throwable cause) { super(message, cause); } public StorageException(Throwable cause) { super(cause); } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:32
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/storage Added Files: Disk.java Memory.java Storage.java Log Message: no message --- NEW FILE: Disk.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.storage; import java.nio.ByteBuffer; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.storage.exceptions.MissingRequiredParameterException; import net.sf.csv2sql.storage.exceptions.StorageException; /** * Storage implementation that save temporary data in a tempfile. * <p> * supported lines around 275000. * @see Storage Storage * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class Disk extends Storage { private File file; private int bufferLength; public boolean add(String o) throws StorageException { try { RandomAccessFile raf = new RandomAccessFile(file, "rw"); raf.seek(raf.length()); ByteBuffer buf = ByteBuffer.allocate(bufferLength); buf.put(o.getBytes()); raf.write(buf.array()); raf.close(); raf=null; return true; } catch (IOException e) { throw new StorageException("can't add element to storage",e); } } public String get(int index) throws IndexOutOfBoundsException, StorageException { try { RandomAccessFile raf = new RandomAccessFile(file, "rw"); raf.seek(index*bufferLength); byte[] b = new byte[bufferLength]; raf.read(b); String str = new String(b); raf.close(); raf=null; return str.trim(); } catch (IOException e) { throw new StorageException("can't get element from storage",e); } } public long size() throws StorageException { try { RandomAccessFile raf = new RandomAccessFile(file, "rw"); int length =(int)raf.length() / bufferLength; raf.close(); raf=null; return length; } catch (IOException e) { throw new StorageException("can't stat size of storage",e); } } public void clear() throws StorageException { file.delete(); } private void calculateBuffer() { bufferLength = Integer.parseInt(getStorageProperties().getProperty("buffer", "2000")); } private File calculateTempFile() throws StorageException { try { String filename = getStorageProperties().getProperty("tempfile"); return (filename==null) ? File.createTempFile("csvtosql", ".tmp") : new File(filename); } catch (IOException e) { throw new StorageException("can't calculate temp file",e); } } public void configure(Properties properties) throws MissingRequiredParameterException, StorageException { super.configure(properties); calculateBuffer(); file = calculateTempFile(); try { file.createNewFile(); } catch (IOException e) { throw new StorageException("can't create temp file",e); } } protected void finalize() throws Throwable { clear(); } public HashMap<String, String> requiredParameterList() { return null; } public HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("buffer", "length in char of buffer. default 2000 characters."); hm.put("tempfile", "temporary filename (absolute). default random name in system tmp directory."); return hm; } } --- NEW FILE: Storage.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.storage; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.storage.exceptions.MissingRequiredParameterException; import net.sf.csv2sql.storage.exceptions.StorageException; /** * Storage classes are used to exchange data between render and writers. * <p> * <b>Extend this class</b> to define a new storage. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public abstract class Storage { private Properties properties; /** * remove all statements */ public abstract void clear() throws StorageException; /** * add one statement */ public abstract boolean add(String o) throws StorageException; /** * read a statement */ public abstract String get(int index) throws IndexOutOfBoundsException, StorageException; /** * return number of statements */ public abstract long size() throws StorageException; public void configure(Properties properties) throws MissingRequiredParameterException, StorageException { this.properties = properties; //check for required properties Object[] required = getRequiredParameterList().keySet().toArray(); for (int i=0; i< required.length; i++) { String parameter = (required[i]).toString(); String configParameter = properties.getProperty(parameter); if (configParameter==null) { throw new MissingRequiredParameterException(parameter); } } } public Properties getStorageProperties() { return this.properties; } public HashMap<String, String> getRequiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.putAll((commonRequiredParameterList()==null ? new HashMap<String, String>() : commonRequiredParameterList())); hm.putAll((requiredParameterList()==null ? new HashMap<String, String>() : requiredParameterList())); return hm; } public HashMap<String, String> getOptionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.putAll((commonOptionalParameterList()==null ? new HashMap<String, String>() : commonOptionalParameterList())); hm.putAll((optionalParameterList()==null ? new HashMap<String, String>() : optionalParameterList())); return hm; } private HashMap<String, String> commonRequiredParameterList() { return null; } private HashMap<String, String> commonOptionalParameterList() { return null; } protected abstract HashMap<String, String> requiredParameterList(); protected abstract HashMap<String, String> optionalParameterList(); } --- NEW FILE: Memory.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.storage; import java.util.HashMap; import java.util.List; import java.util.ArrayList; import net.sf.csv2sql.storage.exceptions.StorageException; /** * Storage implementation that save temporary data in memory. * <p> * supported lines around 50000 with default memory options. * @see Storage Storage * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class Memory extends Storage { private List<String> elements = new ArrayList<String>(); public boolean add(String o) throws StorageException { return elements.add(o); } public String get(int index) throws IndexOutOfBoundsException, StorageException { return (String)elements.get(index); } public long size() throws StorageException { return elements.size(); } public void clear() throws StorageException { elements.clear(); } public HashMap<String, String> requiredParameterList() { return null; } public HashMap<String, String> optionalParameterList() { return null; } } |