About Question enthuware.ocpjp.v7.2.1261 :
Moderator: admin
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
About Question enthuware.ocpjp.v7.2.1261 :
Hi,
I read precedently that in order to proper match this joins, it's necessary to use setKeyColumns(arrayKey);.
So far I have never seen a use of this method.. do you know when it helps?
I thought that at least the 2 CachedRowSet created in this question should have declared "setKeyColumns(new int[]{1});" but apparently there is no need.
Again, when is it indeed mandatory the method setKeyColumns?
Thanks in advance.
The_Nick.
I read precedently that in order to proper match this joins, it's necessary to use setKeyColumns(arrayKey);.
So far I have never seen a use of this method.. do you know when it helps?
I thought that at least the 2 CachedRowSet created in this question should have declared "setKeyColumns(new int[]{1});" but apparently there is no need.
Again, when is it indeed mandatory the method setKeyColumns?
Thanks in advance.
The_Nick.
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
To do a join, you need match columns (not key columns). If you specify join columns while adding rowsets to JoinRowSet, so Key columns on individual rowset are not required. See the parameters of JoinRowSet.addRowSet.
The API description of this method explains the details: http://docs.oracle.com/javase/7/docs/ap ... olumns(int[])
HTH,
Paul.
The API description of this method explains the details: http://docs.oracle.com/javase/7/docs/ap ... olumns(int[])
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
I have gone through those API, it does not say when it's indispensable to be used. However it's mentioned in CachedRowSet java tutorial description, without explaning the case in particular. All the operation I ever made with any rowset, I have never come across the need to use setKeyColumn, I am wondering if it's for future purposes.
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
The API description is quite clear on its purpose, "Sets this CachedRowSet object's keyCols field with the given array of column numbers, which forms a key for uniquely identifying a row in this CachedRowSet object.
If a CachedRowSet object becomes part of a JoinRowSet object, the keys defined by this method and the resulting constraints are maintained if the columns designated as key columns also become match columns."
Not sure what is the confusion. If you want to uniquely identify a row in a CRS, use setKeyColumns. Otherwise, don't.
If a CachedRowSet object becomes part of a JoinRowSet object, the keys defined by this method and the resulting constraints are maintained if the columns designated as key columns also become match columns."
Not sure what is the confusion. If you want to uniquely identify a row in a CRS, use setKeyColumns. Otherwise, don't.
If you like our products and services, please help us by posting your review here.
-
- Posts: 53
- Joined: Thu Nov 22, 2012 12:01 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
About the code shown in the explanation:
JoinRowSet jrs2 = rsf.createJoinRowSet();
jrs.setMatchColumn("SUBJECT"); //First change the match column of first jrs to SUBJECT.
jrs2.addRowSet(jrs);
jrs2.addRowSet(teacherRS, "SUBJECT");
Can I change it to the following?
JoinRowSet jrs2 = rsf.createJoinRowSet();
jrs2.addRowSet(jrs);
jrs2.setMatchColumn("SUBJECT");
//jrs2.addRowSet(jrs);
jrs2.addRowSet(teacherRS, "SUBJECT");
JoinRowSet jrs2 = rsf.createJoinRowSet();
jrs.setMatchColumn("SUBJECT"); //First change the match column of first jrs to SUBJECT.
jrs2.addRowSet(jrs);
jrs2.addRowSet(teacherRS, "SUBJECT");
Can I change it to the following?
JoinRowSet jrs2 = rsf.createJoinRowSet();
jrs2.addRowSet(jrs);
jrs2.setMatchColumn("SUBJECT");
//jrs2.addRowSet(jrs);
jrs2.addRowSet(teacherRS, "SUBJECT");
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
No, you can't call jsr2.addRowSet(jrs); because it will throw an exception if the match column is not set before this method is called. Please go through the API description of JoinRowSet to see how it works. They have explained it really well at http://docs.oracle.com/javase/7/docs/ap ... owSet.html
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 53
- Joined: Thu Nov 22, 2012 12:01 am
- Contact:
-
- Posts: 8
- Joined: Tue Jan 27, 2015 3:33 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
Code: Select all
JoinRowSet jrs2 = rsf.createJoinRowSet();
jrs.setMatchColumn("SUBJECT"); //First change the match column of first jrs to SUBJECT.
jrs2.addRowSet(jrs);
jrs2.addRowSet(teacherRS, "SUBJECT"); //Now match jrs's SUBJECT with teacherRS's SUBJECT.
Code: Select all
jrs.setMatchColumn("SUBJECT")
Code: Select all
jrs.addRowSet(teacherRS, "SUBJECT");
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
Did you read the explanation? It explains exactly what you are asking.
If you like our products and services, please help us by posting your review here.
-
- Posts: 15
- Joined: Tue Jan 13, 2015 12:10 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
Is it right, that every time I need to change a matching column, I need to create a new instance of JoinRowSet?
-
- Posts: 15
- Joined: Tue Jan 13, 2015 12:10 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
Can I change
jrs.setMatchColumn("SUBJECT"); jrs2.addRowSet(jrs);
to
jrs2.addRowSet(jrs, "SUBJECT");
?
jrs.setMatchColumn("SUBJECT"); jrs2.addRowSet(jrs);
to
jrs2.addRowSet(jrs, "SUBJECT");
?
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
Yes.Alina_Lapina wrote:Is it right, that every time I need to change a matching column, I need to create a new instance of JoinRowSet?
If you like our products and services, please help us by posting your review here.
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1261 :
YesAlina_Lapina wrote:Can I change
jrs.setMatchColumn("SUBJECT"); jrs2.addRowSet(jrs);
to
jrs2.addRowSet(jrs, "SUBJECT");
?
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 115 guests