Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import net.autodata.engines.configurator.*;
- import net.autodata.engines.configurator.vehicle.*;
- import net.autodata.engines.configurator.core.*;
- import net.autodata.engines.configurator.vehicle.dao.*;
- import net.autodata.engines.configurator.vehicle.digester.*;
- import net.autodata.engines.*;
- import org.springframework.jdbc.datasource.DriverManagerDataSource;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.*;
- public class RoRAutoDataBridge
- {
- //class varibles
- ConfigVehicleFactory factory;
- IConfigVehicle veh;
- VehicleSAXDigester digester;
- DriverManagerDataSource dmds;
- JdbcLogicTreeDAO dao;
- Connection connection;
- Statement statement;
- static final String LANG_CODE = "en";
- static final String CC = "US";
- public RoRAutoDataBridge(String acode, String make, String model)
- {
- //create a new vehicle digerster
- digester = new VehicleSAXDigester();
- try
- {
- //create connection to data base
- dmds = new DriverManagerDataSource();
- dmds.setDriverClassName("com.mysql.jdbc.Driver");
- dmds.setUrl("jdbc:mysql://76.233.231.47:3306/autodata");
- dmds.setUsername("autodata");
- dmds.setPassword("@utoda!a");
- dao = new JdbcLogicTreeDAO();
- dao.setDataSource(dmds);
- factory = new ConfigVehicleFactory();
- factory.setDao(dao);
- factory.setDigester(digester);
- }
- catch( Exception e)
- {
- System.out.println("There was an error The program will now exit");
- System.out.println(e);
- }
- try
- { // fetch vehicle from database with acode passsed into constructor
- veh = factory.getConfigVehicle(acode,"EN","","14");
- }
- catch( Exception e)
- {
- System.out.println("There was an error The program will now exit");
- System.out.println(e);
- }
- }
- public IConfigVehicle getIConfigVehicle()
- {
- return this.veh;
- }
- public ResultSet findAcode(String make, String model, String year)
- {
- ResultSet resultSet = null;
- try
- { //load database driver class
- Class.forName("com.mysql.jdbc.Driver");
- connection = DriverManager.getConnection("jdbc:mysql://76.233.231.47:3306/autodata", "autodata", "@utoda!a");
- statement = connection.createStatement();
- resultSet = statement.executeQuery("SELECT Acode from vt05_trim, vt04_model, vt08_year, vt02_division WHERE vt02_division.LngCode="
- +LANG_CODE+" AND vt02_division.CountryCode="+CC
- +" AND vt02_division.DivCode=vt04_model.DivCode AND vt08_year.YearCode=vt05_trim.YearCode AND vt04_model.ModelId=vt05_trim.ModelId AND vt02_division.DivDesc="
- +make+" AND vt04_model.ModelDesc ="+model+" AND vt08_year.YearDesc="+year+"");
- }
- catch( Exception e)
- {
- System.out.println("There was an error The program will now exit");
- System.out.println(e);
- }
- return resultSet;
- }
- public static void main (String[] args)
- {
- try
- { // create new roradb object and pass it an acode
- RoRAutoDataBridge roradb = new RoRAutoDataBridge ("USA20ACC011C3", "", "");
- // get the general info object and then output price
- IGeneralInfo igi = roradb.getIConfigVehicle().getGeneralInfo();
- System.out.println(igi.getFullBaseMSRP());
- ResultSet myResultSet = roradb.findAcode("BMW","M5", "B90");
- }
- catch( Exception e)
- {
- System.out.println("There was an error The program will now exit");
- System.out.println(e);
- }
- }
- }
Add Comment
Please, Sign In to add comment