73 lines
2.5 KiB
Java
73 lines
2.5 KiB
Java
package it.acxent.face.fr;
|
|
|
|
import it.acxent.db.ApplParm;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.DBAdapter;
|
|
import it.acxent.util.DbConsole;
|
|
import java.sql.Time;
|
|
import java.util.StringTokenizer;
|
|
|
|
public class Test extends DbConsole {
|
|
public static void main(String[] args) {
|
|
Test bean = new Test();
|
|
bean.doImport();
|
|
System.exit(0);
|
|
}
|
|
|
|
public void doImport() {
|
|
String db = "fr";
|
|
int i = 0;
|
|
int se1 = 10;
|
|
int se2 = 100;
|
|
String hostname = "localhost:3308";
|
|
String temp = getCi().readLine("Hostname (" + hostname + "):");
|
|
if (!temp.isEmpty())
|
|
hostname = temp;
|
|
temp = getCi().readLine("Database name (" + db + "):");
|
|
if (!temp.isEmpty())
|
|
db = temp;
|
|
System.out.println("Db: " + db);
|
|
ApplParmFull apTarget = new ApplParmFull(new ApplParm(3, "//" + hostname + "/" + db, "root", "root", 1, 10, 300));
|
|
apTarget.setDebug(false);
|
|
StringBuffer msg = new StringBuffer();
|
|
try {
|
|
FotoRequest bean = new FotoRequest(apTarget);
|
|
bean.findByPrimaryKey(28402L);
|
|
String json = bean.getJson();
|
|
System.out.println(json.length());
|
|
System.out.println(json);
|
|
String jc = DBAdapter.compressText(json);
|
|
System.out.println(jc.length());
|
|
String ja = DBAdapter.decompressText(jc);
|
|
System.out.println(ja.length());
|
|
System.out.println(ja);
|
|
bean.save();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
protected Time getTimeFromString(String theTime) {
|
|
try {
|
|
if (theTime.matches("[0-9][0-9][0-9][0-9]"))
|
|
theTime = theTime.substring(0, 2) + ":" + theTime.substring(0, 2);
|
|
if (theTime.matches("[0-9]{1,2}+:[0-9]{1,2}+")) {
|
|
StringTokenizer st = new StringTokenizer(theTime, ":");
|
|
int hour = Integer.parseInt(st.nextToken());
|
|
int min = Integer.parseInt(st.nextToken());
|
|
int sec = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
|
|
return new Time((long)((hour - 1) * 3600000 + min * 60000 + sec * 1000));
|
|
}
|
|
if (theTime.matches("[0-9]{1,2}+:[0-9]{1,2}+:[0-9]{1,2}+")) {
|
|
StringTokenizer st = new StringTokenizer(theTime, ":");
|
|
int hour = Integer.parseInt(st.nextToken());
|
|
int min = Integer.parseInt(st.nextToken());
|
|
int sec = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
|
|
return new Time((long)((hour - 1) * 3600000 + min * 60000 + sec * 1000));
|
|
}
|
|
return null;
|
|
} catch (Exception e) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|