Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package routines;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- /*
- * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
- * it must be before the "{talendTypes}" key.
- *
- * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
- * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
- * Short
- *
- * 3. {Category} define a category for the Function. it is required. its value is user-defined .
- *
- * 4. {param} 's format is: {param} <type>[(<default value or closed list values>)] <name>[ : <comment>]
- *
- * <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'s value is the
- * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
- * added. you can have many parameters for the Function.
- *
- * 5. {example} gives a example for the Function. it is optional.
- */
- public class updatePendapatan {
- /**
- * helloExample: not return value, only print "hello" + message.
- *
- *
- * {talendTypes} String
- *
- * {Category} User Defined
- *
- * {param} string("world") input: The string need to be printed.
- *
- * {example} helloExemple("world") # hello world !.
- */
- public static void helloExample(String message) {
- if (message == null) {
- message = "World"; //$NON-NLS-1$
- }
- System.out.println("Hello " + message + " !"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- /**
- * kodeSkrd: return skrd.
- *
- *
- * {talendTypes} String
- *
- * {Category} User Defined
- *
- * {param} string("20461611000022;02;000000300000") input: The string need to be printed.
- *
- * {example} kodeSkrd("20461611000022;02;000000300000") # 20461611000022;02;000000300000.
- */
- public static String update(String kode){
- String[] array = kode.split("\\;");
- String ntpd = array[0];
- String bank = array[2];
- String channel = array[3];
- String datetime = array[4];
- String[] parentKode = array[1].split("\\,");
- System.out.println("NTPD"+ntpd);
- System.out.println(bank);
- System.out.println(channel);
- try{
- Class.forName("com.mysql.jdbc.Driver");
- Connection con=DriverManager.getConnection(
- "jdbc:mysql://10.15.34.159:3306/masterpendapatan","admin2","dki123@");
- if(parentKode == null){
- String kode_penetapan = array[1];
- Statement stmt=con.createStatement();
- stmt.execute("update pendapatan set ntpd = '" + ntpd + "', bank = '" + bank + "', channel ='" + channel + "', tgl_bayar ='" + datetime + "', status = 'Dibayar' where kode_penetapan = '" + kode_penetapan + "'");
- }else{
- for(String s: parentKode){
- System.out.println(s);
- Statement stmt=con.createStatement();
- stmt.execute("update pendapatan set ntpd = '" + ntpd + "', bank = '" + bank + "', channel ='" + channel + "', tgl_bayar ='" + datetime + "', status = 'Dibayar' where kode_penetapan = '" + s + "'");
- }
- }
- con.close();
- }catch(Exception e){ System.out.println(e);}
- return kode;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement