Un piccolo script .bat per cancellare tutti i file più vecchi di una certa data:
set log_path="c:\tomcat\logs"
set numDays= 7
forfiles /p %logPath% /s /d -%numDays% /c "cmd /c del @FILE"
set log_path="c:\tomcat\logs"
set numDays= 7
forfiles /p %logPath% /s /d -%numDays% /c "cmd /c del @FILE"
package it.rowsetTest; import java.sql.Connection; import java.sql.DriverManager; import javax.sql.rowset.WebRowSet; import com.sun.rowset.WebRowSetImpl; public class XmlRowSet { public static void main(String[] args) throws Exception { String urlConn=""; WebRowSet p= new WebRowSetImpl(); String select="select top 5 id,descrizione from S_ATECO2007"; p.setCommand(select); p.setUrl("jdbc:sqlserver://127.0.0.1:1433;databaseName=test;selectMethod=cursor"); p.setUsername("test"); p.setPassword("test"); p.execute(); java.io.FileOutputStream oStream =new java.io.FileOutputStream("test.xml"); p.writeXml(oStream); } }
<?xml version="1.0"?>
<webRowSet xmlns="http://java.sun.com/xml/ns/jdbc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jdbc http://java.sun.com/xml/ns/jdbc/webrowset.xsd">
<properties>
<command>select top 5 id,descrizione from S_ATECO2007</command>
<concurrency>1008</concurrency>
<datasource><null/></datasource>
<escape-processing>true</escape-processing>
<fetch-direction>1000</fetch-direction>
<fetch-size>0</fetch-size>
<isolation-level>2</isolation-level>
<key-columns>
</key-columns>
<map>
</map>
<max-field-size>0</max-field-size>
<max-rows>0</max-rows>
<query-timeout>0</query-timeout>
<read-only>true</read-only>
<rowset-type>ResultSet.TYPE_SCROLL_INSENSITIVE</rowset-type>
<show-deleted>false</show-deleted>
<table-name>S_ATECO2007</table-name>
<url>jdbc:sqlserver:gianos_professionisti</url>
<sync-provider>
<sync-provider-name>com.sun.rowset.providers.RIOptimisticProvider</sync-provider-name>
<sync-provider-vendor>Oracle Corporation</sync-provider-vendor>
<sync-provider-version>1.0</sync-provider-version>
<sync-provider-grade>2</sync-provider-grade>
<data-source-lock>1</data-source-lock>
</sync-provider>
</properties>
<metadata>
<column-count>2</column-count>
<column-definition>
<column-index>1</column-index>
<auto-increment>true</auto-increment>
<case-sensitive>false</case-sensitive>
<currency>false</currency>
<nullable>0</nullable>
<signed>true</signed>
<searchable>true</searchable>
<column-display-size>11</column-display-size>
<column-label>id</column-label>
<column-name>id</column-name>
<schema-name></schema-name>
<column-precision>10</column-precision>
<column-scale>0</column-scale>
<table-name>S_ATECO2007</table-name>
<catalog-name></catalog-name>
<column-type>4</column-type>
<column-type-name>int</column-type-name>
</column-definition>
<column-definition>
<column-index>2</column-index>
<auto-increment>false</auto-increment>
<case-sensitive>false</case-sensitive>
<currency>false</currency>
<nullable>1</nullable>
<signed>false</signed>
<searchable>true</searchable>
<column-display-size>250</column-display-size>
<column-label>descrizione</column-label>
<column-name>descrizione</column-name>
<schema-name></schema-name>
<column-precision>250</column-precision>
<column-scale>0</column-scale>
<table-name>S_ATECO2007</table-name>
<catalog-name></catalog-name>
<column-type>12</column-type>
<column-type-name>varchar</column-type-name>
</column-definition>
</metadata>
<data>
<currentRow>
<columnValue>1</columnValue>
<columnValue>AGRICOLTURA, SILVICOLTURA E PESCA </columnValue>
</currentRow>
<currentRow>
<columnValue>2</columnValue>
<columnValue>COLTIVAZIONI AGRICOLE E PRODUZIONE DI PRODOTTI ANIMALI, CACCIA E SERVIZI CONNESSI </columnValue>
</currentRow>
<currentRow>
<columnValue>3</columnValue>
<columnValue>COLTIVAZIONE DI COLTURE AGRICOLE NON PERMANENTI </columnValue>
</currentRow>
<currentRow>
<columnValue>4</columnValue>
<columnValue>Coltivazione di cereali (escluso il riso), legumi da granella e semi oleosi </columnValue>
</currentRow>
<currentRow>
<columnValue>5</columnValue>
<columnValue>Coltivazione di cereali (escluso il riso) </columnValue>
</currentRow>
</data>
</webRowSet>
package it.threads;
import java.util.concurrent.Callable;
public class OperazioneAsincrona implements Callable<String> {
@Override
public String call() throws Exception {
System.out.println("Simulo lavorazione.....");
Thread.sleep(3000);
return "Lavorazione eseguita.....";
}
}
package it.threads;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class OperazioneAsincronaTest {
public static void main(String[] args) throws InterruptedException, ExecutionException {
Callable<String> task=new OperazioneAsincrona();
ExecutorService es=Executors.newSingleThreadExecutor();
Future<String> f=es.submit(task);
System.out.println(f.get());
System.out.println("Esco dall'executor...");
es.shutdown();
}
}
package it.threads;
public class ClassicIntTest extends Thread {
private static Integer intero=new Integer(0);
public void run(){
System.out.println("CLASSICO: Incremento
e recupero il valore "+ ++intero);
}
}
public static void main(String[] args) {
for(int i=0;i<10;i++){
new ClassicIntTest().start();
}
}
package it.threads;
import java.util.concurrent.atomic.AtomicInteger;
public class AtomicIntTest extends Thread {
private static AtomicInteger intero=new AtomicInteger(0);
public void run(){
System.out.println("ATOMIC: Incrementa e recupera il valore "+intero.incrementAndGet());
}
}
document.getElementById(event.target.id).innerHTML+="<br />";
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form >
<textarea id="prova" rows="10" cols="50"></textarea>
</form>
</body>
<script>
document.getElementById("prova").addEventListener("keydown",test,false);
function test(e) {
if (e.keyCode == 13 && e.target=="[object HTMLTextAreaElement]" ) {
document.getElementById(event.target.id).innerHTML+="<br />";
e.preventDefault();
return false;
}
}
</script>
</html>
public static String getRappresentazioneStringa(Object o) throws Exception{
StringBuffer sb=new StringBuffer();
Method[] listaMetodi= o.getClass().getMethods();
for(int i=0;i<listaMetodi.length;i++){
Method m=listaMetodi[i];
if(m.getName().startsWith("get") && !"getClass".equals(m.getName())){
// è un getter stampo il valore
sb.append(m.getName().substring(3).toUpperCase());
sb.append(" = ");
sb.append(m.invoke(o)!=null?m.invoke(o).toString():"");
sb.append("#");
}
}
return sb.toString();
}