1 package ist.coach.coachEmfServices.EmfBasicLog; 2 3 import java.sql.*; 4 import org.omg.CORBA.Any ; 5 import org.omg.CORBA.TCKind ; 6 7 public class AnyTypeTrans 8 { 9 10 11 12 public int toDB(PreparedStatement dbStatement, int position, Any anyParam) 13 { 14 TCKind J = null; 15 16 try 17 { 18 if ((anyParam.type()).kind() == TCKind.tk_string) { 19 dbStatement.setString(position, anyParam.extract_string()); 20 J = TCKind.tk_string; 21 } 22 if ((anyParam.type()).kind() == TCKind.tk_boolean) { 23 dbStatement.setBoolean(position, anyParam.extract_boolean()); 24 J = TCKind.tk_boolean; 25 } 26 if ((anyParam.type()).kind() == TCKind.tk_double) { 27 dbStatement.setDouble(position, anyParam.extract_double()); 28 J = TCKind.tk_double; 29 } 30 if ((anyParam.type()).kind() == TCKind.tk_float) { 31 dbStatement.setFloat(position, anyParam.extract_float()); 32 J = TCKind.tk_float; 33 } 34 if ((anyParam.type()).kind() == TCKind.tk_ulong) { 35 dbStatement.setInt(position, anyParam.extract_ulong()); 36 J = TCKind.tk_ulong; 37 } 38 if ((anyParam.type()).kind() == TCKind.tk_long) { 39 dbStatement.setInt(position, anyParam.extract_long()); 40 J = TCKind.tk_long; 41 } 42 if ((anyParam.type()).kind() == TCKind.tk_short) { 43 dbStatement.setShort(position, anyParam.extract_short()); 44 J = TCKind.tk_short; 45 } 46 } 47 catch (Exception ex) 48 { 49 System.out.println("** AnyTypeTrans: <EXCEPTION> While putting data in the PreparedStatement"); 50 System.out.println(ex.getMessage()); 51 } 52 53 return J.value(); 54 55 } 57 58 59 60 61 public Any fromDB(ResultSet rs, int L, int rsPosition) { 62 63 org.omg.CORBA.TCKind K = null; 64 65 K = TCKind.from_int(L); 66 67 Any res = org.objectweb.ccm.CORBA.TheORB.getORB().create_any(); 68 69 try 70 { 71 if (K == TCKind.tk_string ) { 72 String A = rs.getString(rsPosition); 73 res.insert_string(A); 74 } 75 76 if (K == TCKind.tk_boolean ) { 77 boolean B = rs.getBoolean(rsPosition); 78 res.insert_boolean(B); 79 } 80 if (K == TCKind.tk_double ) { 81 double C = rs.getDouble(rsPosition); 82 res.insert_double(C); 83 } 84 if (K == TCKind.tk_float ) { 85 float D = rs.getFloat(rsPosition); 86 res.insert_float(D); 87 } 88 if (K == TCKind.tk_ulong ) { 89 int E = rs.getInt(rsPosition); 90 res.insert_ulong(E); 91 } 92 if (K == TCKind.tk_long ) { 93 int F = rs.getInt(rsPosition); 94 res.insert_long(F); 95 } 96 if (K == TCKind.tk_short ) { 97 short G = rs.getShort(rsPosition); 98 res.insert_short(G); 99 } 100 } 101 catch(Exception ex) 102 { 103 System.err.println("** AnyTypeTrans: <EXCEPTION> While getting data from the ResultSet"); 104 System.err.println(ex.getMessage()); 105 106 } 107 108 return res; 109 110 } 112 } | Popular Tags |