Example usage for java.util.logging Logger getLogger

List of usage examples for java.util.logging Logger getLogger

Introduction

In this page you can find the example usage for java.util.logging Logger getLogger.

Prototype




@CallerSensitive
public static Logger getLogger(String name) 

Source Link

Document

Find or create a logger for a named subsystem.

Usage

From source file:com.bluepandora.therap.donatelife.service.CheckService.java

public static boolean isMobileNumberTaken(String mobileNumber, DatabaseService dbService) {
    String query = GetQuery.mobileNumberUsedQuery(mobileNumber);
    ResultSet result = dbService.getResultSet(query);
    boolean mobileNumberRegistered = false;
    try {/*from   w  ww .j a  v a2  s.co  m*/
        while (result.next()) {
            mobileNumberRegistered = true;
        }
    } catch (SQLException error) {
        Logger.getLogger(CheckService.class.getName()).log(Level.SEVERE, null, error);
    }
    return mobileNumberRegistered;
}

From source file:bizlogic.Records.java

public static void add(Connection DBcon, String sensor_name, String smpl_interval, String running, String name)
        throws SQLException {

    String isRunning;/*from   ww w  . ja  va2s . c o  m*/
    Statement st;
    ResultSet rs = null;

    try {
        st = DBcon.createStatement();
        rs = st.executeQuery("SELECT * FROM USERCONF.SENSORLIST WHERE NAME = '" + sensor_name + "' ");

    } catch (SQLException ex) {
        Logger lgr = Logger.getLogger(Records.class.getName());
        lgr.log(Level.SEVERE, ex.getMessage(), ex);
    }
    rs.next();
    int id = rs.getInt("sensor_id");

    String sql_statement;
    if (running.equals("true")) {
        isRunning = "B'1'";
    } else {
        isRunning = "B'0'";
    }

    st = DBcon.createStatement();
    sql_statement = "INSERT INTO USERCONF.LOG_LIST(SENSOR_ID, SMPL_INTERVAL, RUNNING, NAME) " + "VALUES (" + id
            + ", " + smpl_interval + ", " + isRunning + ", " + "'" + name + "'" + " );";
    System.out.println(sql_statement);
    st.clearBatch();
    st = DBcon.createStatement();
    DBcon.createStatement();
    st.executeUpdate(sql_statement);

}

From source file:gentracklets.GenTracklets.java

public static void main(String[] args) throws OrekitException {

    // load the data files
    File data = new File("/home/zittersteijn/Documents/java/libraries/orekit-data.zip");
    DataProvidersManager DM = DataProvidersManager.getInstance();
    ZipJarCrawler crawler = new ZipJarCrawler(data);
    DM.clearProviders();//from  ww w.j  a  v a  2  s .c  om
    DM.addProvider(crawler);

    // Read in TLE elements
    File tleFile = new File("/home/zittersteijn/Documents/TLEs/ASTRA20151207.tle");
    FileReader TLEfr;
    Vector<TLE> tles = new Vector<>();
    tles.setSize(30);

    try {
        // read and save TLEs to a vector
        TLEfr = new FileReader("/home/zittersteijn/Documents/TLEs/ASTRA20151207.tle");
        BufferedReader readTLE = new BufferedReader(TLEfr);

        Scanner s = new Scanner(tleFile);

        String line1, line2;
        TLE2 tle = new TLE2();

        int nrOfObj = 4;
        for (int ii = 1; ii < nrOfObj + 1; ii++) {
            System.out.println(ii);
            line1 = s.nextLine();
            line2 = s.nextLine();
            if (TLE.isFormatOK(line1, line2)) {
                tles.setElementAt(new TLE(line1, line2), ii);
                System.out.println(tles.get(ii).toString());
            } else {
                System.out.println("format problem");
            }

        }
        readTLE.close();

        // define a groundstation
        Frame inertialFrame = FramesFactory.getEME2000();
        TimeScale utc = TimeScalesFactory.getUTC();
        double longitude = FastMath.toRadians(7.465);
        double latitude = FastMath.toRadians(46.87);
        double altitude = 950.;
        GeodeticPoint station = new GeodeticPoint(latitude, longitude, altitude);
        Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
        BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS,
                Constants.WGS84_EARTH_FLATTENING, earthFrame);
        TopocentricFrame staF = new TopocentricFrame(earth, station, "station");

        Vector<Orbit> eles = new Vector<>();
        eles.setSize(tles.size());
        for (int ii = 1; ii < nrOfObj + 1; ii++) {
            double a = FastMath.pow(Constants.WGS84_EARTH_MU / FastMath.pow(tles.get(ii).getMeanMotion(), 2),
                    (1.0 / 3));
            // convert them to orbits
            Orbit kep = new KeplerianOrbit(a, tles.get(ii).getE(), tles.get(ii).getI(),
                    tles.get(ii).getPerigeeArgument(), tles.get(ii).getRaan(), tles.get(ii).getMeanAnomaly(),
                    PositionAngle.MEAN, inertialFrame, tles.get(ii).getDate(), Constants.WGS84_EARTH_MU);

            eles.setElementAt(kep, ii);

            // set up propagators
            KeplerianPropagator kepler = new KeplerianPropagator(eles.get(ii));

            System.out.println("a: " + a);

            // Initial state definition
            double mass = 1000.0;
            SpacecraftState initialState = new SpacecraftState(kep, mass);

            // Adaptive step integrator
            // with a minimum step of 0.001 and a maximum step of 1000
            double minStep = 0.001;
            double maxstep = 1000.0;
            double positionTolerance = 10.0;
            OrbitType propagationType = OrbitType.KEPLERIAN;
            double[][] tolerances = NumericalPropagator.tolerances(positionTolerance, kep, propagationType);
            AdaptiveStepsizeIntegrator integrator = new DormandPrince853Integrator(minStep, maxstep,
                    tolerances[0], tolerances[1]);

            NumericalPropagator propagator = new NumericalPropagator(integrator);
            propagator.setOrbitType(propagationType);

            // set up and add force models
            double AMR = 0.4;
            double crossSection = mass * AMR;
            double Cd = 0.01;
            double Cr = 0.5;
            double Co = 0.8;
            NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(4, 4);
            ForceModel holmesFeatherstone = new HolmesFeatherstoneAttractionModel(
                    FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);
            SphericalSpacecraft ssc = new SphericalSpacecraft(crossSection, Cd, Cr, Co);
            PVCoordinatesProvider sun = CelestialBodyFactory.getSun();
            SolarRadiationPressure srp = new SolarRadiationPressure(sun,
                    Constants.WGS84_EARTH_EQUATORIAL_RADIUS, ssc);

            propagator.addForceModel(srp);
            propagator.addForceModel(holmesFeatherstone);
            propagator.setInitialState(initialState);

            // propagate the orbits with steps size and tracklet lenght at several epochs (tracklets)
            Vector<AbsoluteDate> startDates = new Vector<>();
            startDates.setSize(3);
            startDates.setElementAt(new AbsoluteDate(2015, 12, 8, 20, 00, 00, utc), 0);
            startDates.setElementAt(new AbsoluteDate(2015, 12, 9, 21, 00, 00, utc), 1);
            startDates.setElementAt(new AbsoluteDate(2015, 12, 10, 22, 00, 00, utc), 2);

            double tstep = 30;
            int l = 7;

            for (int tt = 0; tt < startDates.size(); tt++) {

                // set up output file
                String app = "S_" + tles.get(ii).getSatelliteNumber() + "_" + startDates.get(tt) + ".txt";
                //                    FileWriter trackletsOutKep = new FileWriter("/home/zittersteijn/Documents/tracklets/simulated/keplerian/ASTRA/dt1h/AMR040/" + app);
                //                    FileWriter trackletsOutPer = new FileWriter("/home/zittersteijn/Documents/tracklets/simulated/perturbed/ASTRA/dt1h/AMR040/" + app);
                //                    BufferedWriter trackletsKepBW = new BufferedWriter(trackletsOutKep);
                //                    BufferedWriter trackletsPerBW = new BufferedWriter(trackletsOutPer);

                // with formatted output
                File file1 = new File(
                        "/home/zittersteijn/Documents/tracklets/simulated/keplerian/ASTRA/dt1d/AMR040/" + app);
                File file2 = new File(
                        "/home/zittersteijn/Documents/tracklets/simulated/perturbed/ASTRA/dt1d/AMR040/" + app);
                file1.createNewFile();
                file2.createNewFile();
                Formatter fmt1 = new Formatter(file1);
                Formatter fmt2 = new Formatter(file2);

                for (int kk = 0; kk < l; kk++) {
                    AbsoluteDate propDate = startDates.get(tt).shiftedBy(tstep * kk);
                    SpacecraftState currentStateKep = kepler.propagate(propDate);
                    SpacecraftState currentStatePer = propagator.propagate(propDate);

                    System.out.println(currentStateKep.getPVCoordinates().getPosition() + "\t"
                            + currentStateKep.getDate());

                    // convert to RADEC coordinates
                    double[] radecKep = conversions.geo2radec(currentStateKep.getPVCoordinates(), staF,
                            inertialFrame, propDate);
                    double[] radecPer = conversions.geo2radec(currentStatePer.getPVCoordinates(), staF,
                            inertialFrame, propDate);

                    // write the tracklets to seperate files with the RA, DEC, epoch and fence given
                    //                        System.out.println(tles.get(kk).getSatelliteNumber() + "\t" + radec[0] / (2 * FastMath.PI) * 180 + "\t" + currentState.getDate());
                    AbsoluteDate year = new AbsoluteDate(YEAR, utc);
                    fmt1.format("%.12f %.12f %.12f %d%n", radecKep[0], radecKep[2],
                            (currentStateKep.getDate().durationFrom(year) / (24 * 3600)), (tt + 1));
                    fmt2.format("%.12f %.12f %.12f %d%n", radecPer[0], radecPer[2],
                            (currentStateKep.getDate().durationFrom(year) / (24 * 3600)), (tt + 1));

                }
                fmt1.flush();
                fmt1.close();
                fmt2.flush();
                fmt2.close();

            }
        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(GenTracklets.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException iox) {
        Logger.getLogger(GenTracklets.class.getName()).log(Level.SEVERE, null, iox);
    }

}

From source file:sandeep.kb.android.remote.utils.Utils.java

public static String readDataFromFile(String path) {
    String data = null;// www. j  a  v a  2s . c  o m
    try {
        InputStream fileStream = Utils.class.getResourceAsStream(path);
        data = IOUtils.readFully(fileStream);
    } catch (IOException ex) {
        Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
    }
    return data;
}

From source file:controller.NewEntryVideoControllerTest.java

@AfterClass
public static void tearDownClass() {
    String fSeparator = File.separator;
    File file = new File("." + fSeparator + "MyDiaryBook" + fSeparator);
    try {//from   ww w  . j  a  va 2 s. c o  m
        FileUtils.deleteDirectory(file);
    } catch (IOException ex) {
        Logger.getLogger(NewEntryVideoControllerTest.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:emailworkshop.EmailWorkshop.java

public static void exe(ArrayList<Checkin> lista, String emailAutentica, String senhaAutentica,
        String emailRecebe, boolean enviaEmailParticipante) {
    if (emailAutentica.isEmpty() || senhaAutentica.isEmpty()) {
        System.exit(0);/*  w ww.j  a v a2 s .c  om*/
    }
    FileWriter fw = null;
    try {
        fw = new FileWriter("relatorioDeEnvio.txt");
    } catch (IOException ex) {
        Logger.getLogger(EmailWorkshop.class.getName()).log(Level.SEVERE, null, ex);
    }
    int numCert = 2217;
    for (Checkin c : lista) {
        //if ("https://drive.google.com/open?id=0B0LxgGB17-B3aGVNMThsTXpWV0E".equals(c.getQrCode())) {
        gerarPDF(c.getNome(), numCert);
        try {
            if (!emailRecebe.isEmpty()) {
                enviaEmailComAnexo(emailAutentica, senhaAutentica, emailRecebe, c.getNome());
                System.out.println("certificado de " + c.getNome() + " gerado!");

                try {

                    fw.write("certificado de " + c.getNome() + " gerado!\n");

                } catch (IOException ex) {
                    Logger.getLogger(EmailWorkshop.class.getName()).log(Level.SEVERE, null, ex);
                }

            }
            if (enviaEmailParticipante) {
                System.out.println("envia email para " + c.getNome());
                enviaEmailComAnexo(emailAutentica, senhaAutentica, c.getEmail(), c.getNome());
            }
            //avisoDeEnvio(c.getNome());
        } catch (EmailException ex) {
            Logger.getLogger(EmailWorkshop.class.getName()).log(Level.SEVERE, null, ex);
        }

        //}
        numCert = numCert + 1;
    }
    try {
        fw.close();
    } catch (IOException ex) {
        Logger.getLogger(EmailWorkshop.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:local.Statistics.LessSellCars.java

/**
 * @param args the command line arguments
 *//*w  w  w.j  a v  a 2s .  c o m*/
public static void carrosMenosVendidos() {
    Graficas_DAO gr = new Graficas_DAO();
    ResultSet rs = gr.getgraficaautomas();
    try {
        String nameAuto;
        int quantitySales;
        DefaultPieDataset data = new DefaultPieDataset();
        while (rs.next()) {
            nameAuto = rs.getString(3);
            quantitySales = rs.getInt(1);
            data.setValue(nameAuto, quantitySales);
        }
        JFreeChart chart = ChartFactory.createPieChart("GRAFICAS AUTOS MENOS VENDIDOS", data, true, true,
                false);
        ChartFrame frame = new ChartFrame("Autos menos vendidos", chart);
        frame.pack();
        frame.setVisible(true);
        rs.close();
        gr.close();
    } catch (SQLException ex) {
        Logger.getLogger(LessSellCars.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.quangphuong.crawler.dbutil.DBHandler.java

public static Connection openConnection() {
    try {//from  w w w  .  j av a2  s  . co m
        Class.forName("com.mysql.jdbc.Driver");
        boolean isDebug = System.getenv("OPENSHIFT_APP_NAME") == null;
        DBConfig dBConfig;
        if (isDebug) {
            dBConfig = new DBConfig(DBConstant.driver, DBConstant.host, DBConstant.port, DBConstant.schema,
                    DBConstant.user, DBConstant.password);
        } else {
            dBConfig = new DBConfig(DBConstant.driver, DBConstant.OPENSHIFT_HOST, DBConstant.OPENSHIFT_PORT,
                    DBConstant.schema, DBConstant.OPENSHIFT_USER, DBConstant.OPENSHIFT_PASSWORD);
        }
        System.out.println("COnnection str: " + dBConfig.toString());
        Connection connection = DriverManager.getConnection(dBConfig.toString(), dBConfig.getUser(),
                dBConfig.getPassword());

        return connection;
    } catch (Exception ex) {
        Logger.getLogger(DBConfig.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}

From source file:app.Mysqlconector.java

public static void liberaConexion(Connection conexion) {
    try {//from  www  .  j a va 2 s.co m
        // En realidad no cierra, solo libera la conexion.
        conexion.close();
    } catch (SQLException ex) {
        Logger.getLogger(Mysqlconector.class.getName()).log(Level.SEVERE, null, ex);
    }

    //   conexion=null;
}

From source file:com.oic.connection.Connections.java

public synchronized static void removeConnection(WebSocketListener webSocketListener) {
    synchronized (userConnections) {
        try {//  w  w w.j  av  a  2s .co m
            webSocketListener.getSession().close();
        } catch (IOException ex) {
            Logger.getLogger(Connections.class.getName()).log(Level.WARNING, null, ex);
        }
        userConnections.remove(webSocketListener);
    }
}