You are not logged in.

Unanswered posts



Important! This site has been replaced. All content here is read-only. Please visit our brand-new community at https://community.talend.com/. We look forward to hearing from you there!



#1 2016-11-27 16:31:07

Daywalker
Member
4 posts

Daywalker said:

DQ With TJava

Already i have a problem, with the tjava, i cant create  a class into the tjava, cuz already i need validate if(that row are the same && other is false) for that operation already  make a array of object but didnt work appear the following problem


Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
	Illegal modifier for the local class Client; only abstract or final is permitted
	Illegal modifier for the local class started; only abstract or final is permitted
	migration.Client cannot be resolved to a type
	migration.Client cannot be resolved to a type
	The method main cannot be declared static; static methods can only be declared in a static or top level type
	Invalid character constant

this is the code into the tjava:

public class Client{
    long id=0,city=0,user_id=0;
    int identification=0;
    String name="",last_name="",phone="",phone2="",email="",email2="",address="",state="",liner="",clouser_name="",observation="";
    Date created_at,updated_at,deleted_at;
    public Client(long id, int identification,String name,String last_name, String phone, String phone2, String email, String email2, String address, String state, String liner, String clouser_name, long city, long user_id,Date created_at,Date updated_at,String observation, Date deleted_at) {
        this.id = id;
        this.identification = identification;
        this.name = name;
        this.last_name = last_name;
        this.phone = phone;
        this.phone2 = phone2;
        this.email = email;
        this.email2 = email2;
        this.address = address;
        this.state = state;
        this.liner = liner;
        this.clouser_name = clouser_name;
        this.city = city;
        this.user_id = user_id;
        this.created_at = created_at;
        this.updated_at = updated_at;
        this.observation = observation;
        this.deleted_at = deleted_at;
    }
}

public class started{
migration.Client[] clientArray = new migration.Client[7668];
int count=1;
public static void main(String args[]){
long id=globalMap.get('row1.id'),city=globalMap.get('row1.city'),user_id=globalMap.get('row1.user_id');
int identification=globalMap.get('row1.identification');
String name=globalMap.get('row1.name'),last_name=globalMap.get('row1.last_name'),phone=globalMap.get('row1.phone'),phone2=globalMap.get('row1.phone2'),email=globalMap.get('row1.email'),email2=globalMap.get('row1.email2'),address=globalMap.get('row1.address'),state=globalMap.get('row1.state'),liner=globalMap.get('row1.liner_name'),clouser_name=globalMap.get('row1.clouser_name'),observation=globalMap.get('row1.observation');
Date created_at=globalMap.get('row1.created_at'),updated_at=globalMap.get('row1.updated_at'),deleted_at=globalMap.get('row1.deleted_at');
       Client client = new Client(id,identification,name,last_name,phone,phone2,email,email2,address,state,liner,clouser_name,city,user_id,created_at,updated_at,observation,deleted_at);
       clientArray[count]=client;
       count= count+1;
       if(count==7668){
          for(int i=1;i<=clientArray.lenght;i++){
            System.out.print(clientArray[i]);
          }
       }
}
}

download file:

Offline

#2 2016-11-27 17:50:11

JoRoesecke
Member
112 posts

JoRoesecke said:

Re: DQ With TJava

Hi

I believe there is a misunderstanding about what tJava and in fact a Talend job is and does. I do not understand what you want to achieve with this code, but you cannot define a new "main" method in there. Please understand that Talend builds the Java code for you (including "main"). Only in those circumstances when you cannot find a suitable component (there are a lot of those - all well documented) you should introduce custom Java code. Please click on the "Code" tab under the job design and maybe you will see what I mean. This is the code Talend will generate for you.
Just a couple of hints:

  1. You never defined "migration.Client" (would not work if you did)

  2. It should be ((DATA TYPE)globalMap.get("row1.FIELD")) instead of just globalMap.get('row1.FIELD') (use double quotes!)

  3. When did you fill the globalMap with the values you are getting? In a tFlowToIterate step before that?

That being said, please provide a description of what you want to achieve (input, output, conversions, etc.) and someone might be able to point you in the right direction. A picture of your current job design is always helpful.

Regards, Joachim

Offline

Board footer

Talend Contributor Agreement - Talend Website Privacy Policy