|
15 | 15 | /* |
16 | 16 | * This class provides information about the database as a whole. |
17 | 17 | * |
18 | | - * $Id: DatabaseMetaData.java,v 1.57 2002/06/25 16:30:49 davec Exp $ |
| 18 | + * $Id: DatabaseMetaData.java,v 1.58 2002/07/12 13:07:48 davec Exp $ |
19 | 19 | * |
20 | 20 | * <p>Many of the methods here return lists of information in ResultSets. You |
21 | 21 | * can use the normal ResultSet methods such as getString and getInt to |
@@ -2625,55 +2625,40 @@ else if ("setdefault".equals(rule)) |
2625 | 2625 |
|
2626 | 2626 |
|
2627 | 2627 | // Parse the tgargs data |
2628 | | -StringBufferfkeyColumns =newStringBuffer(); |
2629 | | -StringBufferpkeyColumns =newStringBuffer(); |
| 2628 | +StringfkeyColumn=""; |
| 2629 | +StringpkeyColumn=""; |
2630 | 2630 |
|
2631 | 2631 |
|
2632 | 2632 | // Note, I am guessing at most of this, but it should be close |
2633 | 2633 | // if not, please correct |
2634 | 2634 | // the keys are in pairs and start after the first four arguments |
2635 | 2635 | // the arguments are seperated by \000 |
2636 | 2636 |
|
2637 | | -intnumColumns = (rs.getInt(8) >>1) -2; |
2638 | | - |
2639 | | - |
| 2637 | +intkeySequence =rs.getInt(4);//KEY_SEQ |
2640 | 2638 |
|
2641 | 2639 | // get the args |
2642 | 2640 | Stringtargs =rs.getString(9); |
2643 | 2641 |
|
2644 | | -// start parsing from the end |
2645 | | -intpos =targs.lastIndexOf("\\000"); |
| 2642 | +// args look like this |
| 2643 | +//<unnamed>\000ww\000vv\000UNSPECIFIED\000m\000a\000n\000b\000 |
| 2644 | +// we are primarily interested in the column names which are the last items in the string |
| 2645 | + |
| 2646 | +StringTokenizerst =newStringTokenizer(targs,"\\000"); |
2646 | 2647 |
|
2647 | | -for (intc =0;c <numColumns;c++) |
| 2648 | +intadvance =4 + (keySequence-1) *2; |
| 2649 | +for(inti=0;st.hasMoreTokens() &&i <advance ;i++ )st.nextToken();// advance to the key column of interest |
| 2650 | + |
| 2651 | +if (st.hasMoreTokens() ) |
| 2652 | + { |
| 2653 | +fkeyColumn =st.nextToken(); |
| 2654 | + } |
| 2655 | +if (st.hasMoreTokens() ) |
2648 | 2656 | { |
2649 | | -// this should never be, since we should never get to the beginning of the string |
2650 | | -// as the number of columns should override this, but it is a safe test |
2651 | | -if (pos > -1) |
2652 | | - { |
2653 | | -intpos2 =targs.lastIndexOf("\\000",pos -1); |
2654 | | -if (pos2 > -1) |
2655 | | - { |
2656 | | -// seperate the pkColumns by ',' s |
2657 | | -if (pkeyColumns.length() >0) |
2658 | | -pkeyColumns.insert(0,','); |
2659 | | - |
2660 | | -// extract the column name out 4 characters ahead essentially removing the /000 |
2661 | | -pkeyColumns.insert(0,targs.substring(pos2 +4,pos));//PKCOLUMN_NAME |
2662 | | - |
2663 | | -// now find the associated fkColumn |
2664 | | -pos =targs.lastIndexOf("\\000",pos2 -1); |
2665 | | -if (pos > -1) |
2666 | | - { |
2667 | | -if (fkeyColumns.length() >0) |
2668 | | -fkeyColumns.insert(0,','); |
2669 | | -fkeyColumns.insert(0,targs.substring(pos +4,pos2));//FKCOLUMN_NAME |
2670 | | - } |
2671 | | - } |
2672 | | - } |
| 2657 | +pkeyColumn =st.nextToken(); |
2673 | 2658 | } |
2674 | 2659 |
|
2675 | | -tuple[3] =pkeyColumns.toString().getBytes();//PKCOLUMN_NAME |
2676 | | -tuple[7] =fkeyColumns.toString().getBytes();//FKCOLUMN_NAME |
| 2660 | +tuple[3] =pkeyColumn.getBytes();//PKCOLUMN_NAME |
| 2661 | +tuple[7] =fkeyColumn.getBytes();//FKCOLUMN_NAME |
2677 | 2662 |
|
2678 | 2663 | tuple[8] =rs.getBytes(4);//KEY_SEQ |
2679 | 2664 | tuple[11] =rs.getBytes(3);//FK_NAME |
|