Run GlassFish as a Service in Windows
https://blogs.oracle.com/foo/entry/automatic_starting_of_servers_in
asadmin create-service
sharing some tech problems and soln
https://blogs.oracle.com/foo/entry/automatic_starting_of_servers_in
asadmin create-service
Posted by Sajjad at 1:07 am 0 comments
Labels: GlassFish
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fileapp;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.logging.XMLFormatter;
/**
*
* @author sajjad
*/
public class MyLog {
/**
* @param args the command line arguments
*/
private final static Logger LOGGER = Logger.getLogger(FileApp.class.getName());
public static void main(String[] args) throws IOException {
// LOGGER.setLevel(Level.INFO);
Calendar now = GregorianCalendar.getInstance();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String file=dateFormat.format(date)+".log";
file="c:/data_log/"+file;
Handler handler;
handler = new FileHandler(file,true);
handler.setFormatter(new SimpleFormatter() );
LOGGER.addHandler(handler);
LOGGER.addHandler(new ConsoleHandler());
LOGGER.info("Our first logging message");
LOGGER.severe("Something terrible happened");
}
}
Posted by Sajjad at 6:02 am 0 comments
Labels: Java
in jsf page
<f:metadata>
<f:viewParam name="id" value="#{testBean.val}" />
</f:metadata>
in managed bean
public void setVal(String val) throws IOException {
System.out.println("Value Set"+ new Date());
if(val.startsWith("1"))
FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml");
else
FacesContext.getCurrentInstance().getExternalContext().dispatch("/bar.xhtml");
this.val = val;
}
Posted by Sajjad at 3:28 pm 0 comments
Labels: JSF
CREATE OR REPLACE FUNCTION date_null(
iv_number IN DATE,dt IN DATE)
RETURN integer
IS
d integer;
BEGIN
IF iv_number is NULL THEN d :=1;
ELSE
d :=2;
END IF ;
RETURN d;
END;
Posted by Sajjad at 12:06 am 0 comments
function definition
CREATE OR REPLACE FUNCTION larger_date(
iv_number IN DATE,dt IN DATE)
RETURN DATE IS
d date;
BEGIN
IF iv_number > dt THEN d :=iv_number -7;
ELSE
d :=dt;
END IF ;
RETURN d;
END;
How to call in SQL
SELECT larger_date
Posted by Sajjad at 11:43 pm 0 comments
Labels: PL/SQL
Posted by Sajjad at 7:33 pm 1 comments
Labels: Oracle, tnsnames.ora
XMLGregorianCalendar xgc=DatatypeFactory.newInstance().newXMLGregorianCalendarDate(year, month, day, timezone);
Posted by Sajjad at 7:36 pm 0 comments
Labels: Java, XMLGregorianCalendar
Query q=em.createQuery("select sum(o.montant) from Operation o join
o.codTransac t join o.codCaisse c where (t.sens='D')and
(c.dateCaisse=o.dateOp)");
Query q = em.createQuery("DELETE FROM Subscription s WHERE s.subscriptionDate < :today");
q.setParameter("today", new Date());
int deleted = q.executeUpdate();
Date now = new Date();
Date thirtyDaysAgo = new Date(now.getTime() - (30 * MS_IN_DAY));
Query q = em.createQuery("Select m from Message m "
+ "where m.targetTime < :now and m.targetTime > :thirtyDays");
q.setParameter("now", now);
q.setParameter("thirtyDays", thirtyDaysAgo);
List<Message> results = (List<Message>) q.getResultList();
Posted by Sajjad at 10:17 pm 0 comments
Labels: JPA
Posted by Sajjad at 4:45 pm 0 comments
Labels: JSF
FacesContext facesContext = FacesContext.getCurrentInstance();
NeededBean neededBean
= (NeededBean)facesContext.getApplication()
.createValueBinding("#{neededBean}").getValue(facesContext);
Posted by Sajjad at 1:52 pm 0 comments
Labels: JSF, managed bean