|
Date and Calendar parameter values require special methods in order
to specify what they represent, such as a pure date, a pure time or a
combination of date and time, as explained in detail in the Date and
Time (Temporal) Types section
For example, the following invocation passes a Date object as a pure date (no time): Query query = em.createQuery("Select f From usuarios f where f.fecha=:date");
and timestamp
|
Monday, November 30, 2015
JPA select query with timestamp and date fields fail to retrieve results
Cuando necesitemos hacer consultas con dates, tipo date, y timestamp se hace asi:
JSF How to redirect from backing bean to a URL dynamically constructed in the backing bean - Redirijir Url desde Mangedbean a otra pagina web
Cuando necesitamos redirigir dedesde MangedBean hacia cualquier otra pagina web hacemos lo siguiente
ExternalContext context2 = FacesContext.getCurrentInstance().getExternalContext();
try {
context2.redirect(context2.getRequestContextPath() +"http://www.google.com");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ExternalContext context2 = FacesContext.getCurrentInstance().getExternalContext();
try {
context2.redirect(context2.getRequestContextPath() +"http://www.google.com");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Wildfly Conectividad con MYSQL DRIVER
Cuando se necesite cargar driver MYSQL con wildfly creamos una carpeta dentro de wildfly-9.0.1.Final/modules/system/layers/base/com
la carpeta que creemos alli la nombramos mysql y dentro otra carpeta llamada main, dentro de main creamos un archivo .xml y dentro de este archivo colocamos
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.23-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
descargamos el jar mysql-connector-java-5.1.23-bin.jar o la version actual que este en el momento y la dejamos en esa carpeta asi:

Luego nos dirijimos a wildfly-9.0.1.Final/standalone/configuration/ y abrimos el archivo standalone.xml y dentro del bloque driver que aparace asi
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
vamos a dejarlo asi:
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysqlDriver" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
</driver>
</drivers>
Reiniciamos servidor Jboss wildfly y ya estamos listos para agregar datasources de mysql al servidor por medio de jndi
la carpeta que creemos alli la nombramos mysql y dentro otra carpeta llamada main, dentro de main creamos un archivo .xml y dentro de este archivo colocamos
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.23-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
descargamos el jar mysql-connector-java-5.1.23-bin.jar o la version actual que este en el momento y la dejamos en esa carpeta asi:
Luego nos dirijimos a wildfly-9.0.1.Final/standalone/configuration/ y abrimos el archivo standalone.xml y dentro del bloque driver que aparace asi
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
vamos a dejarlo asi:
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysqlDriver" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
</driver>
</drivers>
Reiniciamos servidor Jboss wildfly y ya estamos listos para agregar datasources de mysql al servidor por medio de jndi
Web Access WildFly
SI necesitamos tener acceso libre de la red hacia wildfly
By default, you will be able to access Wildfly via web only on your local system, by browsing to:
http://localhost:8090 [or any port that you have previously configured]
If you need access from outside, you must locate the following in standalone.xml:
And change that to:
By default, you will be able to access Wildfly via web only on your local system, by browsing to:
http://localhost:8090 [or any port that you have previously configured]
If you need access from outside, you must locate the following in standalone.xml:
1 2 3 4 5 6 | <interface name="management"> <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> </interface> <interface name="public"> <inet-address value="${jboss.bind.address:127.0.0.1}"/> </interface>
|
1 2 3 4 5 6 | <interface name="management"> <any-address/> </interface> <interface name="public"> <any-address/> </interface> |
Configurar Wilf Fly en Linux UBUNTU como servicio
Cando se necesita configurar wildfly como servidor y como servicio para que inicie automaticamente la app, se realizan los siguientes pasos:
1: Aderir usuario wildfly
2: Aderir grupo wildfly
copiar el archivo wildlfly-xxx.zip a /opt, descomprimir alli, renombrar la carpeta como wildfly
3: darle propiedad al usuario wildfly y grupo wildfly a la carpeta wildlfy asi:
chown -R wildfly:wildlfy /opt/wildfly
To run Wildfly you can simply execute the standalone.sh script located at:
This is a pretty straightforward approach and it does not require any configuration.
If you need Wildfly to run in the background (and maybe at system startup), you must install Wildfly as a service:
Copy wildfly.conf to /etc/default/ and change the name to wildfly
Edit this file to set your own configurations, they will be discarded by default because of the #.
You need to set some values, for example, JAVA_HOME must be set to where you have Java installed, JBOSS_USER (default: wildfly) must be set to the user who will be running Wildfly and who owns the main directory, JBOSS_HOME (default: /opt/widlfly) is the main directory where you have placed the installation files, JBOSS_CONSOLE_LOG is where logs will be stored (make sure the user have write access to this file).
Now you need to copy the wildfly-init-debian.sh to /etc/init.d and rename it to wildfly.
And this is enough to install Wildfly as a service, to run the service, simply execute:
1: Aderir usuario wildfly
2: Aderir grupo wildfly
copiar el archivo wildlfly-xxx.zip a /opt, descomprimir alli, renombrar la carpeta como wildfly
3: darle propiedad al usuario wildfly y grupo wildfly a la carpeta wildlfy asi:
chown -R wildfly:wildlfy /opt/wildfly
To run Wildfly you can simply execute the standalone.sh script located at:
1 | [WILDFLY_INSTALLATION_DIRECTORY]/bin/standalone.sh |
If you need Wildfly to run in the background (and maybe at system startup), you must install Wildfly as a service:
Copy wildfly.conf to /etc/default/ and change the name to wildfly
cp [WILDFLY_INSTALLATION_DIRECTORY]/bin/init.d/wildfly.conf /etc/default/wildfly |
You need to set some values, for example, JAVA_HOME must be set to where you have Java installed, JBOSS_USER (default: wildfly) must be set to the user who will be running Wildfly and who owns the main directory, JBOSS_HOME (default: /opt/widlfly) is the main directory where you have placed the installation files, JBOSS_CONSOLE_LOG is where logs will be stored (make sure the user have write access to this file).
Now you need to copy the wildfly-init-debian.sh to /etc/init.d and rename it to wildfly.
cp [WILDFLY_INSTALLATION_DIRECTORY]/bin/init.d/wildfly-init-debian.sh /etc/init.d/wildfly |
service wildfly start Hasta este punto ya debemos de tener el servicio de wildfly corriendo, ahora para poder hacer que autoinicie cada vez que el servidor se encienda se debe de correr:
y con esto ya tendriamos Wildfly rodando cada vez que el servidor se reinicie Para remover el Servicio de autoestarte se coloca
|
Sunday, November 29, 2015
7-Zip command to create and extract a password-protected ZIP file on Linux
Cuando necesitemos de comprimir archivos protegidos usando zip
zip -P password -r encrypted.zip folderIWantToZip
para descomprimir
unzip -P password encrypted.zip
Para descomprimir usando 7z usamos
7z a secure.7z * -pSECRET
Donde
7z: name and path of 7-Zip executable
a: add to archive
secure.7z: name of destination archive
*: add all files from current directory to destination archive
-pSECRET: specify the password "SECRET"
How to get current timestamp in java - Obtener Timestamp tiempo actual en JAVA
La forma de convertir la fecha actual a timestamp es la siguiente
Date date= new Date(); //getTime() returns current time in milliseconds long time = date.getTime(); //Passed the milliseconds to constructor of Timestamp class Timestamp ts = new Timestamp(time); System.out.println("Current Time Stamp: "+ts);