package com.philmcrew.data; import com.philmcrew.utility.FixedToDelim; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.sql.PreparedStatement; import java.sql.SQLException; /** * Created by IntelliJ IDEA. * User: Mitchell * Date: Feb 27, 2005 * Time: 10:47:34 AM * To change this template use Options | File Templates. */ public class CountrySubEntity implements DataFile { public String getTable() { return "country_subentity"; } public URL getDataSource() throws MalformedURLException { return new URL("http://philmcrew.com/countrysubentity.txt"); } public InputStream getInputStream() throws IOException { URL url = getDataSource(); URLConnection urlConnection = url.openConnection(); return urlConnection.getInputStream(); } public String getCreateQuery() { return "create table countrysubentity ( country_code char(2), state_code varchar(6), state_name varchar(128))"; } public String getDeleteQuery() { return "delete from countrysubentity"; } public String getInsertQuery() { return "insert into countrysubentity values (?, ?, ?)"; } public int deliminate(InputStream inputStream, PreparedStatement pst) throws SQLException { FixedToDelim fixedToDelim = new FixedToDelim(); return fixedToDelim.fixedDeliminate(inputStream, pst, ",", 3); } }