[Tynstep-svn] r21 - in trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader: . beans loaders utils
ChrisBurrell at crosswire.org
ChrisBurrell at crosswire.org
Thu Nov 12 06:54:04 MST 2009
Author: ChrisBurrell
Date: 2009-11-12 06:54:04 -0700 (Thu, 12 Nov 2009)
New Revision: 21
Modified:
trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/ClientDbProvider.java
trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/Dataloader.java
trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/beans/PartialDate.java
trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/beans/TimelineEventBean.java
trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/AbstractLoader.java
trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/TimelineLoader.java
trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java
Log:
Modified: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/ClientDbProvider.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/ClientDbProvider.java 2009-11-10 22:52:18 UTC (rev 20)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/ClientDbProvider.java 2009-11-12 13:54:04 UTC (rev 21)
@@ -7,12 +7,16 @@
public class ClientDbProvider {
//TODO: shove this in a properties file
private static String clientConnection = "jdbc:derby:";
-
+ private static Connection connection = null;
public static Connection getConnection(String dbPath) throws SQLException {
- String connectionString = clientConnection + dbPath;
- System.out.println("Using connection string: " + connectionString);
- return DriverManager.getConnection(connectionString );
+ if(connection == null) {
+ String connectionString = clientConnection + dbPath;
+ System.out.println("Using connection string: " + connectionString);
+ connection = DriverManager.getConnection(connectionString);
+ }
+
+ return connection;
}
public static void finaliseConnection(Connection connection) throws SQLException {
@@ -20,4 +24,8 @@
connection.close();
}
}
+
+ public static Connection getConnection() {
+ return connection;
+ }
}
Modified: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/Dataloader.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/Dataloader.java 2009-11-10 22:52:18 UTC (rev 20)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/Dataloader.java 2009-11-12 13:54:04 UTC (rev 21)
@@ -3,7 +3,6 @@
import java.io.IOException;
import java.sql.SQLException;
import java.text.ParseException;
-import java.util.Calendar;
import org.apache.commons.dbutils.DbUtils;
Modified: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/beans/PartialDate.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/beans/PartialDate.java 2009-11-10 22:52:18 UTC (rev 20)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/beans/PartialDate.java 2009-11-12 13:54:04 UTC (rev 21)
@@ -2,9 +2,7 @@
import java.text.ParseException;
import java.util.Calendar;
-import java.util.Date;
import java.util.GregorianCalendar;
-import java.util.TimeZone;
import org.apache.commons.lang.StringUtils;
Modified: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/beans/TimelineEventBean.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/beans/TimelineEventBean.java 2009-11-10 22:52:18 UTC (rev 20)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/beans/TimelineEventBean.java 2009-11-12 13:54:04 UTC (rev 21)
@@ -1,8 +1,5 @@
package com.tyndalehouse.step.dataloader.beans;
-import java.text.ParseException;
-import java.util.Calendar;
-import java.util.HashMap;
//TODO: Refactor eventually so use as we load data out of the database...
public class TimelineEventBean extends DbBean {
Modified: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/AbstractLoader.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/AbstractLoader.java 2009-11-10 22:52:18 UTC (rev 20)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/AbstractLoader.java 2009-11-12 13:54:04 UTC (rev 21)
@@ -5,7 +5,6 @@
import java.sql.Connection;
import java.sql.SQLException;
-import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.io.FileUtils;
Modified: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/TimelineLoader.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/TimelineLoader.java 2009-11-10 22:52:18 UTC (rev 20)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/TimelineLoader.java 2009-11-12 13:54:04 UTC (rev 21)
@@ -1,20 +1,18 @@
package com.tyndalehouse.step.dataloader.loaders;
import java.io.File;
+import java.io.FileFilter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
-import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.text.ParseException;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
-import org.apache.commons.dbutils.DbUtils;
import org.supercsv.io.CsvBeanReader;
import org.supercsv.io.ICsvBeanReader;
import org.supercsv.prefs.CsvPreference;
@@ -48,7 +46,17 @@
}
//then get list of files in directory
- File[] listOfFiles = directory.listFiles();
+ File[] listOfFiles = directory.listFiles(new FileFilter() {
+
+ @Override
+ public boolean accept(File file) {
+ if(!file.getName().endsWith(".csv")) {
+ return false;
+ }
+ return true;
+ }
+
+ });
List<TimelineEventBean> events = new ArrayList<TimelineEventBean>();
TimelineEventBean tb;
Modified: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java 2009-11-10 22:52:18 UTC (rev 20)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java 2009-11-12 13:54:04 UTC (rev 21)
@@ -1,16 +1,18 @@
package com.tyndalehouse.step.dataloader.utils;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import com.tyndalehouse.step.dataloader.ClientDbProvider;
+
public class DerbyUtils {
//TODO: optimize: creating a new connection each time sounds like a waste of time...
public static void dropIfExists(String tableName) throws SQLException {
- Connection conn = DriverManager.getConnection("jdbc:default:connection");
+ //Connection conn = DriverManager.getConnection("jdbc:default:connection");
+ Connection conn = ClientDbProvider.getConnection();
PreparedStatement exists = conn.prepareStatement("select count(*) from sys.systables where tablename = upper('" + tableName + "')");
ResultSet exRs = exists.executeQuery();
@@ -23,6 +25,6 @@
PreparedStatement s = conn.prepareStatement("drop table " + tableName);
s.executeUpdate();
}
- conn.close();
+ //conn.close();
}
}
More information about the Tynstep-svn
mailing list