package com.philmcrew.data; import com.philmcrew.utility.FixedToDelim; import java.net.URL; import java.net.MalformedURLException; import java.net.URLConnection; import java.io.InputStream; import java.io.IOException; import java.sql.PreparedStatement; import java.sql.SQLException; /** * Created by IntelliJ IDEA. * User: mfriedman * Date: Feb 6, 2006 * Time: 12:47:30 PM * To change this template use File | Settings | File Templates. */ public class FipsCountry implements DataFile { public String getTable() { return "fips_country"; } public URL getDataSource() throws MalformedURLException { return new URL("http://philmcrew.com/fips_country.txt"); } public InputStream getInputStream() throws IOException { URL url = getDataSource(); URLConnection urlConnection = url.openConnection(); return urlConnection.getInputStream(); } public String getCreateQuery() { return "create table fips_country (" + "country_name varchar(64), " + "long_country_name varchar(96), " + "country_code char(2), " + "of_country_code char(2) " + ")"; } public String getDeleteQuery() { return "delete from fips_country"; } public String getInsertQuery() { return "insert into fips_country values (?, ?, ?, ?)"; } public int deliminate(InputStream inputStream, PreparedStatement pst) throws SQLException { FixedToDelim fixedToDelim = new FixedToDelim(); return fixedToDelim.fixedDeliminate(inputStream, pst, "\t", 4); } }