import it.acxent.contab.Documento; import it.acxent.contab.DocumentoCR; import it.acxent.db.ApplParm; import it.acxent.db.ApplParmFull; import it.acxent.db.ResParm; import it.acxent.util.DbConsole; import it.acxent.util.Vectumerator; import java.sql.Time; import java.util.StringTokenizer; public class TestMysql8 extends DbConsole { public static void main(String[] args) { TestMysql8 bean = new TestMysql8(); bean.doImport(); System.exit(0); } public void doImport() { String db = "cc"; int i = 0; int se1 = 10; int se2 = 100; String hostname = "localhost"; 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 apTarget57 = new ApplParmFull(new ApplParm(3, "//" + hostname + "/" + db, "cc", "root", "root", 1, 10, 300)); ApplParmFull apTarget8 = new ApplParmFull(new ApplParm(17, "//" + hostname + ":3308/" + db, db, "root", "root", 1, 10, 300)); apTarget57.setDebug(false); apTarget8.setDebug(false); StringBuffer msg = new StringBuffer(); try { Documento bean = new Documento(apTarget57); bean.findByPrimaryKey(2306L); System.out.println(bean.getDescRecordHeader()); System.out.println(bean.getDescRecordLine()); System.out.println("" + bean.getId_documento() + " " + bean.getId_documento()); ResParm rp = bean.save(); System.out.println(rp.getMsg()); Vectumerator vec = bean.findByCR(new DocumentoCR(), 1, 10); System.out.println(bean.getDescRecordHeader()); while (vec.hasMoreElements()) { Documento row = (Documento)vec.nextElement(); System.out.println(row.getDescRecordLine()); } } 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; } } }