Advertisement
Guest User

updatependapatan

a guest
Jan 27th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. package routines;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.Statement;
  6.  
  7. /*
  8. * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
  9. * it must be before the "{talendTypes}" key.
  10. *
  11. * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
  12. * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
  13. * Short
  14. *
  15. * 3. {Category} define a category for the Function. it is required. its value is user-defined .
  16. *
  17. * 4. {param} 's format is: {param} <type>[(<default value or closed list values>)] <name>[ : <comment>]
  18. *
  19. * <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'s value is the
  20. * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
  21. * added. you can have many parameters for the Function.
  22. *
  23. * 5. {example} gives a example for the Function. it is optional.
  24. */
  25. public class updatePendapatan {
  26.  
  27. /**
  28. * helloExample: not return value, only print "hello" + message.
  29. *
  30. *
  31. * {talendTypes} String
  32. *
  33. * {Category} User Defined
  34. *
  35. * {param} string("world") input: The string need to be printed.
  36. *
  37. * {example} helloExemple("world") # hello world !.
  38. */
  39. public static void helloExample(String message) {
  40. if (message == null) {
  41. message = "World"; //$NON-NLS-1$
  42. }
  43. System.out.println("Hello " + message + " !"); //$NON-NLS-1$ //$NON-NLS-2$
  44. }
  45.  
  46. /**
  47. * kodeSkrd: return skrd.
  48. *
  49. *
  50. * {talendTypes} String
  51. *
  52. * {Category} User Defined
  53. *
  54. * {param} string("20461611000022;02;000000300000") input: The string need to be printed.
  55. *
  56. * {example} kodeSkrd("20461611000022;02;000000300000") # 20461611000022;02;000000300000.
  57. */
  58. public static String update(String kode){
  59.  
  60. String[] array = kode.split("\\;");
  61. String ntpd = array[0];
  62. String bank = array[2];
  63. String channel = array[3];
  64. String datetime = array[4];
  65. String[] parentKode = array[1].split("\\,");
  66.  
  67. System.out.println("NTPD"+ntpd);
  68. System.out.println(bank);
  69. System.out.println(channel);
  70. try{
  71. Class.forName("com.mysql.jdbc.Driver");
  72. Connection con=DriverManager.getConnection(
  73. "jdbc:mysql://10.15.34.159:3306/masterpendapatan","admin2","dki123@");
  74.  
  75. if(parentKode == null){
  76. String kode_penetapan = array[1];
  77. Statement stmt=con.createStatement();
  78. stmt.execute("update pendapatan set ntpd = '" + ntpd + "', bank = '" + bank + "', channel ='" + channel + "', tgl_bayar ='" + datetime + "', status = 'Dibayar' where kode_penetapan = '" + kode_penetapan + "'");
  79. }else{
  80. for(String s: parentKode){
  81. System.out.println(s);
  82. Statement stmt=con.createStatement();
  83. stmt.execute("update pendapatan set ntpd = '" + ntpd + "', bank = '" + bank + "', channel ='" + channel + "', tgl_bayar ='" + datetime + "', status = 'Dibayar' where kode_penetapan = '" + s + "'");
  84. }
  85. }
  86.  
  87. con.close();
  88. }catch(Exception e){ System.out.println(e);}
  89. return kode;
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement